Skip to main content

Module align

Module align 

Source
Expand description

One reader over both alignment formats.

BAM and CRAM answer the same questions with the same types — the same EntriesRequest, the same BamRecord, the same four read paths — because the CRAM reader rebuilds BAM records rather than inventing a second entry type. What is left over is the dispatch, and this is it.

§Why an enum rather than a trait

The instinct is a trait, and it does not survive contact with the walks. bam::LocusWalk and cram::LocusWalk carry different plans — the BAM one a set of decompressed-chunk cursors, the CRAM one nothing of the sort — and the borrowing iterators over them carry lifetimes. An object-safe trait would mean boxing the plan and giving up the plain Iterator a Rust caller gets today, to abstract over a set that has two members and will not grow a third. A match costs one predictable branch per window, not per record.

This is what the Python layer holds, which is why gwseq_io.BamReader reads CRAM too and reports which it has through its type — exactly as BbiReader already serves bigWig and bigBed.

Enums§

AlignmentWalk
A walk over either format’s loci or windows.
Alignments
A BAM or a CRAM, opened for reading.