# HG changeset patch # User Matthew Shirley # Date 1352930151 18000 # Node ID d7708f338c826776ffd999465532da609a24a3e3 # Parent 20a054a7e2fdfc2bd1b79c2accd94b99813b07d0 bug fixes diff -r 20a054a7e2fd -r d7708f338c82 sra_fetch.py --- a/sra_fetch.py Wed Nov 14 13:36:21 2012 -0500 +++ b/sra_fetch.py Wed Nov 14 16:55:51 2012 -0500 @@ -12,12 +12,19 @@ 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') -ftp.cwd('/sra/sra-instant/reads/ByRun/sra/' + - prefix + '/' + - prefix + middle + '/' + - prefix + middle + suffix + '/') -ftp.pwd() +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() diff -r 20a054a7e2fd -r d7708f338c82 sra_fetch.xml --- a/sra_fetch.xml Wed Nov 14 13:36:21 2012 -0500 +++ b/sra_fetch.xml Wed Nov 14 16:55:51 2012 -0500 @@ -1,11 +1,11 @@ by accession from NCBI SRA. - sra_fetch.py $accession $output + sra_fetch.py '$accession' '$output' - + sra_fetch.py