本來想重復冷泉港Lippman 2017年在Cell上的一篇文章:Bypassing Negative Epistasis on Yield in Tomato Imposed by a Domestication Gene,但是在下載數據的時候,遇到了一個大坑,萌生了對現(xiàn)有下載NGS數據總結的一個想法,歸納如下:
NGS數據下載的幾種方式
NGS數據的存儲方式一般有兩種,SRA格式或fastq格式。其中,SRA格式是NCBI對NGS數據的一種壓縮格式,需要利用sratools對sra文件進行解壓縮操作;而在ENA (European Nucleotide Archive)中,直接以fastq.gz的壓縮格式對測序數據進行存儲。
1. Aspera Connect下載(首選)
Aspera connect是IBM的商業(yè)化高速文件下載軟件,但可以免費下載NCBI和EBI的數據。速度可達200-500Mbps,幾乎所有站點都超過10Mbps
如果Aspera connect不能下載,則推薦sratoolkit的prefetch功能
-最后,盡量使用sratoolkit中的fastq-dump和sam-dump命令。如果fastq-dump連接外部穩(wěn)定,則推薦使用Biostar Handbook中的wonderdump腳本。
警告:盡量不要使用wget或curl命令來下載
2.1安裝及添加環(huán)境變量
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
2.2 Aspera使用
Official documents
命令行格式:
ascp [options] target-file storage-directory
參數說明:
-i(必選): Use public key authentication and specify the private key file, the address normally is ~/.aspera/connect/etc/asperaweb_id_dsa.openssh.
-T: Disable encryption, otherwise downloading will be interrupted sometimes.
-l: Set the target transfer rate in Kbps, normally is 200m - 500m.
-k: Enable resuming partially transferred files, better set value 1.
-Q: Enable fair transfer policy, use it when download data from ENA database.
-P: Set the TCP port used for fasp session initiation, just use value 33001.
使用舉例:
(1) 從SRA數據庫下載數據:
首先要確定SRA數據是否在ftp-private.ncbi.nlm.nih.gov中,有時,數據也有可能在https://sra-downloadb.be-md.ncbi.nlm.nih.gov/(不知道是否年代比較久遠的數據就在這里?)。SRA在Aspera中的用戶名為anonftp,如要下載SRR949627.sra,命令行為:
ascp -v -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh -k 1 -T -l 200m anonftp@ftp-private.ncbi.nlm.nih.gov:/sra/sra-instant/reads/ByRun/sra/SRR/SRR949/SRR949627/SRR949627.sra ./
注意:
- anonftp@ftp-private.ncbi.nlm.nih.gov后為“:”
- sra文件在NCBI的存儲路徑相同,一般為/sra/sra-instant/reads/ByRun/sra/...,便于利用腳本進行批量操作
(2) 從ENA數據庫下載數據:
測序數據的存儲位置在fasp.sra.ebi.ac.uk,ENA在Aspera中的用戶名為era-fasq,ena可以直接下載fastq.gz文件,不必再從sra文件轉換了。地址去ENA搜索,再復制fastq.gz文件的地址,或者去ENA的ftp地址ftp.sra.ebi.ac.uk搜索,注意是ftp不是fasp。
ascp -v -P33001 -i ~/.aspera/connect/etc/asperaweb_id_dsa.openssh -k 1 -QT -l 200m era-fasp@fasp.sra.ebi.ac.uk:/vol1/fastq/SRR949/SRR949627/SRR949627_1.fastq.gz ./
注意:
- era-fasp@fasp.sra.ebi.ac.uk 后為“:”
- 文件路徑同樣有規(guī)律可循,方便利用腳本進行批量操作
2. SRA toolkit的prefetch命令(不是太推薦,土豪實驗室除外)
單個文件下載:
prefetch <SRA accession>
批量下載:
進入需要下載多個SRA文件的頁面,一般是某個PRJ accession,然后右上角選send to-file,format選擇accession list,保存為一個file(默認是SraAccList.txt),通過以下命令進行下載:
prefetch --option-file SraAccList.txt
3. 通過Linux wget或curl命令下載(不推薦)
首先,查找到NGS存放的位置,一般在NCBI或者ENAftp服務器中,然后通過wget或curl命令下載。
wget -c ftp://ftp-trace.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByStudy/sra/SRR155/SRR1553608/SRR1553608.sra
# -c 為斷點續(xù)傳參數
curl -O ftp://ftp-trace.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByStudy/sra/SRR155/SRR1553608/SRR1553608.sra
這倆的下載速度會讓你懷疑人生,當然,土豪實驗室或研究所除外。