Skip to main content

CI Python versions Coverage Status Ruff Codacy Badge

cogent3-h5seqs: a HDF5 storage driver for cogent3 sequence collections

cogent3-h5seqs is a sequence storage plug-in for cogent3. It uses HDF5 as the storage format for biological sequences, supporting both unaligned sequence collections and alignments. Storage can be in memory (the default) or on disk and sequences are compressed using the lzf compression engine.

The advantage of HDF5 is that once primary sequence formats have been converted from text into numpy arrays, loading and manipulating sequence data is fast and very memory efficient.

Sequences are stored under the hexdigest of their xxhash.hash64(). This means duplicated sequences are stored only once.

Installation

pip install cogent3-h5seqs

Usage

Three types of sequence storage

Storage Class Suffix Compression Notes
UnalignedSeqsData .c3h5u lzf For variable-length sequences. DNA/RNA moltypes are 2-bit encoded, reducing storage by 75%. The encoding can be turned off using packed=False.
AlignedSeqsData .c3h5a lzf Dense storage for equal-length sequences. Every sequence is stored separately.
SparseSeqsData .c3h5s lzf Sparse storage for equal-length sequences. Much more memory efficient than AlignedSeqsData. Faster to create and write.

Making cogent3-h5seqs the default storage

Using cogent3.set_storage_defaults(), you can set cogent3-h5seqs as the default storage. This means whenever a sequence collection is loaded from disk or created in memory, it will use the storage within this package.

The following statement makes cogent3-h5seqs the default for both unaligned and aligned sequence collections.

import cogent3

cogent3.set_storage_defaults(unaligned_seqs="c3h5u", aligned_seqs="c3h5a")

You can undo this setting by

cogent3.set_storage_defaults(reset=True)

Equivalently, you could define

Using cogent3-h5seqs as storage per object

You don't have to specify the storage as the default for all instances, but can do it on a per object basis.

coll = cogent3.load_unaligned_seqs(
    some_path, moltype="dna", storage_backend="h5seqs_unaligned"
)

or, for alignments.

aln = cogent3.load_aligned_seqs(some_path, moltype="dna", storage_backend="c3h5s")

The same values can also be provided to the make_unaligned_seqs(), make_aligned_seqs() functions in cogent3.

Note With the 2-bit encoding for DNA/RNA sequences, you can safely turn off compression with compression=False. This can speed up operations. You can also turn off the encoding by setting packed=False.

Saving storage to disk

cogent3-h5seqs supports writing to disk, and employs the filename suffix .c3h5u for unaligned sequences and .c3h5a for aligned sequences. This will work whether your current object is using cogent3-h5seqs for storage or not. For example

sample_aln = cogent3.get_dataset("brca1")  # using the cogent3 builtin storage
outpath = "~/Desktop/alignment_output.c3h5s"
sample_aln.write(outpath)  # writes out as cogent3-h5seqs HDF5 storage

For a sequence collection, do the following.

sample_coll = cogent3.get_dataset("brca1").degap()
# Note the different suffix
outpath = "~/Desktop/alignment_output.c3h5u"
sample_coll.write(outpath)  # writes out as cogent3-h5seqs HDF5 storage

Loading storage from disk

cogent3 correctly directs to cogent3-h5seqs for loading based on the filename suffix.

inpath = "~/Desktop/alignment_output.c3h5u"
sample_coll = cogent3.load_unaligned_seqs(inpath, moltype="dna")

Note You cannot write an alignment instance to an unaligned storage type or vice versa. Nor can you read into the different types.

Metadata

Release files for cogent3-h5seqs 0.10.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cogent3-h5seqs 0.10.1
File Size Uploaded Provenance Actions
cogent3_h5seqs-0.10.1.tar.gz 171.6 kB With provenance Details for cogent3_h5seqs-0.10.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cogent3-h5seqs 0.10.1
File Interpreter ABI Platform Actions
cogent3_h5seqs-0.10.1-py3-none-any.whl Python 3 none any Details for cogent3_h5seqs-0.10.1-py3-none-any.whl

Total release size: 206.1 kB

Release files / cogent3_h5seqs-0.10.1.tar.gz

Download URL cogent3_h5seqs-0.10.1.tar.gz
Size 171.6 kB
Tags Source
SHA-256 checksum
How to use checksums
beb763e6385ae016335d692b1cdc4ea656f7f7343d340f76e6648e3182aefa07
BLAKE2b-256 checksum
How to use checksums
74e45f982994b46d6ab43ec72d676924bd78fabc1ae962a3e4447df0a2442085
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / cogent3_h5seqs-0.10.1-py3-none-any.whl

Download URL cogent3_h5seqs-0.10.1-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef75fbbcc5509a0e38dceac61f8678e236cc491ae9fbaf88a746492a56717d2d
BLAKE2b-256 checksum
How to use checksums
ed4932be2b03340c1107a447752acc88d604f802b7fbf5e3896f6ee0fba46fb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for cogent3-h5seqs 0.10.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cogent3_h5seqs-0.10.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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