Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View download.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
require 'net/ftp'
require 'timeout'
 
ftp = Net::FTP.new('ftp.sra.ebi.ac.uk')
ftp.login
puts "connected!"
 
errors = []
samples = ["SRR016000"]
 
samples.each do |sample|
files = ftp.chdir("vol1/fastq/SRR016/#{sample}/")
puts "changed directory"
#files = ftp.list('SRR*')
begin
bytes_downloaded = 0
file_name = "#{sample}_1.fastq.gz"
Timeout.timeout(20000) do
file_size = ftp.size(file_name)
 
ftp.getbinaryfile(file_name) do |chunk|
bytes_downloaded += chunk.size
puts "#{bytes_downloaded} of #{file_size} bytes downloaded (#{bytes_downloaded * 100 / file_size}%)."
end
end
rescue Timeout::Error
errors << "File download timed out for: #{sample}"
puts errors.last
end
end
ftp.close
puts "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.