Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PileupBuilder should not report insertions when checking the final mapped base before soft-clipping #956

Merged
merged 3 commits into from
Jan 17, 2024

Conversation

jrm5100
Copy link
Contributor

@jrm5100 jrm5100 commented Jan 5, 2024

I was using the PileupBuilder and ran into an error when attempting to collect an insertion sequence:

case entry: InsertionEntry if entry.rec.start < pos  =>
  // Get insertion bases
  val insStart     = entry.rec.readPosAtRefPos(pos, returnLastBaseIfDeleted = true)
  val insEnd       = entry.rec.readPosAtRefPos(pos + 1, returnLastBaseIfDeleted = true)
  val alleleString = entry.rec.basesString.substring(insStart - 1, insEnd - 1)

The call to substring failed because insEnd was 0.

I tracked this down to the PileupBuilder making an incorrect check. rec.length includes soft-clipped bases, so checking offset < rec.length - 1 will always be true at a pileup for the last mapped base as long as there is at least 1 soft-clipped base. The second half of the check (rec.refPosAtReadPos(offset + 1)) will also be true, but for the wrong reason (it's soft-clipped, not an insertion).

I shoehorned in a test where it seems appropriate.

@clintval clintval self-requested a review January 5, 2024 19:43
@clintval clintval self-assigned this Jan 5, 2024
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (abb741b) 95.62% compared to head (bc462fb) 95.62%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #956   +/-   ##
=======================================
  Coverage   95.62%   95.62%           
=======================================
  Files         126      126           
  Lines        7355     7355           
  Branches      512      528   +16     
=======================================
  Hits         7033     7033           
  Misses        322      322           
Flag Coverage Δ
unittests 95.62% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@clintval clintval changed the title [bugfix] PileupBuilder no longer reports insertions when checking the final mapped base before soft-clipping PileupBuilder should not report insertions when checking the final mapped base before soft-clipping Jan 17, 2024
Copy link
Member

@clintval clintval left a comment

Choose a reason for hiding this comment

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

Took me a bit to walk through the logic using the underlying functions. This does indeed appear to be a bug fix! Thanks for this @jrm5100!

@clintval clintval assigned jrm5100 and unassigned clintval Jan 17, 2024
@clintval clintval merged commit afa634e into fulcrumgenomics:main Jan 17, 2024
4 checks passed
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.

2 participants