Reading POD5 Files¶
escapepod.Reader gives efficient, memory-mapped access to a single POD5
file. escapepod.DatasetReader presents many files as one stream.
Opening a file¶
1 2 3 | |
Reader accepts a str or any os.PathLike (e.g. pathlib.Path). Use it as a
context manager so the underlying file is released promptly:
1 2 3 4 | |
File information¶
Reader exposes file-level metadata as properties:
1 2 3 4 5 6 7 8 9 | |
Iterating over reads¶
Iterating the reader yields ReadData objects — one per
read, metadata only:
1 2 | |
reader.reads() returns the same reads as a list. Pass a selection of read
IDs to restrict it:
1 2 3 | |
By default a requested ID that isn't in the file raises KeyError; pass
missing_ok=True to silently skip it.
reader.read_ids() returns just the IDs as a list[str].
Looking up specific reads¶
1 2 3 | |
Repeated lookups build and reuse an in-memory index. Call
reader.build_index() up front to pay that cost once (it returns the number of
reads indexed); reader.has_index reports whether it's built.
Accessing signal data¶
Signal is stored separately from metadata and is fetched on demand from the
reader — it is not an attribute of ReadData. Request it per read:
1 2 3 4 | |
get_signal returns raw ADC counts as int16. get_signal_pa applies the
read's calibration ((adc + offset) * scale) and returns float32 picoamps.
For many reads at once, the bulk variants decode in parallel and return
(read_id, signal) tuples:
1 2 3 4 5 | |
reader.prefetch_signal() is an optional hint that warms the signal region of
the file; reader.byte_count(read) reports the compressed on-disk size of a
read's signal.
Reads as a DataFrame¶
Pull every read's metadata into a table in one call:
1 2 3 | |
All three accept the same selection / missing_ok arguments as reads().
Columns include read_id, channel, well, num_samples,
calibration_offset, calibration_scale, end_reason, and the rest of the
read metadata fields.
1 2 3 | |
The ReadData object¶
Each read is a ReadData with the POD5 read fields as read-only properties:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
If you already hold a raw ADC array, read.calibrate_signal_array(adc) converts
it to picoamps using that read's calibration:
1 2 | |
Reading many files (DatasetReader)¶
DatasetReader reads a single file, a directory (scanned for *.pod5), or a
list mixing both, and presents every read across all files as one stream — the
escapepod analogue of pod5.DatasetReader.
1 2 3 4 5 6 7 8 | |
Control the directory scan with keyword arguments:
1 | |
DatasetReader offers the same reading surface as Reader —
reads()/read_ids(), to_dict()/to_pandas()/to_polars(),
get_signal()/get_signal_pa() and their bulk get_signals* forms,
byte_count(), iteration, and len() — plus paths, file_count,
read_count, and run_infos properties.