From c75dd1a55ab7a5ae22ff381058950a630bdab65a Mon Sep 17 00:00:00 2001 From: Adam Abeshouse Date: Fri, 25 Aug 2017 16:57:05 -0400 Subject: [PATCH] Merge pull request #29 from pambot/node-package Updates to node package functionality --- packages/oncoprintjs/.npmignore | 8 ++++++++ packages/oncoprintjs/.travis.yml | 3 +++ packages/oncoprintjs/README.md | 24 +++++++++++++++--------- packages/oncoprintjs/gulpfile.js | 10 ++++++---- packages/oncoprintjs/package.json | 6 +++--- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/packages/oncoprintjs/.npmignore b/packages/oncoprintjs/.npmignore index a2424b16386..f13f1eb96ef 100644 --- a/packages/oncoprintjs/.npmignore +++ b/packages/oncoprintjs/.npmignore @@ -1,5 +1,13 @@ # Created by https://www.gitignore.io +### Repo Files ### +src/ +test/ +server.js +gulpfile.js +.gitignore +.travis.yml + ### Node ### # Logs logs diff --git a/packages/oncoprintjs/.travis.yml b/packages/oncoprintjs/.travis.yml index 214d9ab472e..866614d575a 100644 --- a/packages/oncoprintjs/.travis.yml +++ b/packages/oncoprintjs/.travis.yml @@ -3,6 +3,9 @@ node_js: - '6' before_deploy: - npm run build +- mv ./dist/oncoprint-bundle.js ./index.js +- cp -r ./dist/* ./ +- rm -rf dist deploy: provider: npm email: cbioportal@gmail.com diff --git a/packages/oncoprintjs/README.md b/packages/oncoprintjs/README.md index 97773282ce5..dd0cc2b7cda 100644 --- a/packages/oncoprintjs/README.md +++ b/packages/oncoprintjs/README.md @@ -2,7 +2,19 @@ # OncoprintJS This is the library that generates the Oncoprint visualization in cBioPortal. Essentially, it populates a canvas of a grid of `m` tracks of `n` types, where each element can either be a discrete value represented by a colored glyph on a grey background or a continuous value within a color range. Oncoprint can have many conceivable uses, but in cBioPortal, it is primarily used to visualize tracks of `m` genes and `n` patient samples, where the colored glyphs represent genomic alterations. It is also used to display a heatmap of gene and/or protein expression values for those `m` genes and `n` patient samples. -## Getting Started +## Using the Node Module +Oncoprint is on [NPM](https://www.npmjs.com/package/oncoprintjs). To install: + + npm install --save oncoprintjs + +In order to use it, just `require` it into your script. + + const Oncoprint = require('oncoprintjs'); + +This will load the `Oncoprint` prototype into your environment. A full documentation of the API is still pending, but to see the basic usage in action, please follow the instructions below and take a look at the examples in the `test/` directory. + +## Development +### Getting Started First, clone the repo: git clone https://github.com/cBioPortal/oncoprintjs.git @@ -11,20 +23,14 @@ Install the necessary NPM packages defined in `package.json`, create the output cd oncoprintjs npm install - mkdir -p dist gulp -Oncoprint currently has some hard-coded image files, so to set it up for the examples, run: - - mkdir -p dist/img - mv dist/*.svg dist/img - You should now have a folder `dist/` with the oncoprint files in it, including `oncoprint-bundle.js`. This is the original library file. The directory `rules/` contains glyph styling specifications that are specific to the genomic alterations use case of Oncoprint, so it is separate for the library file. -## Changes to Oncoprint +### Changes to Oncoprint If you make changes to the Oncoprint code base and want to load it into the examples, do not modify `oncoprint-bundle.js`, since all of your code will get overwritten when gulped. Instead, modify the files in `src/` and then re-run `gulp`. -## Minimum Working Example +### Minimum Working Example The `test/` folder holds the code that runs the examples. All examples are mounted in `index.html`, which contains one JS file per example. The file `server.js` starts the basic node server, serving files from `dist/`, `rules/`, and `test/` on port 3000. To see the examples, execute the following: node server.js diff --git a/packages/oncoprintjs/gulpfile.js b/packages/oncoprintjs/gulpfile.js index 0e68b02e7e9..a5ee3058ccf 100644 --- a/packages/oncoprintjs/gulpfile.js +++ b/packages/oncoprintjs/gulpfile.js @@ -1,7 +1,9 @@ var gulp = require('gulp'); var shell = require('gulp-shell'); -gulp.task('default', shell.task(['browserify src/js/main.js -o dist/oncoprint-bundle.js', - 'cp src/css/* dist/', - 'cp src/img/* dist/', - ])); +gulp.task('default', shell.task([ + 'mkdir -p dist/img', + 'browserify src/js/main.js -o dist/oncoprint-bundle.js', + 'cp src/css/* dist/', + 'cp src/img/* dist/img/', +])); diff --git a/packages/oncoprintjs/package.json b/packages/oncoprintjs/package.json index c6080f6ae73..a2c26e68ecf 100644 --- a/packages/oncoprintjs/package.json +++ b/packages/oncoprintjs/package.json @@ -3,8 +3,8 @@ "version": "1.0.2", "description": "A data visualization for cancer genomic data.", "scripts": { - "clean": "rm -rf dist", - "build": "npm run clean && mkdir -p dist && gulp && mkdir -p dist/img && mv dist/*.svg dist/img" + "clean": "rm -rf dist", + "build": "npm run clean && gulp" }, "repository": { "type": "git", @@ -43,7 +43,7 @@ "dependencies": { "express": "^4.15.3", "gl-matrix": "^2.3.2", - "jquery": "^1.11.1", + "jquery": "^1.11.3", "underscore": "^1.7.0" } }