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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

pod5_random_access-1.0.4-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.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 810cd98eb6d1510eb6f7873af3c8883a90e213e3a76739cf7f55e7c147743680
MD5 78c33f039d1de58f5e31c2f32d17ab7d
BLAKE2b-256 67058dca337f62c4cadd7067a54c5f00102a377e98c539cce15dd5fcc1f107c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ccce9ebff3fc6892c1541bbf1862b03d95b4d2d5c26d29126940912265bead1c
MD5 398e0d98f80897476cb7efe70efdd3c3
BLAKE2b-256 5cc47c583070828108974dfb1ee694dae76ac6ec0e9754a12c849e95a8a772d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b7c5214df546ac2db1d15100bf3b0147d0665a3e09166ef51ec8dcf41152a7bb
MD5 b1540e7ebf6360dc5a40f2301068a954
BLAKE2b-256 e5cda5ac19b0b2dde682ecc3b055d6eb6b4f859d9b3983174e153c94c542d9fa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 210db4fd9091638a68725ac1ae8b6a5d7ce23db2e7f8f73e92af2a5c0ad0fd87
MD5 d8555b55d9bd681f236fedd31d331c37
BLAKE2b-256 40f14cbc5edc9507b10423e8efef7cf4c30547981e847b45aae9045733e28ba5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 919c617cb1c389b29a346c8cfd99e07e94d0e4f2c3cf5bb99034409e5238dca9
MD5 2d010c36a09e981dc6453e4362bd4d8d
BLAKE2b-256 9926c4df1cd290ee68e0dcd7b80de8826ad5463a6abb4b10eeb544089cdd9059

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a77f655a6d0e9df133157ac6064c7b20aa8a34c100cb20bae9cc48c0feac50cf
MD5 cce0e1d27511efffb00ecc937aa7ca67
BLAKE2b-256 72a8b1b89f461e6b8286aaa43b18eac64747312c4255aca7d622702c190b7d21

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c89371e09062da84287c64158ecc19940f0c5980ebbbcdede85ea8d13a387c03
MD5 d941cffd65e91746d8f82a3c04001ee3
BLAKE2b-256 0a815228c34cd08d3b2a2239a222f705a4e581a2a682dcd9b474b6810ddb71d1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pod5_random_access-1.0.4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b0781ffe0854163356df0c23a08499a714af1ebd59c7a407d47fcded1d039082
MD5 4313053763d3e4b6a9ab66c58f4fcb98
BLAKE2b-256 e6f8bcdd44b1b7d5a39631ee915446b29218e6c5f8e3fd01e1784b6dedc3d366

See more details on using hashes here.

Provenance

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