Last active
September 5, 2017 21:32
-
-
Save johnsolk/2f7ed59867bb8a00d405271aa0b26f6e 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
""" | |
From Luiz Irber. | |
Takes an SRA accession and determines the location of the .sra data file for automated or downloading. | |
Follows this format: ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/{SRR|ERR|DRR}/<first 6 characters of accession>/<accession>/<accession>.sra | |
Format according to NCBI utility handbook: https://www.ncbi.nlm.nih.gov/books/NBK158899/ | |
""" | |
def sra_url(accession): | |
"""Returns predicted URL given SRA accession as input.""" | |
accession = accession.upper() | |
return "ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/{}/{}/{}/{}.sra".format( | |
accession[0:3], accession[0:6], accession, accession) | |
def test_sra_url(): | |
"""Test for the sra_url function.""" | |
assert sra_url('DRR053698') == 'ftp://ftp-trace.ncbi.nih.gov/sra/sra-instant/reads/ByRun/sra/DRR/DRR053/DRR053698/DRR053698.sra' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment