diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/AssemblyBasedCallerUtils.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/AssemblyBasedCallerUtils.java index 5f24b668884..d10a27af4ad 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/AssemblyBasedCallerUtils.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/AssemblyBasedCallerUtils.java @@ -444,6 +444,9 @@ public static AssemblyResultSet applyPileupEventsAsForcedAlleles(final AssemblyR final AssemblyResultSet assemblyResultSet, final List pileupAllelesFoundShouldFilter, final List pileupAllelesPassingFilters, final boolean debug) { List haplotypesWithFilterAlleles = new ArrayList<>(); + // IF we find pileup alleles that we want to filter... AND we are not generating the partially determined haplotypes, + // we resort to a messy approach where we filter alleles by throwing away every haplotype supporting an allele. This is + // very dangerous since this could easily destroy phased variants with the haplotype. if (!pileupAllelesFoundShouldFilter.isEmpty() && !argumentCollection.pileupDetectionArgs.generatePDHaplotypes) { // TODO this is a bad algorithm for bad people for(VariantContext delVariant : pileupAllelesFoundShouldFilter) { diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java index 86a5da37b3c..cde323305cf 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerEngine.java @@ -671,6 +671,7 @@ public List callRegion(final AssemblyRegion region, final Featur .filter(v -> PileupBasedAlleles.passesFilters(hcArgs.pileupDetectionArgs, v)) .collect(Collectors.toList()); + // Regenerate the list of AllVariationEvents, filtering out assembled variants that must be filtered according to the pileupcaller code. final SortedSet allVariationEvents = new TreeSet<>( AssemblyResultSet.HAPLOTYPE_VARIANT_CONTEXT_COMPARATOR); allVariationEvents.addAll(untrimmedAssemblyResult.getVariationEvents(hcArgs.maxMnpDistance).stream() @@ -678,12 +679,14 @@ public List callRegion(final AssemblyRegion region, final Featur && filterAllle.getReference().equals(outerVC.getReference()) && filterAllle.getAlternateAllele(0).equals(outerVC.getAlternateAllele(0))); }).collect(Collectors.toList())); + // Add any new pileupcaller alleles to the variation events for (final VariantContext pileupAllele : pileupAllelesPassingFilters) { //these are events from single haplotypes, so we can do a simple comparison without trimming if (allVariationEvents.stream().noneMatch(vc -> vc.getStart() == pileupAllele.getStart() && vc.getAlternateAllele(0).basesMatch(pileupAllele.getAlternateAllele(0)))) { allVariationEvents.add(pileupAllele); } } + // Add given alleles to the variation events for (final VariantContext given : givenAlleles) { //these are events from single haplotypes, so we can do a simple comparison without trimming if (allVariationEvents.stream().noneMatch(vc -> vc.getStart() == given.getStart() && vc.getAlternateAllele(0).basesMatch(given.getAlternateAllele(0)))) {