Sha256: d7ca8ab9b54235673629b2e54f999ce9acfc6a01ae26f8bb29ac0e73ba08afb2

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

require 'net/ftp'

def download(url)
  file = File.basename(url)
  sh "wget -Nc #{url} && wget -Nc #{url}.md5 &&"\
     " md5sum -c #{file}.md5 && tar xvf #{file}"
end

def databases
  host, dir = 'ftp.ncbi.nlm.nih.gov', 'blast/db'
  usr, pswd = 'anonymous', ENV['email']

  Net::FTP.open(host, usr, pswd) do |con|
    con.passive = true
    con.nlst(dir).
      map { |file| File.join(host, file) }.
      select { |file| file.match(/\.tar\.gz$/) }.
      group_by { |file| File.basename(file).split('.')[0] }
  end
end

databases.each do |name, files|
  multitask(name => files.map { |file| task(file) { download(file) } })
end

task :default do
  puts databases.keys.join(', ')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ncbi-blast-dbs-0.0.1 lib/ncbi-blast-dbs.rake