A script to convert a BAO JSON schema template to a CEDAR schema template
This is an OPTIONAL step for those who don't have a functioning Ruby environment configured on their workstations.
- Run this command in your Terminal/Bash:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
https://github.com/rbenv/rbenv
- Install and update rbenv dependent libraries:
$ brew install rbenv
$ brew upgrade rbenv ruby-build
- Re-start your Terminal/Bash/Command Prompt application by fully quitting it and starting a new session.
- Execute these commands in your Terminal:
$ rbenv install -l
- Choose the latest Ruby version from the list above (ex: 3.0.2) and execute these commands:
$ rbenv install 3.0.2
$ rbenv global 3.0.2
- Check the installed Ruby version:
$ rbenv versions
The output should show ALL Ruby versions installed and the one currently selected. The selected version should be one other than “system”, as in:
system
2.5.8
2.7.1
* 3.0.2 (set by /Users/mdorf/.rbenv/version)
-
IMPORTANT: Re-start your Terminal/Bash/Command Prompt application by fully quitting it and starting a new session.
-
Check the currently running Ruby version:
$ ruby --version
The output should match the Ruby version you've just installed. Example:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin18]
- Navigate to (or create) the folder that will contain the BAO-CEDAR Converter (ex: ~/dev/scripts):
$ cd ~/dev/scripts
- Clone the project from Github:
$ git clone https://github.com/metadatacenter/bao_cedar_template_converter.git
- Navigate to the BAO-CEDAR Converter folder (which was created by the
clone
command):
$ cd ~/dev/scripts/bao_cedar_template_converter
- Run these commands:
$ git stash
$ git pull origin master
$ gem install bundler
$ bundle install
- Create the file
bao_cedar_template_converter/config/config.yml
from the provided sample:
$ cp config/config.yml.sample config/config.yml
-
Open the file
bao_cedar_template_converter/config/config.yml
in your favorite text editor 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
For example (below API keys aren't real, they are provided for reference only):
bp_api_key: "17e2c93c-78f0-19e9-9d8b-029056aa3219"
cedar_api_key: "15ce8bb6cf5b5334c2a5646625w32149a944baa8ce5bb574555700c64ed776a9"
$ bundle exec ruby bao_cedar_template_converter.rb
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 'common assay 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.