Skip to content

Fix SamLocusIterator so that read position is not incorrectly offset …#1758

Merged
tfenne merged 4 commits intodevfrom
fix-accumulateIndels-readBase-drift
Apr 11, 2026
Merged

Fix SamLocusIterator so that read position is not incorrectly offset …#1758
tfenne merged 4 commits intodevfrom
fix-accumulateIndels-readBase-drift

Conversation

@tfenne
Copy link
Copy Markdown
Member

@tfenne tfenne commented Mar 24, 2026

…after transiting insertions that fail the base quality check.

Description

This fixes a bug in SamLocusIterator where during accumulation of indels, the position in the read (readBase) was incorrectly failling to count indels that failed a base quality check. The result of this is that indels later in the read were then accumulated with incorrect read offsets.

This affects any tool that uses the pileup engine with a base quality filter and cares about indels!

The added test fails without the accompanying change to SamLocusIterator.

…after transiting insertions that fail the base quality check.
Copy link
Copy Markdown
Contributor

@yfarjoun yfarjoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore
please add an assert that "proves" that the code evaluates the assertion on L848.

Also a few nits to make the documentation less time-dependent.

Comment thread src/test/java/htsjdk/samtools/util/SamLocusIteratorTest.java Outdated
Comment thread src/test/java/htsjdk/samtools/util/SamLocusIteratorTest.java Outdated
Comment thread src/test/java/htsjdk/samtools/util/SamLocusIteratorTest.java Outdated
for (final SamLocusIterator.RecordAndOffset rao : li.getInsertedInRecord()) {
// The second insertion's first base is at read offset 12.
// Before the fix, the drifted readBase would report offset 11.
Assert.assertEquals(rao.getOffset(), 12,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please assert that we got to here (i.e. that the loops were not all trivially empty)

tfenne and others added 2 commits March 24, 2026 15:01
@tfenne tfenne requested a review from yfarjoun March 24, 2026 21:14
Comment thread src/test/java/htsjdk/samtools/util/SamLocusIteratorTest.java Outdated
Co-authored-by: Nils Homer <nh13@users.noreply.github.com>
@tfenne tfenne changed the base branch from master to dev April 11, 2026 01:36
@tfenne tfenne merged commit 5408b4d into dev Apr 11, 2026
3 checks passed
@tfenne tfenne deleted the fix-accumulateIndels-readBase-drift branch April 11, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants