Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including solvebio with all npm packages installed. Try it out:

var solvebio = require("solvebio")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

solvebio v1.2.1

SolveBio Javascript client

Build Status

solvebio-js

SolveBio Javascript SDK

Features

  • Full SolveBio Api binding
  • Works in NodeJS and in the browser
  • Support of promises
  • Uses Angular, jQuery, Q or native promises if available
  • Special build solvebio-promises.js includes BlueBird promises API
  • Support pagination

Usage

Install

npm

npm install solvebio

Then require('solvebio') in your code.

bower

bower install solvebio

Then add a <script> to your index.html:

<!-- If you already have a promise library loaded, just include solvebio.js -->
<script src="/bower_components/solvebio/dist/solvebio.js"></script>

<!-- If you don't include solvebio-promises.js. This version is bundled with the BlueBird promise library. -->
<script src="/bower_components/solvebio/dist/solvebio-promises.js"></script>

Initialize SolveBio

Initialize SolveBio Javascript client with your Oauth token. Please contact us at [support@solvebio.com](mailto:support@solvebio.com?subject=[Oauth token request]) to get your Oauth token.

var SolveBio = require('solvebio');

SolveBio.init({
  accessToken: <YOUR OAUTH TOKEN>
});

Retrieve a specific dataset

var dataset = SolveBio.Dataset('ClinVar/Variants');

dataset.retrieve()
  .then(function(response) {
    // Your code goes here...
  });

Create filters

var filter1 = SolveBio.Filter({
    gene_symbol: 'BRCA1'
  }), 
  filter2 = SolveBio.Filter({
    gene_symbol: 'BRCA2'
  });
  
var filter = filter1.or(filter2);

Apply Filters and Retrieve query results

dataset.filter(filter)
  .then(function(response) {
    // Your code goes here...
  });

Retrieve a list of paged results

var Promise = require('es6-promise').Promise;

function loadAll(promise) {
  var deferred = Promise.defer(),
    data = [];
    
  load(promise);
  
  return deferred.promise;
  
  function load(promise) {
    promise
      .then(function(response) {
        data = data.concat(response.data);
        if(response.next) {
          load(response.next());
        }
        else {
          deferred.resolve(data);
        }
      });
  }
}

loadAll(SolveBio.Dataset().all())
 .then(function(datasets) {
   // Your code goes here...
 });

Example

An HTML example is provided at examples/simple.html. You can try it by cloning the repository and opening the file in your browser.

Developing

Building from sources

First install Node/NPM then do this:

sudo npm install -g grunt-cli

Then:

npm install
grunt build

Contributing to solvebio-js

Use the build:dev task:

npm install
grunt build:dev
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free