How to download All Sra data At Once
SRA: Sequence Read Archive: It belongs to NCBI (National Center for Biotechnology Information), is a database storing high throughput sequencing (HTS) raw data, alignment information and metadata. Almost all HTS data in published publications will be asked uploading to here, and stored as .sra compressed file format.
ENA: European Nucleotide Archive: It belongs to EBI (European Bioinformatics Institute), although it has the same funtion with SRA, more annotations and friendlier website make it preferable. What’s more, you could download directly fastq.gz files from it.
下載sra files的目的是為了獲得相應的fastq或sam files,進而進行分析。
第1選擇--Aspera Connect 如果aspera connect不能下載,推薦sratoolkit的prefetch功能。盡量不要用wget或curl下載,速度慢,且有時下載不完全
注意:Aspera>Sratools>ftp
第1選擇:Aspera Connect
-Aspera connect是IBM的商業化高速文件下載軟件,但可以免費下載NCBI和EBI的數據。速度可達200-500Mbps,幾乎所有站點都超過10Mbps
-如果Aspera connect不能下載,則推薦sratoolkit的prefetch
功能
-最后,盡量使用sratoolkit中的fastq-dump
和sam-dump
命令。如果fastq-dump
連接外部穩定,則推薦使用Biostar Handbook中的wonderdump腳本。
警告:盡量不要使用
wget
或curl
命令來下載
Aspera有兩種方式可以下載
第一,安裝客戶端(支持windows),
具體可參考這篇文章
第二,命令行下載
關于第一種方式 ,下載直接安裝即可,下載鏈接h
Aspera Connect命令行工具-ascp
首先,goto Aspera connect,選擇linux版本,復制鏈接地址(這個需要代理下載)
wget http://download.asperasoft.com/download/sw/connect/3.7.4/aspera-connect-3.7.4.147727-linux-64.tar.gz
#解壓縮
tar zxvf aspera-connect-3.7.4.147727-linux-64.tar.gz
# install
bash aspera-connect-3.7.4.147727-linux-64.sh
# check the .aspera directory
cd # go to root directory
ls -a # if you could see .aspera, the installation is OK
# add environment variable
echo 'export PATH=~/.aspera/connect/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
#密鑰備份到/home/的家目錄(后面會用,否則報錯)
cp ~/.aspera/connect/etc/asperaweb_id_dsa.openssh ~/
# check help file
ascp --help
恭喜,安裝完成,開始下載,感受飛一般的速度
下載SRA數據:SRA數據庫
注意:要找到下載地址,windows需要使用ie瀏覽器(google不可以)。進入下列網站https://www.ncbi.nlm.nih.gov/projects/faspftp/
若下載sra,依次:sra-sra-instant-reads-ByRun-sra-SRR-SRR###-SRR###$$$-SRR###$$$.sra
比如下載SRR949627.sra文件
ascp -v -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh -k 1 -T -l200m anonftp@ftp-private.ncbi.nlm.nih.gov:/sra/sra instant/reads/ByRun/sra/SRR/SRR949/SRR949627/SRR949627.sra .
如果報ascp: Source file list not specified, exiting,看下最后那個點是否加了,有空格
注意:最后那個.一定要有,表示下載后的路徑,我的速度大概5M/s,比起wget和prefetch已經是在奔跑了。
ENA數據庫下載
數據的存放地址是fasp.sra.ebi.ac.uk,ENA在Aspera的用戶名是era-fasp,注意,ena可以直接下載fastq.gz文件,不必再從sra文件轉換了。地址去ENA搜索,再復制fastq.gz文件的地址,或者去ENA的ftp地址ftp.sra.ebi.ac.uk搜索,注意是ftp不是fasp。
ascp -QT -l 300m -P33001 -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh era-fasp@fasp.sra.ebi.ac.uk:/vol1/fastq/SRR949/SRR949627/SRR949627_1.fastq.gz .
至此,完成原始數據下載!!
3下面再看下不推薦的方法如何下載數據。
1 use R
比如要下載下列數據
https://www.ncbi.nlm.nih.gov/sra
1使用SRAdb包
source('http://bioconductor.org/biocLite.R')
biocLite('SRAdb')
library(SRAdb)
srafile = getSRAdbFile()
con = dbConnect('SQLite',srafile)
2使用GEOquery包
library(GEOquery)
gse <- getGEO('GSE48138') # retrieves a GEO list set for your SRA id.
## see what is in there:
show(gse)
# There are 2 sets of samples for that ID
## what you want is table a with SRR to download and some sample information:
## lets see what the first set contains:
df <- as.data.frame(gse[[1]])
head(df)
2 使用命令行ftp下載
1 wget命令
比如
wget ftp://ftp-trace.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByStudy/sra/SRP%2FSRP055%2FSRP055992/SRR1871481/SRR1871481.sra
2 SRA toolkit的prefetch命令
比如,單個下載
prefetch -v SRR925811
或批量下載
for i in `seq 48 62`;
do
prefetch SRR35899${i}
done
還可以多個一起下載
先找到要下載的頁面,比如https://www.ncbi.nlm.nih.gov/sra,然后右上角,send to-file,format選擇accession list,保存為一個file(默認是SraAccList.txt),然后
prefetch $(<SraAccList.txt)
另外,還可以嘗試geofetch功能,具體見
https://github.com/pepkit/geofetch