Skip to content

Instantly share code, notes, and snippets.

@slowkow
Last active July 25, 2017 13:43
Show Gist options
  • Save slowkow/69d882bebbea9d8f8eac to your computer and use it in GitHub Desktop.
Save slowkow/69d882bebbea9d8f8eac to your computer and use it in GitHub Desktop.
Get SRR ids corresponding to an SRA id.
#!/usr/bin/env bash
# sra2srr.sh
#
# Example
# -------
# To download all of the read archive files for SRP012001:
# sra2srr.sh SRP012001 | while read srr; do prefetch $srr; done
#
# For 'esearch', 'efetch', 'xtract', you must install Entrez Direct:
# http://www.ncbi.nlm.nih.gov/books/NBK179288/
#
# For 'prefetch', you must install SRA Tools:
# https://github.com/ncbi/sra-tools
SRA=$1
esearch -db sra -query $SRA | \
efetch -format docsum | \
xtract -pattern DocumentSummary -element Run@acc | \
tr '\t' '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment