Skip to content

Instantly share code, notes, and snippets.

@bmpvieira
Created July 30, 2015 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmpvieira/5454133eb672aab826dc to your computer and use it in GitHub Desktop.
Save bmpvieira/5454133eb672aab826dc to your computer and use it in GitHub Desktop.
Get stuff from NCBI with custom path
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