diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2Engine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2Engine.java index 40aae82e6c0..4375fcd2b98 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2Engine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2Engine.java @@ -309,7 +309,7 @@ private static List altQuals(final ReadPileup pileup, final byte refBase, result.add(indelQual(1)); } else if (pe.getBase() != refBase && pe.getQual() > MINIMUM_BASE_QUALITY) { final GATKRead read = pe.getRead(); - final int mateStart = read.mateIsUnmapped() ? Integer.MAX_VALUE : read.getMateStart(); + final int mateStart = (!read.isProperlyPaired() || read.mateIsUnmapped()) ? Integer.MAX_VALUE : read.getMateStart(); final boolean overlapsMate = mateStart <= position && position < mateStart + read.getLength(); result.add(overlapsMate ? (byte) FastMath.min(pe.getQual(), pcrErrorQual/2) : pe.getQual()); } diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2IntegrationTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2IntegrationTest.java index 08576deed9d..7df93f63b2c 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2IntegrationTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/mutect/Mutect2IntegrationTest.java @@ -403,6 +403,21 @@ public void testReadsThatConsumeZeroReferenceReads() throws Exception { runCommandLine(args); } + // make sure that unpaired reads that pass filtering do not cause errors + // in particular, the read HAVCYADXX150109:1:1109:11610:46575 with SAM flag 16 fails without the patch + @Test + public void testUnpairedReads() throws Exception { + final String bamWithUnpairedReads = toolsTestDir + "unpaired.bam"; + final File outputVcf = createTempFile("output", ".vcf"); + final String[] args = { + "-I", bamWithUnpairedReads, + "-" + M2ArgumentCollection.TUMOR_SAMPLE_SHORT_NAME, "SM-612V3", + "-R", b37_reference_20_21, + "-O", outputVcf.getAbsolutePath() + }; + runCommandLine(args); + } + // some bams from external pipelines use faulty adapter trimming programs that introduce identical repeated reads // into bams. Although these bams fail the Picard tool ValidateSamFile, one can run HaplotypeCaller and Mutect on them // and get fine results. This test ensures that this remains the case. The test bam is a small chunk of reads surrounding diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam b/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam new file mode 100644 index 00000000000..ea166f4d50c Binary files /dev/null and b/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam differ diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam.bai b/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam.bai new file mode 100644 index 00000000000..85a16628109 Binary files /dev/null and b/src/test/resources/org/broadinstitute/hellbender/tools/unpaired.bam.bai differ