-
-
Save crazyhottommy/7fb431a179a044dbd78077abef91ba58 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
#API created by @apfejes (Anthony Fejes) on top of my half-cooked script | |
#python ebi_url_from_srr.py --file srr_list.txt | xargs -I {} wget {} | |
import argparse | |
def prepareURL(srr_name, prefix="ftp://ftp.sra.ebi.ac.uk/vol1/fastq/"): | |
dir_1=srr_name[:6] | |
dir_2="" | |
url="" | |
num_digits=sum(s.isdigit() for s in srr_name) | |
if(num_digits == 6): | |
url=prefix+dir_1+"/"+srr_name+"/" | |
elif(num_digits == 7): | |
dir_2="00"+srr_name[-1] | |
url=prefix+dir_1+"/"+dir_2+"/"+srr_name+"/" | |
elif(num_digits == 8): | |
dir_2="0"+srr_name[-2:] | |
url=prefix+dir_1+"/"+dir_2+"/"+srr_name+"/" | |
elif(num_digits == 9): | |
dir_2=srr_name[-3:] | |
url=prefix+dir_1+"/"+dir_2+"/"+srr_name+"/" | |
return url | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--SRR', help='SRR name to be parsed') | |
parser.add_argument('--file', help='file containing SRR name to be parsed') | |
args = parser.parse_args() | |
if args.file: | |
with open(args.file) as srr_file: | |
for line in srr_file: | |
url = prepareURL(line.strip()) | |
print("{}*.fastq.gz".format(url)) | |
else: | |
url = prepareURL(args.SRR) | |
print("{}*.fastq.gz".format(url)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
check this gist as well https://gist.github.com/crazyhottommy/b9f6ee0122538b69876fad090cb7211b to understand how the fastqs are organized in the portal