From 7392c4d1b068113f87139ad05ffe5cc4ddab7045 Mon Sep 17 00:00:00 2001 From: Ron Levine Date: Thu, 23 Jun 2016 17:14:06 -0400 Subject: [PATCH] Removed spanning deletions if the deletion was removed --- .../walkers/genotyper/GenotypingEngine.java | 84 +++++++++++++++---- .../GenotypeGVCFsIntegrationTest.java | 9 ++ 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/genotyper/GenotypingEngine.java b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/genotyper/GenotypingEngine.java index 83c7ed533..cdcb2c195 100644 --- a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/genotyper/GenotypingEngine.java +++ b/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/tools/walkers/genotyper/GenotypingEngine.java @@ -104,8 +104,7 @@ public abstract class GenotypingEngine upstreamDeletionsLoc = new LinkedList<>(); /** * Construct a new genotyper engine, on a specific subset of samples. @@ -233,7 +232,7 @@ public abstract class GenotypingEngine alleles = afcr.getAllelesUsedInGenotyping(); final int alternativeAlleleCount = alleles.size() - 1; @@ -355,23 +354,74 @@ public abstract class GenotypingEngine 0) { + final GenomeLoc genomeLoc = genomeLocParser.createGenomeLocOnContig(vc.getContig(), vc.getStart(), vc.getStart() + deletionSize); + upstreamDeletionsLoc.add(genomeLoc); + } + } + + /** + * Is the variant context covered by an upstream deletion? + * + * @param vc variant context + * @return true if the location is covered by an upstream deletion, false otherwise + */ + private boolean coveredByDeletion(final VariantContext vc) { + for (Iterator it = upstreamDeletionsLoc.iterator(); it.hasNext(); ) { + final GenomeLoc loc = it.next(); + if (!loc.getContig().equals(vc.getContig())) { // past contig deletion. + it.remove(); + } else if (loc.getStop() < vc.getStart()) { // past position in current contig deletion. + it.remove(); + } else if (loc.getStart() == vc.getStart()) { + // ignore this deletion, the symbolic one does not make reference to it. + } else { // deletion covers. + return true; + } + } + + return false; + } + /** * Checks whether even if the allele is not well supported by the data, we should keep it for genotyping. * diff --git a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/GenotypeGVCFsIntegrationTest.java b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/GenotypeGVCFsIntegrationTest.java index 56d506ce3..04153ed2d 100644 --- a/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/GenotypeGVCFsIntegrationTest.java +++ b/protected/gatk-tools-protected/src/test/java/org/broadinstitute/gatk/tools/walkers/variantutils/GenotypeGVCFsIntegrationTest.java @@ -661,4 +661,13 @@ public class GenotypeGVCFsIntegrationTest extends WalkerTest { spec.disableShadowBCF(); executeTest("testGenotypingSpanningDeletionWithAllSites", spec); } + + @Test + public void testGenotypingSpanningDeletionAcrossLines() { + final WalkerTestSpec spec = new WalkerTestSpec( + baseTestString(" -V " + privateTestDir + "input-1_2256566.vcf", b37KGReference), + Collections.singletonList("1f914189326cdd17d0a8753f13cb221f")); + spec.disableShadowBCF(); + executeTest("testGenotypingSpanningDeletionAcrossLines", spec); + } } \ No newline at end of file