Skip to main content

genome-zarr-4bit

genome-zarr-4bit turns a FASTA file into a standard, directory-backed Zarr v3 group. Each chromosome is a one-dimensional uint8 Zarr array containing two 4-bit base codes per byte: A=0, C=1, G=2, T=3, and N (or any unsupported IUPAC base) =4. This is the same packed layout used by zarr_compression_benchmark.py; unlike its manual backend, Zarr owns the chunking and compression.

The implementation scans the FASTA once for record sizes and streams it on the second pass. It does not load chromosomes into memory. The default logical chunk is 1 MiB of bases (512 KiB packed bytes), matching the benchmark's default 1 MB base chunk.

Install

From this directory:

python -m pip install .

The package requires Zarr v3 and explicitly creates every group with zarr_format=3. Zstandard compression uses Zarr v3's native zarr.codecs.ZstdCodec; no numcodecs dependency is used for this codec. Transcode commands can read an existing package-created v2 store as a migration source, but every destination they create is Zarr v3.

Commands

# FASTA -> packed 4-bit Zarr with Zstandard compression
genome-zarr fasta-to-zstd genome.fa /data/genome.zarr

# compressed -> uncompressed, preserving arrays, chunks, and attributes
genome-zarr decompress /data/genome.zarr /data/genome-uncompressed.zarr

# uncompressed -> Zstandard (also works as a recompression operation)
genome-zarr compress /data/genome-uncompressed.zarr /data/genome-recompressed.zarr

Destinations must be new unless --overwrite is supplied. To select a chunk size or Zstandard level or number of CPU workers:

# FASTA -> packed 4-bit Zarr with Zstandard compression (chunk size, level, workers)
genome-zarr fasta-to-zstd genome.fa /data/genome.zarr --chunk-bases 2097152 --zstd-level 6 --num-workers 16

# compressed -> uncompressed with parallel workers
genome-zarr decompress /data/genome.zarr /data/genome-uncompressed.zarr --num-workers 8

# uncompressed -> Zstandard (recompression) with parallel workers
genome-zarr compress /data/genome-uncompressed.zarr /data/genome-recompressed.zarr --zstd-level 6 --num-workers 8

--chunk-bases must be even, since two bases occupy each byte. Store-level attributes document the encoding and each chromosome array has a logical_length attribute, which removes the one-base padding ambiguity for odd-length sequences.

Each command prints Starting <command>... immediately, then a completion summary with elapsed time, chromosome and base counts, packed-data size, Zarr format, compression mode, and apparent and allocated destination storage. Transcoding commands also print the source store's apparent size.

Python API

from genome_zarr import fasta_to_zstd, decompress_zarr, compress_zarr

fasta_to_zstd("genome.fa", "genome.zarr")
decompress_zarr("genome.zarr", "genome-uncompressed.zarr")
compress_zarr("genome-uncompressed.zarr", "genome-zstd.zarr")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genome_zarr_4bit-0.3.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genome_zarr_4bit-0.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file genome_zarr_4bit-0.3.0.tar.gz.

File metadata

  • Download URL: genome_zarr_4bit-0.3.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for genome_zarr_4bit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f7e2e7501339fbd1b10d667cd91897eba842c1d49609d8ee441f93410d1ad959
MD5 96c5efb08b8ece829c2ddf49c046eb63
BLAKE2b-256 3de8871218fbc48496b4fcf0d6adc9c30000f1e987f5abaa516e42471690d972

See more details on using hashes here.

File details

Details for the file genome_zarr_4bit-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for genome_zarr_4bit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 945858ca6d1d7b74f18aff030f1b45fe9b894f6ebe9ad70ff4806030237047b6
MD5 6c82cdaac7b5ed8242121cd2fc1bfc6a
BLAKE2b-256 35f5c31b31165bda0bdc4527cc77d97baf9eced2f20a00833fe6daa11a1c27f8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

1 file

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page