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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ trait PileupBuilder extends PileupParameters {
testAndAdd(DeletionEntry(rec, deletionPosition - 1))
} else { // This site must be a matched site within the read.
testAndAdd(BaseEntry(rec, offset - 1))
// Also check to see if the subsequent base represents an insertion.
if (offset < rec.length - 1 && rec.refPosAtReadPos(offset + 1) == 0) testAndAdd(InsertionEntry(rec, offset))
// Also check to see if any subsequent base represents an insertion.
if (rec.end > pos && rec.refPosAtReadPos(offset + 1) == 0) testAndAdd(InsertionEntry(rec, offset))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class PileupBuilderTest extends UnitSpec {
builder.addFrag(name = "q3", start = 101, cigar = "31M9I10M").foreach(_.bases = "G" * ReadLength)
builder.addFrag(name = "q4", start = 101, cigar = "30M9D20M").foreach(_.bases = "T" * ReadLength)
builder.addFrag(name = "q5", start = 141, cigar = "10I40M" ).foreach(_.bases = "N" * ReadLength)
builder.addFrag(name = "q6", start = 201, cigar = "47M3S" ).foreach(_.bases = "N" * ReadLength)

val source = builder.toSource
val piler = PileupBuilder(source, accessPattern = accessPattern, mappedPairsOnly = false)
Expand Down Expand Up @@ -170,6 +171,19 @@ class PileupBuilderTest extends UnitSpec {
p4.iterator.collect{ case x: InsertionEntry => x }.map(_.rec.name).next() shouldBe "q5"
p4.baseIterator.toSeq should contain theSameElementsAs p4.withoutIndels.iterator.toSeq

// Locus with the remainder of a read that is soft-clipped
val p5 = piler.pileup(Chr1, 247)
p5.depth shouldBe 1
p5.iterator.size shouldBe 1 // should not report an insertion due to the remaining soft-clipped bases
p5.baseIterator.size shouldBe 1
p5.baseIterator.toSeq should contain theSameElementsAs p5.withoutIndels.iterator.toSeq

// Locus at the site of a single read that is soft-clipped
val p6 = piler.pileup(Chr1, 248)
p6.depth shouldBe 0
p6.iterator.size shouldBe 0
p6.baseIterator.size shouldBe 0
p6.baseIterator.toSeq should contain theSameElementsAs p5.withoutIndels.iterator.toSeq
clintval marked this conversation as resolved.
Show resolved Hide resolved
source.safelyClose()
piler.safelyClose()
}
Expand Down
Loading