原文链接:生信技能技巧小知识,Linux多线程压缩/解压工具
语雀文档链接:生信技能技巧小知识,Linux多线程压缩/解压工具(语雀文档)
R
https://www.yuque.com/bioinformatic/dulearning/fiu1ymkqlumdpn2i
们这里使用的是西柚服务器,他们的下载网络确实很快,有国际专线,前面我们在zenodo数据中下载T2T泛基因组,轻轻松松搞定,2026年Pan-genome可能作为顶刊的一个方向,如何快速下载T2T-Pan-genome数据?。
网址:
R
https://dayu.xiyoucloud.net/dayu/api/v1/anonymous/affiliate/BioinfoDu
本期教程

前言
我们分享了Linux中多线程压缩软件 | Mingz。对于个人来说,比较喜欢把CPU全部榨干,因此,不会留给CPU任何余粮(PS:在使用的时候)。因此,多线程是在跑程序时必须加上的参数。前段时间,下载了几百个fq数据,有时分析需要进行解压,若是使用Linux自带的压缩解压软件,基本只能使用单线程。为提高效率,我们来分享支持多线程的压缩解压软件。
Pigz简介
pigz是 Parallel Implementation of GZip 的缩写,它是 gzip 的全功能替代品,在压缩数据时可充分利用多处理器和多内核。
安装
方法一:推荐
R
mamba install -y pigz
or
conda install -y pigz
``
方法二:
```R
sudo apt install pigz
方法三:源码安装
网址:
R
https://github.com/madler/pigz
安装成功:
R
$ pigz -h
Usage: pigz [options] [files ...]
will compress files in place, adding the suffix '.gz'. If no files are
specified, stdin will be compressed to stdout. pigz does what gzip does,
but spreads the work over multiple processors and cores when compressing.
Options:
-0 to -9, -11 Compression level (level 11, zopfli, is much slower)
--fast, --best Compression levels 1 and 9 respectively
-A, --alias xxx Use xxx as the name for any --zip entry from stdin
-b, --blocksize mmm Set compression block size to mmmK (default 128K)
-c, --stdout Write all processed output to stdout (won't delete)
-C, --comment ccc Put comment ccc in the gzip or zip header
-d, --decompress Decompress the compressed input
-f, --force Force overwrite, compress .gz, links, and to terminal
-F --first Do iterations first, before block split for -11
-h, --help Display a help screen and quit
-H, --huffman Use only Huffman coding for compression
-i, --independent Compress blocks independently for damage recovery
-I, --iterations n Number of iterations for -11 optimization
-J, --maxsplits n Maximum number of split blocks for -11
-k, --keep Do not delete original file after processing
-K, --zip Compress to PKWare zip (.zip) single entry format
-l, --list List the contents of the compressed input
-L, --license Display the pigz license and quit
-m, --no-time Do not store or restore mod time
-M, --time Store or restore mod time
-n, --no-name Do not store or restore file name or mod time
-N, --name Store or restore file name and mod time
-O --oneblock Do not split into smaller blocks for -11
-p, --processes n Allow up to n compression threads (default is the
number of online processors, or 8 if unknown)
-q, --quiet Print no messages, even on error
-r, --recursive Process the contents of all subdirectories
-R, --rsyncable Input-determined block locations for rsync
-S, --suffix .sss Use suffix .sss instead of .gz (for compression)
-t, --test Test the integrity of the compressed input
-U, --rle Use run-length encoding for compression
-v, --verbose Provide more verbose output
-V --version Show the version of pigz
-Y --synchronous Force output file write to permanent storage
-z, --zlib Compress to zlib (.zz) instead of gzip format
-- All arguments after "--" are treated as files
常用参数:
R
-0 ~ -9 压缩等级,数字越大压缩率越高,速度越慢,默认为6
-k --keep 压缩后不删除原始文件
-l --list 列出压缩输入的内容
-K --zip Compress to PKWare zip (.zip) single entry format
-d --decompress 解压缩输入
-p --processes n 使用n核处理,默认为使用所有CPU核心
速度比拼:
我们这里就只看解压速度。
1. 文件大小
R
$ du -sh *
3.5G SRR9071704_1.fastq.gz
4.1G SRR9071704_2.fastq.gz
3.6G SRR9071705_1.fastq.gz
4.2G SRR9071705_2.fastq.gz
- 使用CPU核心数量,28核心。
R
$ time pigz -k -d *.gz
real 5m4.003s
user 5m17.713s
sys 2m4.975s
#-------
# 解压后文件
$ du -sh *.fastq
17G SRR9071704_1.fastq
17G SRR9071704_2.fastq
17G SRR9071705_1.fastq
17G SRR9071705_2.fastq
这样解压速度算是比较快的,5分04秒,主要还是由于我硬盘的速写速度导致这个时间延长,若是你的硬盘读写较快,那么的时间会更短。
单个文件解压,mingz与pigz比较。
| 软件 | 时间 | 解压后文件 |
|---|---|---|
| Pigz | 48秒 | 17G |
| mingZ | 4分8秒 | 17G |
R
$ time mingz SRR9071704_1.fastq.gz -c -d >SRR9071704_1.fastq
real 4m8.304s
user 1m32.054s
sys 0m21.051s
R
$ time pigz -k -d SRR9071704_1.fastq.gz
real 0m48.040s
user 1m18.448s
sys 0m30.692s
若我们的教程对你有所帮助,请
点赞+收藏+转发,这是对我们最大的支持。
2024已离你我而去,2025加油!!
2025年推文汇总 (点击后访问)
2024年推文汇总 (点击后访问)
2023年推文汇总 (点击后访问)
2022年推文汇总 (点击后访问)
往期部分文章
1. 最全WGCNA教程(替换数据即可出全部结果与图形)
推荐大家购买最新的教程,若是已经购买以前WGNCA教程的同学,可以在对应教程留言,即可获得最新的教程。(注:此教程也仅基于自己理解,不仅局限于此,难免有不恰当地方,请结合自己需求,进行改动。)
2. 精美图形绘制教程
3. 转录组分析教程
4. 转录组下游分析
BioinfoR生信筆記 ,注于分享生物信息学相关知识和R语言绘图教程。