Skip to content

Commit

Permalink
Merge pull request cBioPortal#29 from pambot/node-package
Browse files Browse the repository at this point in the history
Updates to node package functionality
  • Loading branch information
adamabeshouse authored and onursumer committed May 18, 2022
1 parent 61edf6f commit c75dd1a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
8 changes: 8 additions & 0 deletions packages/oncoprintjs/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Created by https://www.gitignore.io

### Repo Files ###
src/
test/
server.js
gulpfile.js
.gitignore
.travis.yml

### Node ###
# Logs
logs
Expand Down
3 changes: 3 additions & 0 deletions packages/oncoprintjs/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions packages/oncoprintjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions packages/oncoprintjs/gulpfile.js
Original file line number Diff line number Diff line change
@@ -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/',
]));
6 changes: 3 additions & 3 deletions packages/oncoprintjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}

0 comments on commit c75dd1a

Please sign in to comment.