Pathway Commons JS Library
Description
This library is an interface for accessing the Pathway Commons web API, which is designed to make Pathway Commons easier to work with. In addition, it contains useful optimisations to improve efficiency, and various tools which may be useful when working with Pathway Commons data.
The library makes use of promises in order to keep the API clean. Therefore, if you must support browsers which do not natively support promises, please include a polyfill in your project.
We also have a Pathway Commons (cPath2) java client library.
Getting Started
This library can be included directly using a script tag, or it can be imported using several methods. This library is available on NPM.
CommonJS:
var pathwayCommons = ;
ES6 Imports:
// The entire library can be imported;// Or only the necessary functions;
Setting a username
We request that our users set a username (or app name), which allows us to analyse how and what kind of different clients use the Pathway Commons web services. If no username is set, then the default username (ID) will be used.
Usage Example
var pathwayCommons = ; // Import library pathwayCommonsutilities; // Set your user/app name pathwayCommons // Initialise a new Pathway Commons search request // Set the q parameter // filter by data source type"pathway" // filter by BioPAX class (includes sub-classes) // filter by orgamism (currently, Pathway Commons aims to integrate human data only) // Set the output format // Send the request to the Pathway Commons service ; pathwayCommons // Or use an object containing all request parameters ;
See unit tests or documentation for more examples on how the library can be used.
Build
Required Software
- Node.js >=4.0.0. In order to support earlier versions, compile for node and add polyfills for missing features (etc. Promises).
Configuration
The following environment variables can be used to configure the server:
NODE_ENV
: the environment mode, eitherproduction
ordevelopment
(default)PORT
: the port on which the server runs (default 3000)
Run targets
npm run build
: build projectnpm run build-prod
: build the project for productionnpm run clean
: clean the projectnpm run watch
: watch mode (debug mode enabled, auto rebuild, livereload)npm test
: run testsnpm run lint
: lint the projectnpm run docs
: Generate documentation and place resulting HTML files in the docs folder
Testing
All files /test
will be run by Mocha. You can npm test
to run all tests, or you can run mocha -g specific-test-name
(prerequisite: npm install -g mocha
) to run specific tests.
Chai is included to make the tests easier to read and write.