Created
July 30, 2015 13:04
-
-
Save bmpvieira/5454133eb672aab826dc to your computer and use it in GitHub Desktop.
Get stuff from NCBI with custom path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var ncbi = require('bionode-ncbi') | |
var request = require('request') | |
var through = require('through2') | |
var _ = require('lodash') | |
var property = 'README.txt' | |
var requestStream = through.obj(function(obj, enc, next) { | |
var fileName = _.get(obj, property).split('/')[5] | |
var file = fs.createWriteStream(fileName) | |
var get = request(_.get(obj, property)) | |
get.pipe(file) | |
get.on('end', next) | |
}) | |
var ncbiStream = ncbi.urls('assembly') | |
var pipeline = ncbiStream.pipe(requestStream) | |
pipeline.on('data', console.log) | |
ncbiStream.write('Solenopsis invicta') | |
ncbiStream.write('Acromyrmex') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment