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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

pod5_random_access-1.0.2-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.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8aa9ebc99a3455eaa690b989d076e095833eadda5e8bd6c7c929f142cc200520
MD5 70a7c5a8ce80855ad2de1d653a9b5607
BLAKE2b-256 1b05e0aa62a510d4c84ae611177555ae84961caaec8267b0e87fabbd2cb8d412

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0b04bda4a2a8029cbf165595a8934617b1aeffbe4e69921b03055b8cb8fe131d
MD5 608cd37d4672a9d8291b1acf9f5a8bcd
BLAKE2b-256 cf754a15dbabeb1c0911a4170e15f165c1fa23b302bb0b7e9cf46e2ea7f54ed2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 12dc0ae66230ecf27df25ecd0cb0b0053e93772c0e53975eb85bb56a80b1ebe5
MD5 78ad4f5dbd7b8c4ff1539d88614d2abc
BLAKE2b-256 21bea616ffa5f9de2e95c299f81847bed87272f148ffc4ad8b0b8669da760a89

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4efc7c0744df250955c24f863f7e06fa3ee3c6cf338649cca233b806a2eca6d0
MD5 d1ada6050ec01defd0fb2389a0a299b0
BLAKE2b-256 9e3d02e7c12912ad35894db638b638d1aef05eb151a23b9d9b6828c606c2233a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e50b71549fbd642e974aadb082dd4fb6a502cf5a7fb6b4be9a862a51b178cf3d
MD5 7890a321339164d2850a4978f1c8c6fe
BLAKE2b-256 8c8265c1672284d2719d8289f58edd3ad4198ffdfd9cc974e85d6478f5824f67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b385a73ff98c26dacf61b64732f9120e7d2c7fd2974f219da066083c9f68a469
MD5 2c6b4fd87b32fdaf117b19dd00549fd5
BLAKE2b-256 ca3fd1efeeb7f2c42cf126b1eea514d96e7e3f96e9ea69487a2ee8ecc7f37631

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a2c33cd9a2a95418a999ddad14c51f1263eb04410b555204f633c34bec816257
MD5 a448bde460eeedae45cd465ac3a8d24f
BLAKE2b-256 50a56a7c477996a447dba5863728ae6d1f7bc48a7fa85efdaa843f539e360896

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2f5f37478c2ed37ced0a88d9d01d832ec8cbf80b795af082178f08b772129ac8
MD5 17a47a2a673005ec50ffb42087bf98c4
BLAKE2b-256 1dda1ad3dbd78323d0cb6025b5e929b76e69c5dc1b7058192592167dd871e974

See more details on using hashes here.

Provenance

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