CRABZ

https://img.shields.io/badge/wrapper_version-v9.15.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/utils/crabz?label=version%20update%20pull%20requests&color=1cb481

Like pigz, but rust. A cross platform, fast, compression and decompression tool.

URL: https://github.com/sstadick/crabz

Example

This wrapper can be used in the following way:

rule test_crabz_file_compression:
    input:
        "hello.txt",
    output:
        "hello.txt.gz",
    log:
        "test_crabz_single_file_compression.log",
    threads: 1
    params:
        extra="--compression-level 9",
    wrapper:
        "v9.15.0/utils/crabz"


rule test_crabz_file_decompression:
    input:
        "hello.txt.gz",
    output:
        "hello.decompressed.txt",
    log:
        "test_crabz_single_file_decompression.log",
    threads: 1
    params:
        extra="",
    wrapper:
        "v9.15.0/utils/crabz"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • crabz=0.10.0

  • snakemake-wrapper-utils=0.9.0

Input/Output

Input:

  • Path to the file to compress.

Output:

  • Path to archive.

Params

  • extra: Optional parameters besides -p|–compression-threads or -o|–output

Authors

Code

# coding: utf-8

"""Snakemake wrapper for crabz"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2026, Thibault Dayris"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"

from snakemake.shell import shell
from snakemake_wrapper_utils.snakemake import get_format, is_arg

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)


def crabz_format(file_path):
    fmt = get_format(file_path, ignore_compression=False)
    if fmt == "bgzip":
        return "bgzf"
    return fmt


available_compression_formats = {"gzip", "bgzf", "mgzip", "zlib", "deflate", "snap"}

input_file_format = crabz_format(str(snakemake.input))
if input_file_format in available_compression_formats:
    extra += f" --decompress"
    if not is_arg("format", extra):
        extra += f" --format '{input_file_format}'"
elif not is_arg("format", extra):
    extra += f" --format '{crabz_format(str(snakemake.output))}'"

shell(
    "crabz --compression-threads {snakemake.threads} {extra} "
    "--output {snakemake.output:q} {snakemake.input:q} {log}"
)