Skip to content

Instantly share code, notes, and snippets.

@audy
Created January 8, 2020 21:38
Show Gist options
  • Save audy/519a8054ce661aabfc6c2762b4f3cc57 to your computer and use it in GitHub Desktop.
Save audy/519a8054ce661aabfc6c2762b4f3cc57 to your computer and use it in GitHub Desktop.
quickly fetch all of the annotations on refseq
#!/usr/bin/env ruby
require "open-uri"
require "parallel"
open("https://ftp.ncbi.nlm.nih.gov/genomes/refseq/bacteria/assembly_summary.txt") do |handle|
handle.gets # skip header
handle.gets
Parallel.each(handle, :in_processes => 6, :progress => 'downloading') do |line|
row = line.split("\t")
uri_base = row[-3]
filename = "#{uri_base.split('/')[-1]}_genomic.gbff.gz"
full_uri = "#{uri_base}/#{filename}"
cmd = "wget --quiet -O #{filename} #{full_uri}"
`#{cmd}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment