Created
January 6, 2016 16:17
-
-
Save flashton2003/336e67bbc513b0cf3f07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ftplib | |
# ftp://ftp.sra.ebi.ac.uk/vol1/fastq/ERR038/ERR038787/ERR038787_1.fastq.gz | |
todo_list = ['ERR024633'] # ERR accessions | |
target_dir = '/where/you/want/the/data' | |
def download_from_ena(todo_list, target_dir): | |
ftp = ftplib.FTP('ftp.sra.ebi.ac.uk') | |
ftp.login() | |
ftp.cwd('vol1') | |
ftp.cwd('fastq') | |
for each in todo_list: | |
initial = each[0:6] | |
ftp.cwd(initial) | |
ftp.cwd(each) | |
with open('%s/%s_1.fastq.gz' % (target_dir, each), 'wb') as f1: | |
with open('%s/%s_2.fastq.gz' % (target_dir, each), 'wb') as f2: | |
ftp.retrbinary('RETR %s_1.fastq.gz' % each, f1.write) | |
ftp.retrbinary('RETR %s_2.fastq.gz' % each, f2.write) | |
download_from_ena(todo_list, target_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment