Mercurial > repos > matt-shirley > sra_fetch
annotate 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 |
rev | line source |
---|---|
1 | 1 from ftplib import FTP |
2
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
2 import sys |
1 | 3 |
4 # Get accession number from argument | |
5 accession = sys.argv[1] | |
6 prefix = accession[0:2].uppercase() | |
7 middle = accession[3:5] | |
8 suffix = accession[6:8] | |
9 | |
2
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
10 # NCBI SRA FTP site |
1 | 11 ftp = FTP('ftp.ncbi.nlm.nih.gov') |
12 | |
2
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
13 # Open stdout and transfer requested SRA as a file |
1 | 14 ftp.login() |
2
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
15 ftp.retrbinary('/sra/sra-instant/reads/ByRun/sra/' + |
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
16 prefix + '/' + |
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
17 prefix + middle + '/' + |
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
18 prefix + middle + suffix + '/' + |
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
19 prefix + middle + suffix + '.sra', sys.stdout) |
be22544bfafa
First version of the python script that may work. Whole tool is still not functional.
Matthew Shirley <mdshw5@gmail.com>
parents:
1
diff
changeset
|
20 ftp.quit() |