Skip to content

Commit 5894742

Browse files
committed
Make includeMapPositionsOutsideFrInsert in PileupBuilder intuitively correct
1 parent 3a74fd2 commit 5894742

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/main/scala/com/fulcrumgenomics/bam/pileup/PileupBuilder.scala

+6-9
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,11 @@ object PileupBuilder {
116116
)
117117
}
118118

119-
/** Returns true if <rec> is in a mapped FR pair but the position <pos> is outside the insert coordinates of <rec>.
120-
* Returns false if <rec> is in a mapped FR pair and the position <pos> is inside the insert coordinates of <rec> or
121-
* <rec> is not in a mapped FR pair.
122-
*/
123-
private def positionIsOutsideFrInsert(rec: SamRecord, refIndex: Int, pos: Int): Boolean = {
124-
rec.isFrPair && {
119+
/** Returns true if <rec> is in a mapped FR pair and the position <pos> is inside the insert coordinates of <rec>. */
120+
private def positionIsInsideFrInsert(rec: SamRecord, refIndex: Int, pos: Int): Boolean = {
121+
refIndex == rec.refIndex && rec.isFrPair && {
125122
val (start, end) = Bams.insertCoordinates(rec)
126-
rec.refIndex == refIndex && pos >= start && pos <= end
123+
pos >= start && pos <= end
127124
}
128125
}
129126

@@ -200,8 +197,8 @@ trait PileupBuilder extends PileupParameters {
200197
if (compare) compare = this.acceptRecord(rec)
201198
if (compare) compare = rec.end >= pos
202199
if (compare) compare = rec.start <= pos || PileupBuilder.startsWithInsertion(rec)
203-
if (compare) compare = if (!includeMapPositionsOutsideFrInsert && rec.isFrPair) {
204-
PileupBuilder.positionIsOutsideFrInsert(rec, refIndex = refIndex, pos = pos)
200+
if (compare) compare = if (rec.paired && !includeMapPositionsOutsideFrInsert) {
201+
PileupBuilder.positionIsInsideFrInsert(rec, refIndex = refIndex, pos = pos)
205202
} else { compare }
206203
compare
207204
}

0 commit comments

Comments
 (0)