From be9fcba54651d93da4a4d1c4aa05147e1ae3dd2c Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Sun, 7 Oct 2012 16:32:48 -0400 Subject: [PATCH] Don't allow triggering of polyploid consensus creation in regions where there is more than one het, as it just doesn't work properly. We could probably refactor at some point to make it work, but it's not worth doing that now (especially as it should be rare to have multiple proximal known hets in a single sample exome). --- .../reducereads/SlidingWindow.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java index e39edf956..6fdf85317 100644 --- a/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java +++ b/protected/java/src/org/broadinstitute/sting/gatk/walkers/compression/reducereads/SlidingWindow.java @@ -55,7 +55,7 @@ public class SlidingWindow { private final int nContigs; - private boolean allowPolyploidReduction; + private boolean allowPolyploidReductionInGeneral; /** * The types of synthetic reads to use in the finalizeAndAdd method @@ -117,7 +117,7 @@ public class SlidingWindow { this.hasIndelQualities = hasIndelQualities; this.nContigs = nContigs; - this.allowPolyploidReduction = allowPolyploidReduction; + this.allowPolyploidReductionInGeneral = allowPolyploidReduction; } /** @@ -207,8 +207,9 @@ public class SlidingWindow { finalizedReads = closeVariantRegions(regions, false); List readsToRemove = new LinkedList(); - for (GATKSAMRecord read : readsInWindow) { // todo -- unnecessarily going through all reads in the window !! Optimize this (But remember reads are not sorted by alignment end!) - if (read.getSoftEnd() < getStartLocation(windowHeader)) { + final int windowHeaderStartLoc = getStartLocation(windowHeader); + for (final GATKSAMRecord read : readsInWindow) { // todo -- unnecessarily going through all reads in the window !! Optimize this (But remember reads are not sorted by alignment end!) + if (read.getSoftEnd() < windowHeaderStartLoc) { readsToRemove.add(read); } } @@ -489,7 +490,7 @@ public class SlidingWindow { syntheticRead.add(base, count, qual, insQual, delQual, rms); } - private List compressVariantRegion(int start, int stop) { + private List compressVariantRegion(final int start, final int stop, final boolean disallowPolyploidReductionAtThisPosition) { List allReads = new LinkedList(); // Try to compress into a polyploid consensus @@ -499,7 +500,8 @@ public class SlidingWindow { boolean foundEvent = false; Object[] header = windowHeader.toArray(); - if ( allowPolyploidReduction ) { // foundEvent will remain false if we don't allow polyploid reduction + // foundEvent will remain false if we don't allow polyploid reduction + if ( allowPolyploidReductionInGeneral && !disallowPolyploidReductionAtThisPosition ) { for (int i = start; i<=stop; i++) { nHaplotypes = ((HeaderElement) header[i]).getNumberOfHaplotypes(MIN_ALT_BASE_PROPORTION_TO_TRIGGER_VARIANT); if (nHaplotypes > nContigs) { @@ -558,8 +560,8 @@ public class SlidingWindow { * @return all reads contained in the variant region plus any adjacent synthetic reads */ @Requires("start <= stop") - protected List closeVariantRegion(int start, int stop) { - List allReads = compressVariantRegion(start, stop); + protected List closeVariantRegion(final int start, final int stop, final boolean disallowPolyploidReductionAtThisPosition) { + List allReads = compressVariantRegion(start, stop, disallowPolyploidReductionAtThisPosition); List result = (downsampleCoverage > 0) ? downsampleVariantRegion(allReads) : allReads; result.addAll(addToSyntheticReads(windowHeader, 0, stop, false)); @@ -579,7 +581,7 @@ public class SlidingWindow { if (stop < 0 && forceClose) stop = windowHeader.size() - 1; if (stop >= 0) { - allReads.addAll(closeVariantRegion(start, stop)); + allReads.addAll(closeVariantRegion(start, stop, regions.size() > 1)); lastStop = stop; } }