生信技能技巧小知识,Linux多线程压缩/解压工具

原文链接:生信技能技巧小知识,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
  1. 使用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秒,主要还是由于我硬盘的速写速度导致这个时间延长,若是你的硬盘读写较快,那么的时间会更短。

单个文件解压,mingzpigz比较。

软件 时间 解压后文件
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语言绘图教程。

相关推荐
睡不醒男孩03082326 分钟前
第二篇:深入探索开源数据库高可用:构建基于CLup的PostgreSQL生产级高可用与读写分离架构
数据库·postgresql·开源·clup
方便面不加香菜1 小时前
Linux--基础IO(一)
linux·运维·服务器
Micro麦可乐3 小时前
Spring Boot 实战:从零设计一个短链系统(含完整代码与数据库设计)
数据库·spring boot·后端·哈希算法·雪花算法·短链系统
码农阿豪3 小时前
从零到一:Spring Boot快速接入金仓数据库实战
数据库·spring boot·后端
鼎讯信通3 小时前
风电光缆运维提质增效:G-4000A 光缆故障追踪仪破解风场巡检难题
运维·网络·数据库
三十..4 小时前
MySQL 从入门到高可用架构实战精要
运维·数据库·mysql
cfm_29144 小时前
Redis五大基本数据结构底层了解
数据结构·数据库·redis
真实的菜5 小时前
Redis 从入门到精通(十二):典型业务场景实战 —— 排行榜、限流器、秒杀系统、Session 共享
数据库·redis·python
你想考研啊5 小时前
mysql数据库导出导入
数据库·mysql·oracle
mounter6255 小时前
现代 Linux 内存管理的演进与变革:从传统 LRU 到多代架构 MGLRU
linux·服务器·kernel