A script to convert a BAO JSON schema template to a CEDAR schema template
- Clone this repo and run
bundle install
- Copy config/config.yml.sample to config/config.yml
- Edit config/config.yml and replace the following attributes with your own:
- bp_api_key: "your-bioportal-api-key"
- cedar_api_key: "your-cedar-api-key"
BioPortal API key can be found here: https://bioportal.bioontology.org/account
CEDAR API key can be found here: https://cedar.metadatacenter.org/profile
The script accepts the following parameters (all are OPTIONAL):
-s PATH_TO_SOURCE_TEMPLATE Optional path to the source template file --source Default: latest version of template is pulled from: https://github.com/cdd/bioassay-template/blob/master/data/template/schema.json -d PATH_TO_DESTINATION_TEMPLATE Optional path to the destination template file --destination Default: data/cedar-bao-schema.json -l, PATH_TO_LOG_FILE Optional path to the log file --log Default: logs/bao-to-cedar.log -p, [true/false] Optionally post template to CEDAR (if it passes validation) --post-to-cedar Default: false -h --help Display help screen
Usage: bao_cedar_template_converter.rb [options]
$ bundle exec ruby bao_cedar_template_converter.rb -s data/bao-schema.json -d data/cedar-bao-schema.json
$ bundle exec ruby bao_cedar_template_converter.rb -s data/bao-schema.json -d data/cedar-bao-schema.json -p true
$ bundle exec ruby bao_cedar_template_converter.rb -p true
$ bundle exec ruby bao_cedar_template_converter.rb -p true Generating CEDAR template... Logging output to logs/bao-to-cedar.log Source template: https://github.com/cdd/bioassay-template/blob/master/data/template/schema.json Destination template: data/cedar-bao-schema.json Downloading source template from Github... Source template downloaded successfully. Processing... Completed generating the new template. Running the template through the CEDAR validator... New template validated successfully. Uploading new template to CEDAR... New template successfully uploaded to CEDAR. Completed template conversion, validation and upload in 16.811006000003545 seconds.
$ bundle exec ruby bao_cedar_template_converter.rb -s /Downloads/bao-schema-orig.json -p true Generating CEDAR template... Logging output to logs/bao-to-cedar.log Source template: /Downloads/bao-schema-orig.json Destination template: data/cedar-bao-schema.json New template validated successfully by the CEDAR validator. Uploading new template to CEDAR... New template failed CEDAR upload with the following feedback (logged in logs/bao-to-cedar.log): Response Code: 400 { "status": "BAD_REQUEST", "errorType": null, "errorKey": "templateNotCreated", "errorReasonKey": null, "message": "The template must not contain a non-null '@id' field!", "parameters": { "@id": "https://repo.metadatacenter.org/templates/88eafcd0-c2a1-4c9c-acec-387ce26cc21e" }, "suggestedAction": "none", "originalException": null, "sourceException": null, "operation": null } Completed template conversion and validation in 19.352610000001732 seconds.