view sra_fetch.py @ 4:8ce70ee5f335 draft

Updated wrapper script. First version that should work properly.
author Matthew Shirley <mdshw5@gmail.com>
date Wed, 14 Nov 2012 13:13:32 -0500
parents 01dec8611542
children f74bbb22bf62
line wrap: on
line source

from ftplib import FTP
import sys

# Get accession number from argument
accession = sys.argv[1]
prefix = accession[0:3]
middle = accession[3:6]
suffix = accession[6:9]

# NCBI SRA FTP site
ftp = FTP('ftp-trace.ncbi.nih.gov')

# Open stdout and transfer requested SRA as a file
ftp.login()
ftp.cwd('/sra/sra-instant/reads/ByRun/sra/' + 
        prefix + '/' +
        prefix + middle + '/' +
        prefix + middle + suffix + '/')
ftp.pwd()
ftp.retrbinary('RETR ' + prefix + middle + suffix + '.sra', sys.stdout)
ftp.quit()