A noodles-based htsget client that lazily deserializes alignment records in memory. It provides a Rust API with Python bindings, so you can consume remote CRAM/BAM records over the network without storing them locally.
Documentation: https://cmdoret.github.io/htslurp/
pip install htslurpimport htslurp
records = htslurp.stream_records(
"https://htsget.ga4gh.org/reads",
"giab.NA12878",
"CRAM",
region="11:4900000-5000000",
)
header_text = records.header.decode()
for line in records:
fields = line.decode().split("\t")
# ... or feed `line.decode()` and a pysam.AlignmentHeader built from
# `header_text` to pysam.AlignedSegment.fromstring.See the quickstart for more.
The aim is to provide a convenient interface to consume remote CRAM/BCF records over the network without storing them locally. The noodles crate fetches a binary stream from the server and builds a reader over it that lazily instantiates records.
flowchart LR
htsget[htsget-server] -->|bytes| Reader
Reader -->|Cram records| python
This project requires:
To build the python package:
just buildTo install in editable mode for development:
just developTo preview the docs locally:
just docs