annotate sra_fetch.py @ 1:aa7ab53c53bf draft

Started working on the python FTP script.
author matt-shirley
date Tue, 13 Nov 2012 22:32:13 -0500
parents
children be22544bfafa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
1 from ftplib import FTP
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
2 import os, sys, os.path
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
3
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
4 # Get accession number from argument
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
5 accession = sys.argv[1]
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
6 prefix = accession[0:2].uppercase()
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
7 middle = accession[3:5]
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
8 suffix = accession[6:8]
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
9
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
10 ftp = FTP('ftp.ncbi.nlm.nih.gov')
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
11
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
12 def handleDownload(block):
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
13 file.write(block)
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
14
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
15 ftp.login()
aa7ab53c53bf Started working on the python FTP script.
matt-shirley
parents:
diff changeset
16 ftp.cwd('/sra/sra-instant/reads/BySample/sra/