Skip to content

Instantly share code, notes, and snippets.

@johnsolk
Last active September 5, 2017 21:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnsolk/2f7ed59867bb8a00d405271aa0b26f6e to your computer and use it in GitHub Desktop.
Save johnsolk/2f7ed59867bb8a00d405271aa0b26f6e to your computer and use it in GitHub Desktop.
"""
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