Public | Automated Build

Last pushed: 2 days ago
Short Description
Integration tests for openphacts/ops-linkeddataapi
Full Description

OPS.js

Open PHACTS API Version

2.1

About

OPS.js is a javascript NodeJS based library, available via NPM, for accessing the Open PHACTS Linked Data API (LDA). It uses nets to handle the asynchronous network calls. OPS.js can also be used to parse responses from the LDA.
Please read the API documentation. The API documentation is also available locally within the docs folder. To view them open the docs/index.html file in a browser.

Dependencies & requirements

NodeJS, NPM, nets, JSDoc & browserify
Get your Open PHACTS API application ID and key by registering at https://dev.openphacts.org

Licence

The OPS.js source code is released under the MIT License, http://opensource.org/licenses/MIT. See licence.txt for more details.

Contributing

We love receiving patches for bug fixes and new features. Please follow these simple steps to make our lives easier.

  1. Fork the project.
  2. Checkout develop branch.
  3. Create a new branch based on develop and change the code.
  4. Write some tests.
  5. Submit patch.

Citations

To cite OPS.js in publications please see the zenodo record.

Ian Dunlop et al. (2016). ops.js: OPS.js 7.0.0 for Open PHACTS 2.1 API. Zenodo. 10.5281/zenodo.167595

For Bibtex use:

@misc{ian_dunlop_2016_167595,
  author       = {Ian Dunlop and
                  Egon Willighagen and
                  Elblood and
                  Andra Waagmeester and
                  Stian Soiland-Reyes and
                  PANDORINO and
                  Morton Fox},
  title        = {ops.js: OPS.js 7.0.0 for Open PHACTS 2.1 API},
  month        = nov,
  year         = 2016,
  doi          = {10.5281/zenodo.167595},
  url          = {http://dx.doi.org/10.5281/zenodo.167595}
}

You can get version information by using an OPS.js method in a browser or Node:

    new Version().information()

Using the library

If running in a browser based application use src/combined.js. With NodeJS use npm install ops.js.
See the API documentation

Each API call generally has 1 method to fetch the results using an asynchronous call with a callback and then another method to parse these results.
Look at https://dev.openphacts.org for more information about the source methods that the API calls use.

Testing the library

Jasmine is used to test the ops.js api. The specs for the tests are in the 'test/spec' directory. To run them use jasmine-node like this:

jasmine-node --config app_id your_app_id --config app_key your_app_key --config app_url https://beta.openphacts.org/2.1 test/spec/integration/

In case the test run does not finish with some statistics on the number of tests run, assertions made, and skipped and failed tests,
then it like failed on one of the tests. To see the exception that was thrown, run Jasmine with the --captureExceptions option:

jasmine-node --captureExceptions --config app_id your_app_id --config app_key your_app_key --config app_url https://beta.openphacts.org/1.5 test/spec/integration/

To enable console logging of URIs tested, add the parameter --config debug true

Testing with Docker

If you use Docker, you can run the openphacts/ops-api-test image
to run the tests, without needing to install NodeJS.

Run with the -it parameter to get colour output.
You might want to override environment variables like app_url, app_id and app_key.
Example:

docker run -it -e app_url=http://heater.cs.man.ac.uk:3002 openphacts/ops-api-test

API call examples:

More examples can be found in the integration tests and in the API docs.

Concept Wiki free text search

var searcher = new ConceptWikiSearch("https://beta.openphacts.org/2.1", appID, appKey);  
var callback=function(success, status, response){  
    searcher.parseResponse(response);
};  
// success is 'true' or 'false', status is the http status code, response is the raw result which the parser function accepts  
// response will be null in the case of errors  
// limit to 20 results, species human (branch 4), with type set to compounds (uuid 07a800....)  
searcher.byTag('Aspirin', '20', '4', '07a84994-e464-4bbf-812a-a4b96fa3d197', callback);

Compound information

var searcher = new CompoundSearch("https://beta.openphacts.org/2.1", appID, appKey);  
var callback=function(success, status, response){  
    var compoundResult = searcher.parseCompoundResponse(response);  
};  
// success is 'true' or 'false', status is the http status code, response is the raw result which the parser function accepts  
// response will be null in the case of errors  
// compound uri is for Aspirin  
searcher.fetchCompound('http://www.conceptwiki.org/concept/38932552-111f-4a4e-a46a-4ed1d7bdf9d5', null, callback);

Core Developers

Ian Dunlop

Contributors

Rishi Ramgolam
Elblood
Andra Waagmeester
Egon Willighagen
PANDORINO
Stian Soiland-Reyes
Morton Fox

Docker Pull Command
Owner
openphacts
Source Repository

Comments (0)