Skip to main content

Add your description here

Project description

pod5-random-access

Introduction

A high-performance Python library for efficient random access to nanopore sequencing signals stored in POD5 files. This library creates optimized indexes that enable fast retrieval of specific reads without loading entire files into memory.

Why pod5-random-access?

The standard pod5 library requires scanning Read Table batches to locate a specific read, making true random access expensive. This library pre-builds a lightweight index that maps each UUID directly to its Signal Table location, bypassing the Read Table entirely at runtime. Combined with plan_fetch_order, which sorts accesses by on-disk position, even HDD-based workflows achieve near-sequential I/O performance.

Installation

Install from PyPI:

pip install pod5-random-access

Requirements:

  • Python 3.10+

Usage

Adding POD5 files

Index files (.pod5.idx) are automatically managed. When a POD5 file is added, the library checks for an existing index next to it. If found, loading is deferred until first access. If not, the index is built immediately and saved alongside the POD5 file.

from pod5_random_access import Pod5RandomAccessReader

reader = Pod5RandomAccessReader()

# Add a single file
reader.add_pod5("path/to/run1.pod5")

# Or add all .pod5 files in a directory (recursive)
reader.add_pod5_dir("path/to/pod5/files")

To skip saving index files, set save_index=False:

reader = Pod5RandomAccessReader(save_index=False)
reader.add_pod5("path/to/run1.pod5")  # builds in memory only

Fetching signals

# Raw signal (int16)
signal = reader.fetch_signal("run1.pod5", "read-uuid-string")

# Calibrated pA signal (float32) — (raw + offset) * scale
pA_signal = reader.fetch_pA_signal("run1.pod5", "read-uuid-string")

# Calibration parameters
offset, scale = reader.get_calibration("run1.pod5", "read-uuid-string")

# Signal length (without reading the signal)
length = reader.get_signal_length("run1.pod5", "read-uuid-string")

Batch index building

To pre-build indexes for all POD5 files in a directory:

from pod5_random_access import build_pod5_index

# Builds .pod5.idx next to each .pod5 file
# Automatically parallelizes on SSD, runs sequentially on HDD
build_pod5_index("path/to/pod5/files")

Optimizing read order for HDD

When reading many signals from HDD, sorting by on-disk position avoids random seeks:

sorted_items = reader.plan_fetch_order(
    read_info_list,
    key=lambda x: (x.filename, x.read_id),
)
for item in sorted_items:
    signal = reader.fetch_signal(item.filename, item.read_id)

Building from Source

Dependencies

Install system packages:

sudo apt install -y build-essential cmake python3-dev libzstd-dev \
  libssl-dev libbz2-dev liblz4-dev libsnappy-dev libcurl4-openssl-dev \
  libre2-dev libutf8proc-dev libprotobuf-dev protobuf-compiler \
  libflatbuffers-dev flatbuffers-compiler

Apache Arrow (source build)

The Arrow package is not available via apt on Ubuntu 25.10. Build from source:

git clone --depth 1 --branch apache-arrow-23.0.1 https://github.com/apache/arrow.git
cd arrow/cpp
cmake -B build \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DCMAKE_BUILD_TYPE=Release \
  -DARROW_COMPUTE=ON \
  -DARROW_CSV=ON \
  -DARROW_JSON=ON \
  -DARROW_DATASET=ON \
  -DARROW_FILESYSTEM=ON \
  -DARROW_WITH_ZSTD=ON \
  -DARROW_WITH_LZ4=ON \
  -DARROW_WITH_SNAPPY=ON \
  -DARROW_WITH_BZ2=ON
cmake --build build -j$(nproc)
sudo cmake --install build
sudo ldconfig
cd ../..

Note: The CI uses Arrow 12.0.1, but older versions may fail to build on newer systems due to OpenSSL incompatibilities. Arrow 23.0.1 works on Ubuntu 25.10.

Arrow version compatibility fix

When building with lastest Arrow, DCHECK_EQ has been renamed to ARROW_DCHECK_EQ. Apply this fix before building:

sed -i 's/DCHECK_EQ/ARROW_DCHECK_EQ/g' extern/pod5-file-format/c++/pod5_format/types.cpp

Build and install

git clone --recursive https://github.com/NoguchiRyo/pod5-random-access.git
cd pod5-random-access

# Build C++ extension
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
cmake --install build

# Install Python package
uv venv
source .venv/bin/activate
uv pip install .

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pod5_random_access-1.0.3-cp313-cp313-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pod5_random_access-1.0.3-cp313-cp313-manylinux_2_34_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pod5_random_access-1.0.3-cp312-cp312-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pod5_random_access-1.0.3-cp312-cp312-manylinux_2_34_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pod5_random_access-1.0.3-cp311-cp311-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pod5_random_access-1.0.3-cp311-cp311-manylinux_2_34_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pod5_random_access-1.0.3-cp310-cp310-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pod5_random_access-1.0.3-cp310-cp310-manylinux_2_34_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file pod5_random_access-1.0.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ad2796e831b1601af355cd90f3281950b7bdb9af4346c6844ff9e54a18687b2a
MD5 d772e9e167f3d9c3f5c2a50ef4e51dab
BLAKE2b-256 59529c4ef381d66a40d686fc4bf28ec43833b0c9648169aaccc622eee85c4a61

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp313-cp313-win_amd64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7e5e944544c1d13f196f06e3b61dd0cadc00b7276b5125a936ed47e3303ed63f
MD5 369db53291c9d3584bd72e0384df03ce
BLAKE2b-256 1f1597d9f788980808f0642baac31bb700b522bba86e5a785e96e2734b860aae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e2c06ca86118de42d8dcdb698af9f30deb22e4f1a4b8e1e8d93fee825fcb3e06
MD5 d82a145d817d8e757145137f31dcf8cf
BLAKE2b-256 8646fd4d58439802631674583ec2de51656584bd5c441aecd9ab8ece0711c310

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp312-cp312-win_amd64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 568779949086004d2e02dd4fce0a86e93da896d6bd02f4cac9af7e3b25cd4584
MD5 9ef8efc7352f9f1b4027763e9bdfcfdb
BLAKE2b-256 d3dc29f2065231c574b9434000698b317a7b29fb176060d82ee1b7617bd63ece

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6c62f0842c5846cb0571787d0280c3755d4ef674cb394335621013d2681db4a1
MD5 a0bbd108ce01d6808b55c84c2f2846cb
BLAKE2b-256 89ad0ea10779833bc495468b59af84765bd4f365d4fa8ed20f9fe3588661b33e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp311-cp311-win_amd64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 41f052a8d746aab178d790cca54fca57c1b8fc16b98e7f9b43a8a853b5ee3a9b
MD5 ccc8f86cf2ecaec8a58e2fe288114d3a
BLAKE2b-256 63c1c59be5e571a9a7375d6751ba6d2516e5f231dccf9ba82ef6619bfe2061cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c2035b98537be313eef2b94bb62bbd075177022c48fb4e22606d602276397863
MD5 2d7b2de8c82a9444d5f3eb06c1e1978e
BLAKE2b-256 cea7fd13e68a47d2a00ce4e38cf213a85e5536a9f2767b1fda362ebb8a6cd315

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp310-cp310-win_amd64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pod5_random_access-1.0.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 26745275cb715a39932f773326781767ce412c307ae34cf23c72d65970c647ca
MD5 95c3d47da3301c4ae0f4daa5c8ad878c
BLAKE2b-256 c0748f178831302b7d173665e9e9ff0606ee47e0a7118f981efd8a074edc1d5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.3-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on NoguchiRyo/pod5-random-access

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page