GithubHelp home page GithubHelp logo

global-localhost / bao_cedar_template_converter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metadatacenter-attic/bao_cedar_template_converter

0.0 0.0 0.0 55 KB

A script to convert a BAO template to a CEDAR template

Ruby 100.00%

bao_cedar_template_converter's Introduction

BAO-TO-CEDAR Template Converter

A script to convert a BAO JSON schema template to a CEDAR schema template

Installation

  1. Clone this repo and run bundle install
  2. Copy config/config.yml.sample to config/config.yml
  3. Edit config/config.yml and replace the following attributes with your own:
    1. bp_api_key: "your-bioportal-api-key"
    2. 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

Execution:

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]

Run Example:

Generate template:

$ bundle exec ruby bao_cedar_template_converter.rb -s data/bao-schema.json -d data/cedar-bao-schema.json

Generate template and post it to CEDAR:

$ bundle exec ruby bao_cedar_template_converter.rb -s data/bao-schema.json -d data/cedar-bao-schema.json -p true

Generate template by pulling the source file from BAO Github repo and post result to CEDAR:

$ bundle exec ruby bao_cedar_template_converter.rb -p true

Sample Output:

Success:

$ 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.

Failure:

$ 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.

bao_cedar_template_converter's People

Contributors

mdorf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.