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.0-cp313-cp313-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pod5_random_access-1.0.0-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.0-cp312-cp312-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pod5_random_access-1.0.0-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.0-cp311-cp311-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pod5_random_access-1.0.0-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.0-cp310-cp310-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pod5_random_access-1.0.0-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.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c7864a52f9110d3723ba8a5d05ab2fba5318c899a7c566d3977c250f12158fb7
MD5 3cae55c64513d81416c10746abb815ad
BLAKE2b-256 7d1f85982e7c5fd3d72b677db9ef221e0d4f60f181de7c84c229651eeeea84c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e7c2eb435b675087ece1155985a7f8d75ec961ff030edfee6014739f8e700dba
MD5 f069483ceecfa0448837460fe67f3ba8
BLAKE2b-256 c4862ef54c9edd270b7e122a64c4b5a1662f4841f1d019b9d3ea7f19aab0d444

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 304e3bed8672acb5a5cd4bbaae875d2b4607d8d93f236bb2a619647802696470
MD5 e35691b97bf933d90f6d8af70fa4d57c
BLAKE2b-256 7d6386bc53d4c45b76486ebb63c81c744a8a891a0f0f33c62c03af0c7f16365b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 791841a4780871b5229c411522e837f1076e80ebb5c9d9181a527d47129cf166
MD5 14b607f9561ab0fc48f720de1745e60a
BLAKE2b-256 de185e921b25e0319ceb81303850d4b61108bed83c559f2b6f40be1b84bb857d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 46246b63feb3acfe0be03e4e7b388caa8f695cbdf7eab840a4c839a6382da408
MD5 8eb178bdf56a426f4dd696b7e24cc2ef
BLAKE2b-256 04b2aea44b7c1ebb537033ef0758f02f1241742fee87b1ab97b611e3c6834fcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9ba0d86f4ba4b0f7923712b906807215cc71a77ffd4fa87a45b4006e02a80a76
MD5 2638977b703474160152827a96f0120a
BLAKE2b-256 89e0031298ecd58f9e918cd9eb14e043015842445f496bf162d12533bcd3a968

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 317ecd6106510cd1505b5984b7617c6107df6cfc4e8c5a6e073af39cb54bfc99
MD5 082b5cc1c972cbe015e875979b823a70
BLAKE2b-256 e9ba89a46fd84bd610b99434bf2c093a9ba1b88fc922fd126fc1654ee2d8385e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 85c3a77abc7beb67c637fc6e04dad1f259c83fe0e8a998310f64efd32da6f5f8
MD5 8c2de35bf6894eab521b614306154dc4
BLAKE2b-256 85c594758f87963efa4e8b1cf184adabab48aa0d9b796d5f6546ea2e476a6643

See more details on using hashes here.

Provenance

The following attestation bundles were made for pod5_random_access-1.0.0-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