生信技能技巧小知识,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语言绘图教程。

相关推荐
薛定谔的悦32 分钟前
储能 EMS 的功率策略:从一块电表到一次逆流的 200 毫秒
大数据·linux·能源·储能·bms
zlwool4 小时前
图纸管理选型避坑指南
数据库·erp·设备erp·非标机械
新时代牛马4 小时前
Linux 内核入门地图:架构、源码目录与五大子系统
linux·运维·架构
智购科技无人售货机厂家4 小时前
2026自动售货机制冷系统维护指南:从散热器清洁到压缩机换油的工程实践~YH
运维·redis·物联网·缓存·架构
Julien20044 小时前
控制 SELinux 文件上下文
linux·运维·服务器
sulikey4 小时前
Linux Core Dump 完全指南:从原理到实战的崩溃调试手册。什么是core dump?程序报错core dumped怎么办?
linux·服务器·操作系统·调试·coredump
小灰灰搞电子5 小时前
完全驾驭 Qt 与数据库:C++ ORM 框架 QxOrm 原理与实践指南
数据库·c++·qt
软件聚导航7 小时前
「聚小软 AI 助手」技术升级:从数据库检索到 RAG 知识库问答
前端·数据库·mysql·微信小程序·小程序·ai编程·rag
学习星球7 小时前
单调栈——从“找下一个更大的“到柱状图中的最大矩形
数据库·c++·算法·leetcode·xcode
MayZork7 小时前
Windows 与 Linux 下 vcpkg 的安装部署指南
linux·运维·windows