Add experimental pileup column aggregation API#1
Open
sstadick wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary 🤖
This is an experimental API branch in my seqair fork motivated by perbase's seqair integration. perbase currently materializes each
PileupColumnand then walks every alignment again to compute command-specific row summaries: depth, base counts, insertion/deletion/refskip counts, failed-read counts, and eventually mate-aware summaries.This PR explores making seqair more useful for those downstream pileup consumers by adding:
PileupSummaryonPileupColumn, computed while the column is built.BaseCountsandPileupOpCountshelpers.PileupEngine::pileup_with(...), an opt-in custom accumulator path that observes the same post-max_depthalignments aspileups()but does not need to materialize aPileupColumn.PileupColumnContextpassed to accumulator finish hooks.The existing lending
PileupEngine::pileups()API is preserved; internally it now uses a materializing accumulator so the materialized path and custom path share the same traversal/max-depth semantics.Why
For perbase non-mate
base-depth, the custom accumulator can compute per-row counts directly while seqair is already visiting active records. In the sibling perbase branch/PR, this avoids a downstream second pass overcolumn.raw_alignments()and avoids allocating the per-column alignmentVecfor simple counting output.This also provides an extras-based way to model count/fail/drop style downstream semantics without adding a first-class seqair
ReadDispositionAPI yet: dropped reads are rejected byCustomizeRecordStore, while kept reads carry caller-defined extras that the accumulator can inspect throughRecordStore.Notes / API choices
PileupColumn::summary()describes exactly the emitted alignments exposed byraw_alignments().max_depthtruncation.max_depthalignments thatpileups()would expose.Validation
Ran locally on macOS with SDK env for htslib-backed tests:
Results:
-D warningsDownstream experiment
perbase PR sstadick/perbase#108 uses
PileupEngine::pileup_withfor non-matebase-depth --seqair-pileup. On the HG00157 chr1 10 Mb BAM subset, the new accumulator path produced byte-for-byte identical output to htslib.Latest perbase benchmark summary from that PR:
base-depthhtslib:5.147 ± 0.461 sbase-depthseqair accumulator:5.104 ± 0.166 s150f61653f0cd9225787248fecbbd9d46bde1a9644632bcba8f1898ee780c572