Skip to content

Commit

Permalink
Make includeMapPositionsOutsideFrInsert in PileupBuilder intuitively …
Browse files Browse the repository at this point in the history
…correct
  • Loading branch information
clintval committed Apr 22, 2024
1 parent 3a74fd2 commit 5894742
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ object PileupBuilder {
)
}

/** Returns true if <rec> is in a mapped FR pair but the position <pos> is outside the insert coordinates of <rec>.
* Returns false if <rec> is in a mapped FR pair and the position <pos> is inside the insert coordinates of <rec> or
* <rec> is not in a mapped FR pair.
*/
private def positionIsOutsideFrInsert(rec: SamRecord, refIndex: Int, pos: Int): Boolean = {
rec.isFrPair && {
/** Returns true if <rec> is in a mapped FR pair and the position <pos> is inside the insert coordinates of <rec>. */
private def positionIsInsideFrInsert(rec: SamRecord, refIndex: Int, pos: Int): Boolean = {
refIndex == rec.refIndex && rec.isFrPair && {
val (start, end) = Bams.insertCoordinates(rec)
rec.refIndex == refIndex && pos >= start && pos <= end
pos >= start && pos <= end
}
}

Expand Down Expand Up @@ -200,8 +197,8 @@ trait PileupBuilder extends PileupParameters {
if (compare) compare = this.acceptRecord(rec)
if (compare) compare = rec.end >= pos
if (compare) compare = rec.start <= pos || PileupBuilder.startsWithInsertion(rec)
if (compare) compare = if (!includeMapPositionsOutsideFrInsert && rec.isFrPair) {
PileupBuilder.positionIsOutsideFrInsert(rec, refIndex = refIndex, pos = pos)
if (compare) compare = if (rec.paired && !includeMapPositionsOutsideFrInsert) {
PileupBuilder.positionIsInsideFrInsert(rec, refIndex = refIndex, pos = pos)
} else { compare }
compare
}
Expand Down

0 comments on commit 5894742

Please sign in to comment.