view sra_fetch.py @ 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
line wrap: on
line source

from ftplib import FTP
import sys

# Get accession number from argument
accession = sys.argv[1]
prefix = accession[0:2].uppercase()
middle = accession[3:5]
suffix = accession[6:8]

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

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