macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

高速で高効率なfastqの圧縮ツール DSRC

 

DSRCはマルチスレッドに対応したfastq(ABI SOLiD, and 454/Ion Torrent)の圧縮ツール。gzipやbzipなどの汎用的な圧縮ツールと比較して15~60%高効率とされる。圧縮・解凍速度も極めて速く、8スレッドで500MB/s出るとされる。

 

インストール

binaryのダウンロード

http://sun.aei.polsl.pl/REFRESH/index.php?page=projects&project=dsrc&subpage=download

mac向けをダウンロードして、実行権をつけパスを通す。

 

ソースコード(Gitで管理されている)

https://github.com/refresh-bio/DSRC

user$ dsrc

DSRC - DNA Sequence Reads Compressor

version: 2.00 RC @ 28.03.2014

 

usage: dsrc <c|d> [options] <input filename> <output filename>

compression options:

-d<n> : DNA compression mode: 0-3, default: 0

-q<n> : Quality compression mode: 0-2, default: 0

-f<1,..>: keep only those fields no. in tag field string, default: keep all

-b<n> : FASTQ input buffer size in MB, default: 8

-o<n> : Quality offset, default: 0

-l : use Quality lossy mode (Illumina binning scheme), default: 0

-c : calculate and check CRC32 checksum calculation per block, default: 0

automated compression modes:

-m<n> : compression mode, where n:

* 0 - fast version with decent ratio (-d0 -q0 -b16)

* 1 - slower version with better ratio (-d2 -q2 -b64)

* 2 - slow version with best ratio (-d3 -q2 -b256)

both compression and decompression options:

-t<n> : processing threads number, default (available h/w threads): 24, max: 64

-s : use stdin/stdout for reading/writing FASTQ data

 

実行方法

圧縮

dsrc c input.fastq output.dsrc
  • c compression

解凍

dsrc d input.dsrc output.fastq
  • d decompression

 

4CPUを使い、謝り符号訂正も行いながら高速に圧縮する。

dsrc c -m0 -c -t4 input.fastq output.dsrc
  • -t processing threads number, default (available h/w threads): 24, max: 64
  • -c calculate and check CRC32 checksum calculation per block, default: 0
  • -m compression mode. where n: -m<n> : compression mode, where n: 

   m0 - fast version with decent ratio (-d0 -q0 -b16)

   m1 - slower version with better ratio (-d2 -q2 -b64) 

   m2 - slow version with best ratio (-d3 -q2 -b256)

 

 

-- 簡単なベンチマーク --

timeコマンドを使いfastqの圧縮にかかる時間を計測する。gzipはシングルコアしか使えないため、複数コアを使ってgz圧縮可能なpigzとも比べてみる(参考リンク)。

 

計算には3.46GHz x 12コアのmac pro(2012モデル)を使う。5.6GBのfastqを圧縮する。

DSRC default

time dsrc c -t 22 input.fastq input.dsrc

 5.6GB ==> 788.4MB。要した時間は0分10.6秒。

gzip

time gzip -c input.fastq > input.fastq.gz

5.6GB ==> 755.4MB。要した時間は5分9.0秒。

tar

time tar cvjf input.tar.bz2 input.fastq 

5.6GB ==> 459.4MB。要した時間は8分35秒。

pigz

time pigz -c -p 22 out.fq > out.fq.gz 

5.6GB ==> 756.2MB。要した時間は0分22.9秒。

DSRC 高効率モード

time dsrc c -t 22 -m2 input.fastq input.dsrc

 5.6GB ==> 314.2MB。要した時間は0分22.3秒。

 

-m2オプションをつければ、高速にかなりの圧縮率を達成できそうである。

 

 

クオリティについては" -l "フラグをつけることでlossyな圧縮も可能である。もう使わない可能性が高いデータについては、非可逆圧縮までしてしまってもいいかもしれない(慎重に検討してください)。

 

 

*同じラボからfastqのlossyな圧縮が可能なFaStoreも発表されているが、FasToreについては実行ファイルをダウンロードして使っても、ソースからビルドしても、fastqの圧縮途中でsegmentation errorを起こした(cent OS6環境)。

GitHub - refresh-bio/FaStore: FaStore - high-performance FASTQ files compressor

 

 

引用

DSRC 2—Industry-oriented compression of FASTQ files

Łukasz Roguski Sebastian Deorowicz

Bioinformatics, Volume 30, Issue 15, 1 August 2014, Pages 2213–2215

 

Compression of DNA sequences in FASTQ format

Deorowicz, S., Grabowski, Sz

Bioinformatics, 2011; 27(6):860–862