||||
二代测序fastq文件太大,解压,压缩很浪费时间。
常规:使用gzip gunzip单线程压缩
进阶1:python调用threading,多线程压缩,相当于开了N个窗口进行解压和压缩,略。
进阶2:使用pigz,unpigz调用多核cpu压缩和解压。
实测:
import os import time a= time.time() #os.system('gunzip 1-Input_sequence_R2.fastq.gz') # 89s #os.system('./unpigz -p 4 1-Input_sequence_R2.fastq.gz') #37s #os.system('gzip 1-Input_sequence_R2.fastq') # 1200s #os.system('./pigz -p 4 1-Input_sequence_R2.fastq') # 292s b=time.time() print b-a
调用4核,一个10g的fastq文件,gzip压缩用了1200s,而pigz用了292s,3倍多
gzip解压用了89s,unpigz解压用了37s,接近3倍
终极版:python的threading+pigz的-p,把cpu全用了。
对于6个文件的压缩,可以调用6*4=24核,应该能快个3倍多,节省时间。
A parallel implementation of gzip for modern multi-processor, multi-core machines
PS:为什么不用各种专门压缩软件?
例如,这里的一大堆:
http://www.chinapubmed.net/search/?q=fastq+%E5%8E%8B%E7%BC%A9
1,专用软件,安装麻烦
2,客户还得安装
3,参数太复杂,没有pigz 方便
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-6 03:07
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社