Skip to content

Commit 6956ac4

Browse files
committed
Revert back to the original isFrPair filtering logic and document better
1 parent 4232757 commit 6956ac4

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ object PileupBuilder {
6161
/** Allow records flagged as supplementary alignments to contribute to a pileup by default. */
6262
val includeSupplementalAlignments: Boolean = false
6363

64-
/** Exclude any record of an FR pair where the site requested is outside the insert by default. */
64+
/** For FR pairs only, determine if we should keep the pair of reads if the site requested is outside of the
65+
* insert. By default this filter is set to <false> which means for FR pairs where R1 and R2 overlap each other
66+
* and *extend* past the start coordinates of their mate, the pair will be filtered out if the position requested
67+
* overlaps the end of either read in the span that is beyond the start coordinate of the read's mate.
68+
*
69+
* See the following GitHub issue comment for a visualization of when this filter applies:
70+
*
71+
* - https://github.com/fulcrumgenomics/fgbio/issues/980#issuecomment-2075049301
72+
*/
6573
val includeMapPositionsOutsideFrInsert: Boolean = false
6674
}
6775

@@ -197,7 +205,7 @@ trait PileupBuilder extends PileupParameters {
197205
if (compare) compare = this.acceptRecord(rec)
198206
if (compare) compare = rec.end >= pos
199207
if (compare) compare = rec.start <= pos || PileupBuilder.startsWithInsertion(rec)
200-
if (compare) compare = if (rec.paired && !includeMapPositionsOutsideFrInsert) {
208+
if (compare) compare = if (!includeMapPositionsOutsideFrInsert && rec.isFrPair) {
201209
PileupBuilder.positionIsInsideFrInsert(rec, refIndex = refIndex, pos = pos)
202210
} else { compare }
203211
compare

src/test/scala/com/fulcrumgenomics/bam/pileup/PileupBuilderTest.scala

-18
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,6 @@ class PileupBuilderTest extends UnitSpec {
343343
piler.safelyClose()
344344
}
345345

346-
it should "exclude records that appear to be in an FR pair but are on different chromosomes" in {
347-
val builder = new SamBuilder(readLength = ReadLength, sd = Some(TestSequenceDictionary), sort = Some(Coordinate))
348-
349-
builder.addPair(name = "q1", contig = Chr1Index, contig2 = Some(Chr2Index), start1 = 100, start2 = 125)
350-
351-
val source = builder.toSource
352-
val piler = PileupBuilder(source, accessPattern = accessPattern, includeMapPositionsOutsideFrInsert = false)
353-
354-
piler.pileup(Chr1, 100).depth shouldBe 0
355-
piler.pileup(Chr1, 100 + ReadLength - 1).depth shouldBe 0
356-
357-
piler.pileup(Chr2, 125).depth shouldBe 0
358-
piler.pileup(Chr2, 125 + ReadLength - 1).depth shouldBe 0
359-
360-
source.safelyClose()
361-
piler.safelyClose()
362-
}
363-
364346
it should "not filter out records where a position is outside what might look like an 'insert' for a non-FR pair" in {
365347
val builder = new SamBuilder(readLength = ReadLength, sd = Some(TestSequenceDictionary), sort = Some(Coordinate))
366348

0 commit comments

Comments
 (0)