From 4082f0a8174c61a540e87226f670c898b7c7b447 Mon Sep 17 00:00:00 2001 From: Chris Whelan <cwhelan@broadinstitute.org> Date: Mon, 22 Oct 2018 13:08:29 -0400 Subject: [PATCH 1/2] fix issue of alleles not being replaced with star alleles when the given allele variants have genotypes --- .../HaplotypeCallerGenotypingEngine.java | 3 ++- ...cted.testGenotypeGivenAllelesMode.gatk4.vcf | 1 + ...stGenotypeGivenAllelesMode_givenAlleles.vcf | 17 +++++++++-------- ...notypeGivenAllelesMode_givenAlleles.vcf.idx | Bin 448 -> 433 bytes 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java index 0335af96c4b..92d143996d0 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java @@ -227,7 +227,8 @@ private VariantContext replaceWithSpanDelVC(final VariantContext variantContext, VariantContextBuilder builder = new VariantContextBuilder(variantContext) .start(loc) .stop(loc) - .alleles(Arrays.asList(refAllele, Allele.SPAN_DEL)); + .alleles(Arrays.asList(refAllele, Allele.SPAN_DEL)) + .genotypes(GenotypesContext.NO_GENOTYPES); return builder.make(); } diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/expected.testGenotypeGivenAllelesMode.gatk4.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/expected.testGenotypeGivenAllelesMode.gatk4.vcf index 842236c0226..fdf87b8f6d7 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/expected.testGenotypeGivenAllelesMode.gatk4.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/expected.testGenotypeGivenAllelesMode.gatk4.vcf @@ -31,3 +31,4 @@ 20 10004769 . TAAAACTATGC T 980.73 . AC=1;AF=0.500;AN=2;BaseQRankSum=1.603;DP=79;ExcessHet=3.0103;FS=3.758;MLEAC=1;MLEAF=0.500;MQ=52.37;MQRankSum=-6.625;QD=15.32;ReadPosRankSum=1.879;SOR=1.306 GT:AD:DP:GQ:PL 0/1:37,27:64:99:1018,0,1471 20 10004771 . A *,T 998.77 . AC=1,0;AF=0.500,0.00;AN=2;BaseQRankSum=-1.270;DP=74;ExcessHet=3.0103;FS=2.397;MLEAC=1,0;MLEAF=0.500,0.00;MQ=51.81;MQRankSum=-6.325;QD=16.93;ReadPosRankSum=2.185;SOR=1.115 GT:AD:DP:GQ:PL 0/1:32,27,0:59:99:1027,0,1345,1162,1305,2852 20 10006819 . AAAAC T 0 LowQual AC=0;AF=0.00;AN=2;DP=75;ExcessHet=3.0103;FS=0.000;MLEAC=0;MLEAF=0.00;MQ=61.14;SOR=0.572 GT:AD:DP:GQ:PL 0/0:75,0:75:99:0,244,2147483647 +20 10006823 . C *,G 0 LowQual AC=0,0;AF=0.00,0.00;AN=2;DP=73;ExcessHet=3.0103;FS=0.000;MLEAC=0,0;MLEAF=0.00,0.00;MQ=61.18;SOR=0.069 GT:AD:DP:GQ:PL 0/0:17,0,0:17:51:0,229,2147483647,51,819,590 diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf b/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf index c9c28c26d07..48ed82e665e 100644 --- a/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf +++ b/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf @@ -25,11 +25,12 @@ ##INFO=<ID=SOR,Number=1,Type=Float,Description="Symmetric Odds Ratio of 2x2 contingency table to detect strand bias"> ##contig=<ID=20,length=63025520> ##contig=<ID=21,length=48129895> -#CHROM POS ID REF ALT QUAL FILTER INFO -20 10000694 . G A . . . -20 10001436 . A AAGGCT . . . -20 10001661 . T C . . . -20 10004094 . A T . . . -20 10004769 . TAAAACTATGC T . . . -20 10004771 . A T . . . -20 10006819 . AAAAC T . . . +#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SAMPLE1 +20 10000694 . G A . . . GT 0|1 +20 10001436 . A AAGGCT . . . GT 0|1 +20 10001661 . T C . . . GT 0|1 +20 10004094 . A T . . . GT 0|1 +20 10004769 . TAAAACTATGC T . . . GT 0|1 +20 10004771 . A T . . . GT 0|1 +20 10006819 . AAAAC T . . . GT 0|1 +20 10006823 . C G . . . GT 0|1 diff --git a/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf.idx b/src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf.idx index 36d7758150f5b72a804d6f2b33ff0a22e785e721..f0c2511184ce4fdbecc5ccf767cafbfce6ae71c2 100644 GIT binary patch delta 151 zcmX@WypegrYTgMv3}C=vvUN_{#2pIEW_kt_UurN~OcrL;5Hx3Sb9D>}4RVcl_7C+7 XVX&C&!zdBM0o2jT4bev}8s-iFylxf+ delta 166 zcmdnUe1LhvYF<Mg1~5oq7TuaOafgDSsh*LAskxyEj5M2gTZ75mbTSL0hM+Nno2z3; gXpn2Xvwx^x2!r`#TSkc(cAx=e+z?}^MZ=s003aL}LjV8( From 859867b3ebc6674c36b8e0478e64de92ea9d564c Mon Sep 17 00:00:00 2001 From: Chris Whelan <cwhelan@broadinstitute.org> Date: Mon, 22 Oct 2018 23:35:42 -0400 Subject: [PATCH 2/2] add unit test to replaceWithSpanDelVC --- .../HaplotypeCallerGenotypingEngine.java | 6 ++- ...plotypeCallerGenotypingEngineUnitTest.java | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java index 92d143996d0..e990f484f68 100644 --- a/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java +++ b/src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java @@ -216,11 +216,13 @@ public CalledHaplotypes assignGenotypeLikelihoods(final List<Haplotype> haplotyp activeRegionWindow,tracker,activeAllelesToGenotype,emitReferenceConfidence,maxMnpDistance,header,false); } - private List<VariantContext> replaceSpanDels(final List<VariantContext> eventsAtThisLoc, final Allele refAllele, final int loc) { + @VisibleForTesting + static List<VariantContext> replaceSpanDels(final List<VariantContext> eventsAtThisLoc, final Allele refAllele, final int loc) { return eventsAtThisLoc.stream().map(vc -> replaceWithSpanDelVC(vc, refAllele, loc)).collect(Collectors.toList()); } - private VariantContext replaceWithSpanDelVC(final VariantContext variantContext, final Allele refAllele, final int loc) { + @VisibleForTesting + static VariantContext replaceWithSpanDelVC(final VariantContext variantContext, final Allele refAllele, final int loc) { if (variantContext.getStart() == loc) { return variantContext; } else { diff --git a/src/test/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngineUnitTest.java b/src/test/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngineUnitTest.java index 3a04f3a5999..a74474081a8 100644 --- a/src/test/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngineUnitTest.java +++ b/src/test/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngineUnitTest.java @@ -6,6 +6,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.broadinstitute.gatk.nativebindings.smithwaterman.SWOverhangStrategy; import org.broadinstitute.gatk.nativebindings.smithwaterman.SWParameters; +import org.broadinstitute.hellbender.testutils.VariantContextTestUtils; import org.broadinstitute.hellbender.utils.QualityUtils; import org.broadinstitute.hellbender.utils.SimpleInterval; import org.broadinstitute.hellbender.utils.Utils; @@ -559,4 +560,42 @@ public void testRemoveExcessiveAltAlleleFromVC(){ Assert.assertEquals(reducedVC.getNAlleles(), 3); Assert.assertTrue(reducedVC.getAlleles().containsAll(Arrays.asList(Allele.create("A", true), Allele.create("T", false), Allele.create("C", false)))); } + + @Test + public void testReplaceWithSpanDelVC() { + final VariantContext snp = new VariantContextBuilder("source", "1", 1000000, 1000000, + Arrays.asList(Allele.create("A", true), + Allele.create("G", false))).make(); + final VariantContext snpReplacement = + HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(snp, Allele.create("A", true), 1000000); + + Assert.assertEquals(snpReplacement, snp); + + final VariantContext spanDel = new VariantContextBuilder("source", "1", 999995, 1000005, + Arrays.asList(Allele.create("AAAAAAAAAAA", true), + Allele.create("A", false))).make(); + + final VariantContext spanDelReplacement = + HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(spanDel, Allele.create("A", true), 1000000); + + final VariantContext expectedSpanDelReplacement = new VariantContextBuilder("source", "1", 1000000, 1000000, + Arrays.asList(Allele.create("A", true), + Allele.SPAN_DEL)).make(); + + VariantContextTestUtils.assertVariantContextsAreEqual(spanDelReplacement, + expectedSpanDelReplacement, Collections.emptyList()); + + final VariantContext spanDelWithGt = new VariantContextBuilder("source", "1", 999995, 1000005, + Arrays.asList(Allele.create("AAAAAAAAAAA", true), + Allele.create("A", false))) + .genotypes(new GenotypeBuilder("S1", + Arrays.asList(spanDel.getAlleles().get(0), spanDel.getAlleles().get(1))).make()).make(); + + final VariantContext spanDelWithGTReplacement = + HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(spanDelWithGt, Allele.create("A", true), 1000000); + + VariantContextTestUtils.assertVariantContextsAreEqual(spanDelWithGTReplacement, + expectedSpanDelReplacement, Collections.emptyList()); + + } }