Skip to content

Instantly share code, notes, and snippets.

@aneeshpanoli
Last active January 24, 2020 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aneeshpanoli/bf70e834bdef12b3fe5591532f954c58 to your computer and use it in GitHub Desktop.
Save aneeshpanoli/bf70e834bdef12b3fe5591532f954c58 to your computer and use it in GitHub Desktop.
Download sequence from NCBI SRA
import os
#download SRA tool kit
def setup_sra_tool(url):
!wget $url
!gunzip sratoolkit.2.9.6-1-ubuntu64.tar.gz
!tar -xf sratoolkit.2.9.6-1-ubuntu64.tar
#download SRA file and extract fastq
def get_sra(url, sra_path):
os.chdir('/content')
!wget $url
sra_name = url[-11:]
os.chdir(sra_path)
!./fastq-dump /content/$sra_name -O /content/
os.chdir('/content')
# url of SRA tool kit
url_tk= 'https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.9.6-1/sratoolkit.2.9.6-1-ubuntu64.tar.gz'
setup_sra_tool(url_tk)
# example SRA file
sra_url = 'https://sra-download.ncbi.nlm.nih.gov/traces/era6/ERR/ERR3014/ERR3014700'
tool_path = '/content/sratoolkit.2.9.6-1-ubuntu64/bin'
get_sra(sra_url, tool_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment