changeset 7:d7708f338c82 draft

bug fixes
author Matthew Shirley <mdshw5@gmail.com>
date Wed, 14 Nov 2012 16:55:51 -0500
parents 20a054a7e2fd
children 61d634d123c0
files sra_fetch.py sra_fetch.xml
diffstat 2 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- 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 @@
 <tool id="sra_fetch" name="Fetch SRA" version="1.0.0">
   <description> by accession from NCBI SRA.</description>
-  <command interpreter="python">sra_fetch.py $accession $output</command>
+  <command interpreter="python">sra_fetch.py '$accession' '$output'</command>
   <inputs>
     <param name="accession" size="13" type="text" value="SRR000001" label="SRA run accession"/>
   </inputs>
   <outputs>
-    <data format="sra" name="output"/>
+    <data format="sra" name="output" label="Fetch ${accession.value}"/>
   </outputs>
   <requirements>
     <requirement type="python">sra_fetch.py</requirement>