changeset 2:be22544bfafa draft

First version of the python script that may work. Whole tool is still not functional.
author Matthew Shirley <mdshw5@gmail.com>
date Wed, 14 Nov 2012 12:07:18 -0500
parents aa7ab53c53bf
children 01dec8611542
files sra_fetch.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sra_fetch.py	Tue Nov 13 22:32:13 2012 -0500
+++ b/sra_fetch.py	Wed Nov 14 12:07:18 2012 -0500
@@ -1,5 +1,5 @@
 from ftplib import FTP
-import os, sys, os.path
+import sys
 
 # Get accession number from argument
 accession = sys.argv[1]
@@ -7,10 +7,14 @@
 middle = accession[3:5]
 suffix = accession[6:8]
 
+# NCBI SRA FTP site
 ftp = FTP('ftp.ncbi.nlm.nih.gov')
 
-def handleDownload(block):
-    file.write(block)
-    
+# Open stdout and transfer requested SRA as a file
 ftp.login()
-ftp.cwd('/sra/sra-instant/reads/BySample/sra/
+ftp.retrbinary('/sra/sra-instant/reads/ByRun/sra/' + 
+        prefix + '/' +
+        prefix + middle + '/' +
+        prefix + middle + suffix + '/' +
+        prefix + middle + suffix + '.sra', sys.stdout)
+ftp.quit()