Mercurial > repos > matt-shirley > sra_fetch
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:aa7ab53c53bf | 2:be22544bfafa |
---|---|
1 from ftplib import FTP | 1 from ftplib import FTP |
2 import os, sys, os.path | 2 import sys |
3 | 3 |
4 # Get accession number from argument | 4 # Get accession number from argument |
5 accession = sys.argv[1] | 5 accession = sys.argv[1] |
6 prefix = accession[0:2].uppercase() | 6 prefix = accession[0:2].uppercase() |
7 middle = accession[3:5] | 7 middle = accession[3:5] |
8 suffix = accession[6:8] | 8 suffix = accession[6:8] |
9 | 9 |
10 # NCBI SRA FTP site | |
10 ftp = FTP('ftp.ncbi.nlm.nih.gov') | 11 ftp = FTP('ftp.ncbi.nlm.nih.gov') |
11 | 12 |
12 def handleDownload(block): | 13 # Open stdout and transfer requested SRA as a file |
13 file.write(block) | |
14 | |
15 ftp.login() | 14 ftp.login() |
16 ftp.cwd('/sra/sra-instant/reads/BySample/sra/ | 15 ftp.retrbinary('/sra/sra-instant/reads/ByRun/sra/' + |
16 prefix + '/' + | |
17 prefix + middle + '/' + | |
18 prefix + middle + suffix + '/' + | |
19 prefix + middle + suffix + '.sra', sys.stdout) | |
20 ftp.quit() |