comparison sra_fetch.py @ 7:d7708f338c82 draft

bug fixes
author Matthew Shirley <mdshw5@gmail.com>
date Wed, 14 Nov 2012 16:55:51 -0500
parents f74bbb22bf62
children
comparison
equal deleted inserted replaced
6:20a054a7e2fd 7:d7708f338c82
10 10
11 # NCBI SRA FTP site 11 # NCBI SRA FTP site
12 ftp = FTP('ftp-trace.ncbi.nih.gov') 12 ftp = FTP('ftp-trace.ncbi.nih.gov')
13 13
14 # Open file and transfer requested SRA as a file 14 # Open file and transfer requested SRA as a file
15 # Try to change the working directory until it works
15 sra = open(outfile, 'wb') 16 sra = open(outfile, 'wb')
16 ftp.login('ftp') 17 ftp.login('ftp')
17 ftp.cwd('/sra/sra-instant/reads/ByRun/sra/' + 18 connected = False
18 prefix + '/' + 19 while not connected:
19 prefix + middle + '/' + 20 try:
20 prefix + middle + suffix + '/') 21 ftp.cwd('/sra/sra-instant/reads/ByRun/sra/' +
21 ftp.pwd() 22 prefix + '/' +
23 prefix + middle + '/' +
24 prefix + middle + suffix + '/')
25 connected = True
26 except:
27 pass
28
22 ftp.retrbinary('RETR ' + prefix + middle + suffix + '.sra', sra.write) 29 ftp.retrbinary('RETR ' + prefix + middle + suffix + '.sra', sra.write)
23 ftp.quit() 30 ftp.quit()