├── .travis.yml
├── test
├── sample.gz
├── sample.zip
├── sample.vcf
└── test_vcf.js
├── .gitignore
├── .npmignore
├── LICENSE
├── package.json
├── CODE_OF_CONDUCT.md
├── README.md
├── lib
└── index.js
└── CONTRIBUTING.md
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 7
4 |
--------------------------------------------------------------------------------
/test/sample.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bionode/bionode-vcf/master/test/sample.gz
--------------------------------------------------------------------------------
/test/sample.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bionode/bionode-vcf/master/test/sample.zip
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .idea/
3 | *.log
4 | .DS_Store
5 | build
6 | coverage/lcov.info
7 | .coveralls.yml
8 | examples-out
9 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | example
4 | docs
5 | .idea
6 |
7 |
8 | # don't ignore .npmignore files
9 | !.npmignore
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2015, Shyam Rallapalli
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
25 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bionode-vcf",
3 | "description": "a vcf parser in javascript",
4 | "version": "1.3.0",
5 | "homepage": "https://github.com/bionode/bionode-vcf",
6 | "author": {
7 | "name": "Shyam Rallapalli",
8 | "email": "shyam.rallapalli@gmail.com"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git://github.com/bionode/bionode-vcf.git"
13 | },
14 | "bugs": {
15 | "url": "https://github.com/bionode/bionode-vcf/issues"
16 | },
17 | "licenses": [
18 | {
19 | "type": "MIT",
20 | "url": "https://github.com/bionode/bionode-vcf/blob/master/LICENSE"
21 | }
22 | ],
23 | "main": "lib/index.js",
24 | "scripts": {
25 | "test": "standard && dependency-check . && mocha"
26 | },
27 | "dependencies": {
28 | "events": "^1.1.1",
29 | "readline": "^1.3.0",
30 | "stream": "0.0.2",
31 | "unzip-stream": "^0.3.0"
32 | },
33 | "devDependencies": {
34 | "chai": "^4.0.1",
35 | "dependency-check": "^2.8.0",
36 | "mocha": "^3.4.2",
37 | "standard": "^10.0.2"
38 | },
39 | "keywords": [
40 | "vcf parser",
41 | "vcf",
42 | "bionode",
43 | "bionode"
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at mail@bionode.io. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | bionode.io
7 |
8 |
9 |
10 | # bionode-vcf
11 |
12 | > a vcf parser in javascript
13 |
14 | [](http://npmjs.org/package/bionode-vcf)
15 | [](https://travis-ci.org/bionode/bionode-vcf)
16 | [](http://coveralls.io/r/bionode/bionode-vcf)
17 | [](http://david-dm.org/bionode/bionode-vcf)
18 | [](https://www.npmjs.com/package/bionode-vcf)
19 | [](https://gitter.im/bionode/bionode)
20 |
21 |
22 | ## Install
23 |
24 | You need to install the latest Node.JS first, please check [nodejs.org](http://nodejs.org) or do the following:
25 |
26 | ```bash
27 | # Ubuntu
28 | sudo apt-get install npm
29 | # Mac
30 | brew install node
31 | # Both
32 | npm install -g n
33 | n stable
34 | ```
35 |
36 | To use `bionode-vcf` as a command line tool, you can install it globally with `-g`.
37 |
38 | ```bash
39 | npm install bionode-vcf -g
40 | ```
41 |
42 | Or, if you want to use it as a JavaScript library, you need to install it in your local project folder inside the `node_modules` directory by doing the same command **without** `-g`.
43 |
44 | ```bash
45 | npm i bionode-vcf # 'i' can be used as shortcut to 'install'
46 | ```
47 |
48 |
49 | ### Usage
50 |
51 | #### vcf.read
52 | - `vcf.read` takes params: `path`
53 | - The supported filetypes are `vcf`, `zip` and `gz`.
54 |
55 | ```javascript
56 | var vcf = require('bionode-vcf');
57 | vcf.read("/path/sample.vcf");
58 | vcf.on('data', function(feature){
59 | console.log(feature);
60 | })
61 |
62 | vcf.on('end', function(){
63 | console.log('end of file')
64 | })
65 |
66 | vcf.on('error', function(err){
67 | console.error('it\'s not a vcf', err)
68 | })
69 |
70 | ```
71 |
72 | #### vcf.readStream
73 | - `vcf.readStream` takes params: `stream` and `extension`
74 | - The supported extension are `vcf`, `zip` and `gz`.
75 |
76 | ```javascript
77 | var vcf = require('bionode-vcf');
78 | var fileStream = s3.getObject({
79 | Bucket: [BUCKETNAME],
80 | Key: [FILENAME]
81 | }).createReadStream(); // or stream data from any other source
82 |
83 | vcf.read(filestream, 'zip'); // default value is `vcf`
84 | vcf.on('data', function(feature){
85 | console.log(feature);
86 | })
87 |
88 | vcf.on('end', function(){
89 | console.log('end of file')
90 | })
91 |
92 | vcf.on('error', function(err){
93 | console.error('it\'s not a vcf', err)
94 | })
95 |
96 | ```
97 |
98 | ## Documentation
99 |
100 | VCF format specifications and more information about the fileds can be found at
101 | [1000 genomes webpage](http://www.1000genomes.org/wiki/analysis/variant%20call%20format/vcf-variant-call-format-version-41) and
102 | [samtools github page](https://github.com/samtools/hts-specs)
103 |
104 |
105 | ## Contributing
106 |
107 | We welcome all kinds of contributions at all levels of experience, please read the [CONTRIBUTING.md](CONTRIBUTING.md) to get started!
108 |
--------------------------------------------------------------------------------
/test/sample.vcf:
--------------------------------------------------------------------------------
1 | ##fileformat=VCFv4.1
2 | ##samtoolsVersion=0.1.19-44428cd
3 | ##reference=file://../index/Chalara_fraxinea_TGAC_s1v1_scaffolds.fa
4 | ##contig=
5 | ##contig=
6 | ##contig=
7 | ##contig=
8 | ##contig=
9 | ##INFO=
10 | ##INFO=
11 | ##INFO=
12 | ##INFO=
13 | ##INFO=
14 | ##INFO=
15 | ##INFO=
16 | ##INFO=
17 | ##INFO=
18 | ##INFO=
19 | ##INFO=
20 | ##INFO=
21 | ##INFO=
22 | ##INFO=
23 | ##INFO=
24 | ##INFO=
25 | ##INFO=
26 | ##INFO=
27 | ##INFO=
28 | ##INFO=
29 | ##INFO=
30 | ##INFO=
31 | ##INFO=
32 | ##INFO=
33 | ##FORMAT=
34 | ##FORMAT=
35 | ##FORMAT=
36 | ##FORMAT=
37 | ##FORMAT=
38 | ##FORMAT=
39 | ##FORMAT=
40 | ##INFO=
41 | #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT foxley_wood1_bwa-mem-sorted.bam
42 | Cf746836_TGAC_s1v1_scaffold_4 5607 . G C 18.1 . DP=6;VDB=6.560000e-02;RPB=1.427508e+00;AF1=0.5;AC1=1;DP4=3,1,1,1;MQ=60;FQ=21;PV4=1,0.0023,1,1 GT:PL:GQ 0/1:48,0,123:51
43 | Cf746836_TGAC_s1v1_scaffold_12 672 . CAAA CAA 128 . INDEL;IS=16,0.727273;DP=22;VDB=1.896486e-01;AF1=1;AC1=2;DP4=0,0,0,20;MQ=60;FQ=-94.5 GT:PL:GQ 1/1:169,60,0:99
44 | Cf746836_TGAC_s1v1_scaffold_12 2911 . ATA ATACTCGGTA 214 . INDEL;IS=16,0.727273;DP=22;VDB=3.802706e-02;AF1=1;AC1=2;DP4=0,0,9,8;MQ=60;FQ=-85.5 GT:PL:GQ 1/1:255,51,0:99
45 |
--------------------------------------------------------------------------------
/test/test_vcf.js:
--------------------------------------------------------------------------------
1 | /* global describe it */
2 | /*
3 | * bionode-vcf
4 | * https://github.com/shyamrallapalli/bionode-vcf
5 | *
6 | * Copyright (c) 2015 Shyam Rallapalli
7 | * Licensed under the MIT license.
8 | */
9 |
10 | // chai is an assertion library
11 | // var chai = require('chai');
12 |
13 | // @see http://chaijs.com/api/assert/
14 | // var assert = chai.assert;
15 |
16 | // register alternative styles
17 | // @see http://chaijs.com/api/bdd/
18 | // chai.expect();
19 | // chai.should();
20 |
21 | // requires your main app (specified in index.js)
22 | var VCF = require('../lib/index')
23 | var fs = require('fs')
24 | var path = require('path')
25 | var assert = require('assert')
26 |
27 | var allFeatures = []
28 |
29 | describe('VCF', function () {
30 | describe('.read .vcf file', function () {
31 | var filePath = path.join(__dirname, 'sample.vcf')
32 |
33 | it('should read without error', function (finish) {
34 | function onFeature (vcf) {
35 | allFeatures.push(vcf)
36 | }
37 |
38 | VCF.read(filePath).on('data', onFeature).once('end', finish)
39 | })
40 | it('should look like a valid output', function () {
41 | assert.notStrictEqual(allFeatures, validOutput)
42 | })
43 | })
44 |
45 | describe('.read .gz file', function () {
46 | var filePath = path.join(__dirname, 'sample.gz')
47 |
48 | it('should read without error', function (done) {
49 | function onFeature (vcf) {
50 | allFeatures.push(vcf)
51 | }
52 |
53 | VCF.read(filePath).on('data', onFeature).once('end', done)
54 | })
55 | it('should look like a valid output', function () {
56 | assert.notStrictEqual(allFeatures, validOutput)
57 | })
58 | })
59 |
60 | describe('.read .zip file', function () {
61 | var filePath = path.join(__dirname, 'sample.zip')
62 | it('should read without error', function (done) {
63 | function onFeature (vcf) {
64 | allFeatures.push(vcf)
65 | }
66 |
67 | VCF.read(filePath).on('data', onFeature).once('end', done)
68 | })
69 | it('should look like a valid output', function () {
70 | assert.notStrictEqual(allFeatures, validOutput)
71 | })
72 | })
73 |
74 | describe('.readStream', function () {
75 | var filePath = path.join(__dirname, 'sample.vcf')
76 | var fileStream = fs.createReadStream(filePath)
77 |
78 | it('should read without error', function (finish) {
79 | function onFeature (vcf) {
80 | allFeatures.push(vcf)
81 | }
82 |
83 | VCF.readStream(fileStream).on('data', onFeature).once('end', finish)
84 | })
85 | it('should look like a valid output', function () {
86 | assert.notStrictEqual(allFeatures, validOutput)
87 | })
88 | })
89 | })
90 |
91 | var validOutput = [
92 | { chr: 'Cf746836_TGAC_s1v1_scaffold_4',
93 | pos: '5607',
94 | id: '.',
95 | ref: 'G',
96 | alt: 'C',
97 | qual: '18.1',
98 | filter: '.',
99 | varinfo:
100 | { VAR: 'SNP',
101 | VARINFO: 'substitution',
102 | DP: '6',
103 | VDB: '6.560000e-02',
104 | RPB: '1.427508e+00',
105 | AF1: ' 0.5',
106 | AC1: '1',
107 | DP4: '3,1,1,1',
108 | MQ: '60',
109 | FQ: '21',
110 | PV4: '1,0.0023,1,1' },
111 | sampleinfo:
112 | [ { NAME: 'foxley_wood1_bwa-mem-sorted.bam',
113 | GT: '0/1',
114 | PL: '48,0,123',
115 | GQ: '51' } ],
116 | attributes:
117 | { vcfver: 'VCFv4.1',
118 | samtools: '0.1.19-44428cd',
119 | reference: 'file://../index/Chalara_fraxinea_TGAC_s1v1_scaffolds.fa' }
120 | },
121 | { chr: 'Cf746836_TGAC_s1v1_scaffold_12',
122 | pos: '672',
123 | id: '.',
124 | ref: 'CAAA',
125 | alt: 'CAA',
126 | qual: '128',
127 | filter: '.',
128 | varinfo:
129 | { VAR: 'INDEL',
130 | VARINFO: 'deletion',
131 | IS: '16,0.727273',
132 | DP: '22',
133 | VDB: '1.896486e-01',
134 | AF1: '1',
135 | AC1: '2',
136 | DP4: '0,0,0,20',
137 | MQ: '60',
138 | FQ: '-94.5' },
139 | sampleinfo:
140 | [ { NAME: 'foxley_wood1_bwa-mem-sorted.bam',
141 | GT: '1/1',
142 | PL: '169,60,0',
143 | GQ: '99' } ],
144 | attributes:
145 | { vcfver: 'VCFv4.1',
146 | samtools: '0.1.19-44428cd',
147 | reference: 'file://../index/Chalara_fraxinea_TGAC_s1v1_scaffolds.fa' }
148 | },
149 | { chr: 'Cf746836_TGAC_s1v1_scaffold_12',
150 | pos: '2911',
151 | id: '.',
152 | ref: 'ATA',
153 | alt: 'ATACTCGGTA',
154 | qual: '214',
155 | filter: '.',
156 | varinfo:
157 | { VAR: 'INDEL',
158 | VARINFO: 'insertion',
159 | IS: '16,0.727273',
160 | DP: '22',
161 | VDB: '3.802706e-02',
162 | AF1: '1',
163 | AC1: '2',
164 | DP4: '0,0,9,8',
165 | MQ: '60',
166 | FQ: '-85.5' },
167 | sampleinfo:
168 | [ { NAME: 'foxley_wood1_bwa-mem-sorted.bam',
169 | GT: '1/1',
170 | PL: '255,51,0',
171 | GQ: '99' } ],
172 | attributes:
173 | { vcfver: 'VCFv4.1',
174 | samtools: '0.1.19-44428cd',
175 | reference: 'file://../index/Chalara_fraxinea_TGAC_s1v1_scaffolds.fa' }
176 | }
177 | ]
178 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * bionode-vcf
3 | * https://github.com/shyamrallapalli/bionode-vcf
4 | *
5 | * Copyright (c) 2015 Shyam Rallapalli and Martin Page
6 | * Licensed under the MIT license.
7 | */
8 |
9 | var fs = require('fs')
10 | var readline = require('readline')
11 | var Stream = require('stream')
12 | var events = require('events')
13 | var zlib = require('zlib')
14 | var unzip = require('unzip-stream')
15 |
16 | var vcf = new events.EventEmitter()
17 |
18 | function parseStream (instream, extension) {
19 | var rl
20 | var numSamples = 0
21 | var sampleIndex = {}
22 | var vcfAttrib = {}
23 | var outstream = new Stream()
24 |
25 | switch (extension) {
26 | case 'gz':
27 | rl = readline.createInterface({
28 | input: instream.pipe(zlib.createGunzip())
29 | })
30 | break
31 | case 'zip':
32 | rl = readline.createInterface({
33 | input: instream.pipe(unzip.Parse())
34 | })
35 | break
36 | case 'vcf':
37 | rl = readline.createInterface(instream, outstream)
38 | break
39 | default:
40 | var err = new Error('File format not supported')
41 | vcf.emit('error', err)
42 | }
43 |
44 | rl.on('line', function (line) {
45 | // check if line starts with hash and use them
46 | if (line.indexOf('#') === 0) {
47 | // ##fileformat=VCFv4.1
48 | if (!vcfAttrib.vcf_v) {
49 | vcfAttrib.vcf_v = line.match(/^##fileformat=/) ? line.split('=')[1] : null
50 | }
51 |
52 | // ##samtoolsVersion=0.1.19-44428cd
53 | if (!vcfAttrib.samtools) {
54 | vcfAttrib.samtools = line.match(/^##samtoolsVersion=/) ? line.split('=')[1] : null
55 | }
56 |
57 | // ##reference=file://../index/Chalara_fraxinea_TGAC_s1v1_scaffolds.fa
58 | if (!vcfAttrib.refseq) {
59 | vcfAttrib.refseq = line.match((/^##reference=file:/)) ? line.split('=')[1] : null
60 | }
61 |
62 | // #CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tsample1\tsample2\tsample3
63 | // set number of samples in vcf file
64 | if (line.match(/^#CHROM/)) {
65 | var sampleinfo = line.split('\t')
66 | numSamples = sampleinfo.length - 9
67 |
68 | for (var i = 0; i < numSamples; i++) {
69 | sampleIndex[i] = sampleinfo[9 + i]
70 | }
71 | }
72 | } else { // go through remaining lines
73 | // split line by tab character
74 | var info = line.split('\t')
75 |
76 | if (info.length < 9) {
77 | var err = new Error('number of columns in the file are less than expected in vcf')
78 | vcf.emit('error', err)
79 | }
80 |
81 | // format information ids
82 | var formatIds = info[8].split(':')
83 |
84 | // parse the sample information
85 | var sampleObject = []
86 | for (var j = 0; j < numSamples; j++) {
87 | var sampleData = {}
88 | sampleData['NAME'] = sampleIndex[j]
89 | var formatParts = info[9].split(':')
90 | for (var k = 0; k < formatParts.length; k++) {
91 | sampleData[formatIds[k]] = formatParts[k]
92 | }
93 | sampleObject.push(sampleData)
94 | }
95 |
96 | // parse the variant call information
97 | var varInfo = info[7].split(';')
98 | var infoObject = {}
99 |
100 | // check if the variant is INDEL or SNP
101 | // and assign the specific type of variation identified
102 | var type
103 | var typeInfo
104 | if (varInfo[0].match(/^INDEL$/)) {
105 | type = 'INDEL'
106 | varInfo.shift()
107 | if (info[3].length > info[4].length) {
108 | typeInfo = 'deletion'
109 | } else if (info[3].length < info[4].length) {
110 | typeInfo = 'insertion'
111 | } else if (info[3].length === info[4].length) {
112 | typeInfo = 'substitution - multi'
113 | }
114 | } else {
115 | type = 'SNP'
116 | if (info[3].length === 1) {
117 | typeInfo = 'substitution'
118 | } else if (info[3].length > 1) {
119 | typeInfo = 'substitution - multi'
120 | }
121 | }
122 | infoObject['VAR'] = type
123 | infoObject['VARINFO'] = typeInfo
124 |
125 | // variant info added to object
126 | for (var l = 0; l < varInfo.length; l++) {
127 | var pair = varInfo[l].split('=')
128 | infoObject[pair[0]] = pair[1]
129 | }
130 |
131 | // parse the variant information
132 | var varData = {
133 | chr: info[0],
134 | pos: info[1],
135 | id: info[2],
136 | ref: info[3],
137 | alt: info[4],
138 | qual: info[5],
139 | filter: info[6],
140 | varinfo: infoObject,
141 | sampleinfo: sampleObject,
142 | attributes: vcfAttrib
143 | }
144 |
145 | // console.log('Variant data',varData);
146 | vcf.emit('data', varData)
147 | }
148 | })
149 |
150 | rl.on('close', function () {
151 | vcf.emit('end')
152 | })
153 | }
154 |
155 | // To read file in stream and parse it
156 | vcf.read = function (path) {
157 | var instream = fs.createReadStream(path)
158 | var extension = path.split('.').pop()
159 |
160 | parseStream(instream, extension)
161 |
162 | return this
163 | }
164 |
165 | // To parse stream data sent by user
166 | vcf.readStream = function (instream, extension = 'vcf') {
167 | parseStream(instream, extension)
168 |
169 | return this
170 | }
171 |
172 | module.exports = vcf
173 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Bionode
2 |
3 | Thank you for your interest in contributing to Bionode :tada:!
4 |
5 | Bionode is an Open Source community that aims at building highly reusable code and tools for bioinformatics by leveraging the Node.JS ecosystem. We use Node.JS Streams to process big genomic data.
6 |
7 | We welcome all kinds of contributions at all levels of experience, either code, knowledge, questions or suggestions. Many of our goals and GitHub issues do not require biology knowledge (e.g. very technical, coding) and some don't even require JavaScript knowledge (e.g. events, community, documentation).
8 |
9 | This document has a set of guidelines for contributing to Bionode on GitHub. These are guidelines, not rules. This guide is meant to make it easier for you to get involved.
10 |
11 | * [Participation guidelines](#participation-guidelines)
12 | * [What we're working on](#what-were-working-on)
13 | * [How to submit changes](#how-to-submit-changes)
14 | * [How to report bugs](#how-to-report-bugs)
15 | * [Communication channels](#communication-channels)
16 |
17 | ## Participation guidelines
18 |
19 | This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [mail@bionode.io](mailto:mail@bionode.io).
20 |
21 | ## What we're working on
22 |
23 | Take a look at the GitHub issues in our organisation wide project board at [project.bionode.io](http://project.bionode.io). Here's what each column means:
24 | * **Backlog** All the issues we have open (sorted by most recent). You'll find a lot in here and maybe something you could help us with.
25 | * **Next** What we want to work on next! Picking something to solve here would be greatly appreciated!!
26 | * **In Progress** Things we are currently working on, come help us! The person assigned to each issue is the one in charge and who you can ask any question.
27 | * **Done** Solved issues (sorted by closed date). Here you can check what we've been up to in the past.
28 |
29 | If you want to have a view of where all of this is going in the long run, check out our [Roadmap issue](https://github.com/bionode/bionode/issues/35), where we discuss our vision.
30 |
31 | ## How to submit changes
32 |
33 | Each bionode tool and library has its own repository (like a folder).
34 | Once you've identified one of the issues above that you feel you can contribute to, you're ready to make a change to the repository of that issue! However, it's always a good idea to [talk to us first](#communication-channels). Specially if you intend to take on something big, just to make sure we're on the same track. :wink:
35 |
36 | 1. **[Fork](https://help.github.com/articles/fork-a-repo/) the repository** that the issue belongs to. This makes your own version of the tool/library that you can edit and use. If you were invited to the [Bionode organisation](https://github.com/orgs/bionode/people) on GitHub, you can just `git clone` the repo and use a `git branch` instead of `forking`.
37 | 2. **[Make your changes](https://guides.github.com/activities/forking/#making-changes)**! You can do this in the GitHub interface on your own local machine. Once you're happy with your changes...
38 | 3. **Submit a [pull request](https://help.github.com/articles/proposing-changes-to-a-project-with-pull-requests/)**. This opens a discussion around your project and lets the project lead know you are proposing changes.
39 |
40 | First time contributing to open source? Check out this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
41 |
42 | ## How to report bugs
43 |
44 | Any general Bionode bug or question should be reported on the issue tracker of [bionode/bionode](https://github.com/bionode/bionode/issues). Anything that is specific to one of the tools, e.g. `bionode-ncbi`, should be reported under [that tool issue tracker](https://github.com/bionode/bionode-ncbi).
45 |
46 | ## Communication channels
47 |
48 | Don't be shy! Come talk to us :smiley:
49 |
50 | * **Email** [mail@bionode.io](mailto:mail@bionode.io)
51 | * **Chat room** [http://gitter.im/bionode/bionode](http://gitter.im/bionode/bionode)
52 | * **IRC** #bionode on Freenode
53 | * **Twitter** [@bionode](http://twitter.com/@bionode)
54 |
55 | ## Node.JS specific commands
56 | If you're new to Node.JS we highly recommend checking the [NodeSchool workshop](https://nodeschool.io/#workshopper-list) that you can install and run in your command line. Example:
57 |
58 | ```bash
59 | npm install -g learnyounode
60 | learnyounode
61 | ```
62 |
63 | To install a local version of a bionode tool that you are modifying (e.g. bionode-ncbi):
64 |
65 | ```bash
66 | git clone git@github.com:bionode/bionode-ncbi.git
67 | cd bionode-ncbi
68 | npm install # Install all dependencies defined in the package.json file
69 | npm link # Setup bionode-ncbi in your PATH to point to this local version
70 | ```
71 |
72 | You can now modify the code in the `bionode-ncbi` folder and test the effect of those changes when you run the `bionode-ncbi` command in your terminal.
73 |
74 | To run a bionode tool suite of tests and check their code coverage, you can do:
75 |
76 | ```bash
77 | npm test
78 | npm run coverage
79 | ```
80 |
81 | To rebuild and minify a bionode module for the browser (if supported) do:
82 |
83 | ```bash
84 | npm run build-browser
85 | ```
86 |
87 | To rebuild the documentation using the comments in the code do:
88 |
89 | ```sh
90 | npm run build-docs
91 | ```
92 |
93 | # Style guide
94 | We currently recommend using the [JavaScript Standard Style](https://github.com/feross/standard) to check your code. You can run it in the folder you're working (see below) and install it as an extension for your text editor (e.g. [Atom](https://atom.io/packages/linter-js-standard) or [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=chenxsan.vscode-standardjs)).
95 |
96 | ```bash
97 | npm install -g standard
98 | standard
99 | ```
100 |
101 | # Testing
102 | We use [tape](https://github.com/substack/tape) with [tape-nock](https://github.com/Flet/tape-nock) for testing. Code coverage is checked with [istanbul](https://github.com/gotwarlost/istanbul).
103 |
--------------------------------------------------------------------------------