Mercurial > repos > matt-shirley > sra_fetch
diff sra_fetch.py @ 9:cf0980cfd040 draft default tip
Deleted selected files
author | matt-shirley |
---|---|
date | Tue, 27 Nov 2012 13:38:35 -0500 |
parents | 61d634d123c0 |
children |
line wrap: on
line diff
--- a/sra_fetch.py Sun Nov 18 17:12:24 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -from ftplib import FTP -import sys - -# Get accession number from argument -accession = sys.argv[1] -outfile = sys.argv[2] -prefix = accession[0:3] -middle = accession[3:6] -suffix = accession[6:9] - -# NCBI SRA FTP site -ftp = FTP('ftp-trace.ncbi.nih.gov') - -# Open file and transfer requested SRA as a file -# Try to change the working directory until it works -sra = open(outfile, 'wb') -ftp.login('ftp') -connected = False -while not connected: - try: - ftp.cwd('/sra/sra-instant/reads/ByRun/sra/' + - prefix + '/' + - prefix + middle + '/' + - prefix + middle + suffix + '/') - connected = True - except: - pass - -ftp.retrbinary('RETR ' + prefix + middle + suffix + '.sra', sra.write) -ftp.quit()