2019年11月28日木曜日

SRAデータのダウンロードツールがfastq-dumpからfasterq-dumpへ

次世代シークエンスのデータをncbiのSRAからダウンロードする際に用いられていたのが、ncbiのSRA toolkitに含まれる、fastq-dumpだった。
 https://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?view=toolkit_doc&f=fastq-dump

ペアエンドのリードをダウンロードする際は、二つのファイルを生成するように以下のようなオプションを使っていた。
> fastq-dump -I --split-files SRR000001

しばらく使っていなかったのだが、久しぶりに見てみると、クラウド移行した上にマルチスレッドにも対応したfasterq-dumpというコマンドが使えるようになっていた。2.9.1からということだが、現在の最新は2.10.0だった。
 githubのREADMEにアナウンスメントがあり、まだfastq-dumpも使えるが、今後fasterq-dumpに移行していくようだ。

ANNOUNCEMENT:

With release 2.10.0 of sra-tools we have added cloud-native operation for AWS and GCP environments (Linux only for this release), for use with the public SRA. prefetch is capable of retrieving original submission files in addition to ETL data.
With release 2.9.1 of sra-tools we have finally made available the tool fasterq-dump, a replacement for the much older fastq-dump tool. As its name implies, it runs faster, and is better suited for large-scale conversion of SRA objects into FASTQ files that are common on sites with enough disk space for temporary files. fasterq-dump is multi-threaded and performs bulk joins in a way that improves performance as compared to fastq-dump, which performs joins on a per-record basis (and is single-threaded).
fastq-dump is still supported as it handles more corner cases than fasterq-dump, but it is likely to be deprecated in the future.

Wikiに詳しく使い方が書いてあり、メモリをtmpに使用する方法やディスクの空き容量を調べる方法など色々解説してあって勉強になる。
https://github.com/ncbi/sra-tools/wiki/HowTo:-fasterq-dump


 まずは、wgetでダウンロードしたのちに、展開する。binの中にプログラムが入っているので、パスを通す。
> wget http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.10.0/sratoolkit.2.10.0-centos_linux64.tar.gz
> tar xzf ./sratoolkit.2.10.0-centos_linux64.tar.gz

これでまずはSRRファイルを一つダウンロードすることを試みたのだが、以下のエラーメッセージが帰ってきた。
> fasterq-dump SRR6453566 -t /dev/shm -e 8 -p

Can't locate XML/LibXML.pm in @INC (you may need to install the XML::LibXML module) 

 XML::LibXMLをcpanで入れようとしたのだが、なぜかエラーでうまくいかなかった。

仕方がないので試しに以前のバージョン(2.9.2)をインストールして使ってみると、今度はうまくダウンロードすることができた。 
> fasterq-dump SRR6453566 -t /dev/shm -e 8 -p
 

join   :|-------------------------------------------------- 100.00%
concat :|-------------------------------------------------- 100.00%
spots read      : 9,980,987
reads read      : 19,961,974
reads written   : 19,961,974


ここで、-tは一時的にできるファイルの場所を指定するオプションで、指定しない場合は今いるところに作られ、ダウンロード終了の際に消去されるようだ。ここで-t /dev/shmと指定することで、メモリをtmpの場所として指定することができるようで、ダウンロードの高速化が見込める。他にも、-tでSSDなどを指定しても良いらしい。-eは使うスレッドの数で、デフォルトは6。ただ、これは増やしたからといって必ずしもずっと高速化するわけではなく、I/Oの速さの制約を受けると書いてある。

これで、試しにBrassica napusについて大規模に解析した論文のデータをダウンロードしてみることにした。B. napusについては、違うグループから大規模集団解析の結果が立て続けにNature communicationsに掲載されている。

 Whole-genome resequencing reveals Brassica napus origin and genetic loci involved in its improvement.
https://www.nature.com/articles/s41467-019-09134-9

Transcriptome and organellar sequencing highlights the complex origin and diversification of allotetraploid Brassica napus.
https://www.nature.com/articles/s41467-019-10757-1

この2番目の方のデータをダウンロードしてみることにした。data availabilityの情報から、SRAの番号がSRA128554であることから、これをSRA Run Selectorで探した。
https://trace.ncbi.nlm.nih.gov/Traces/study/?acc=srp128554

Run Selectorも昔のサイトよりもすごくモダンな感じになっており、見やすくなっていた。ここからSRRのリストをダウンロードし、シェルスクリプトを書いてLinux機で実行した。

time fasterq-dump SRR6453567 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453568 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453569 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453570 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453571 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453573 -t /dev/shm -e 8 -p
time fasterq-dump SRR6453574 -t /dev/shm -e 8 -p

///

全体のデータ量が935.18Gbとあるので、だいぶん大きい。しばらく時間がかかりそうだ。
扱うデータが大きくなると、ストレージの確保もだが、大きなデータの効率的な扱い方を覚えないと軽く死ねそうだ。