Library to facilitate access to the Pathway Commons web service
npm install pathway-commonsPathway Commons JS Library 
================
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.
CommonJS:
``js`
var pathwayCommons = require('pathway-commons');
ES6 Imports:
`js`
// The entire library can be imported
import pathwayCommons from 'pathway-commons';
// Or only the necessary functions
import {utilities, search} from 'pathway-commons';
js
var pathwayCommons = require('pathway-commons'); // Import librarypathwayCommons.utilities.user('my-demo-app'); // Set your user/app name
pathwayCommons.search() // Initialise a new Pathway Commons search request
.q("insulin") // Set the q parameter
.datasource(["inoh", "reactome"]) // filter by data source
.type("pathway") // filter by BioPAX class (includes sub-classes)
.organism("homo sapiens") // filter by orgamism (currently, Pathway Commons aims to integrate human data only)
.format("json") // Set the output format
.fetch() // Send the request to the Pathway Commons service
.then((obj) => { // Receive the response asynchronously
console.log(obj);
});
pathwayCommons.search() // Or use an object containing all request parameters
.query({
q: "insulin",
datasource: [
"inoh",
"reactome"
],
type: "pathway",
organism: "homo sapiens"
})
.format("json")
.fetch()
.then((obj) => {
console.log(obj);
});
`See unit tests or documentation for more examples on how the library can be used.
Build
$3
- Node.js >=4.0.0. In order to support earlier versions, compile for node and add polyfills for missing features (etc. Promises).
$3
The following environment variables can be used to configure the server:
-
NODE_ENV : the environment mode, either production or development (default)
- PORT : the port on which the server runs (default 3000)$3
-
npm run build : build project
- npm run build-prod : build the project for production
- npm run clean : clean the project
- npm run watch : watch mode (debug mode enabled, auto rebuild, livereload)
- npm test : run tests
- npm run lint : lint the project
- npm run docs : Generate documentation and place resulting HTML files in the docs folder$3
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.