Skip to content

Commit 5d95d60

Browse files
cwhelandroazen
authored andcommitted
Fix error in genotype given alleles mode when input alleles have genotypes (#5341)
* fix issue of alleles not being replaced with star alleles when the given allele variants have genotypes * add unit test to replaceWithSpanDelVC
1 parent 4618323 commit 5d95d60

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

src/main/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngine.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,21 @@ public CalledHaplotypes assignGenotypeLikelihoods(final List<Haplotype> haplotyp
216216
activeRegionWindow,tracker,activeAllelesToGenotype,emitReferenceConfidence,maxMnpDistance,header,false);
217217
}
218218

219-
private List<VariantContext> replaceSpanDels(final List<VariantContext> eventsAtThisLoc, final Allele refAllele, final int loc) {
219+
@VisibleForTesting
220+
static List<VariantContext> replaceSpanDels(final List<VariantContext> eventsAtThisLoc, final Allele refAllele, final int loc) {
220221
return eventsAtThisLoc.stream().map(vc -> replaceWithSpanDelVC(vc, refAllele, loc)).collect(Collectors.toList());
221222
}
222223

223-
private VariantContext replaceWithSpanDelVC(final VariantContext variantContext, final Allele refAllele, final int loc) {
224+
@VisibleForTesting
225+
static VariantContext replaceWithSpanDelVC(final VariantContext variantContext, final Allele refAllele, final int loc) {
224226
if (variantContext.getStart() == loc) {
225227
return variantContext;
226228
} else {
227229
VariantContextBuilder builder = new VariantContextBuilder(variantContext)
228230
.start(loc)
229231
.stop(loc)
230-
.alleles(Arrays.asList(refAllele, Allele.SPAN_DEL));
232+
.alleles(Arrays.asList(refAllele, Allele.SPAN_DEL))
233+
.genotypes(GenotypesContext.NO_GENOTYPES);
231234
return builder.make();
232235
}
233236

src/test/java/org/broadinstitute/hellbender/tools/walkers/haplotypecaller/HaplotypeCallerGenotypingEngineUnitTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.apache.commons.lang3.tuple.Pair;
77
import org.broadinstitute.gatk.nativebindings.smithwaterman.SWOverhangStrategy;
88
import org.broadinstitute.gatk.nativebindings.smithwaterman.SWParameters;
9+
import org.broadinstitute.hellbender.testutils.VariantContextTestUtils;
910
import org.broadinstitute.hellbender.utils.QualityUtils;
1011
import org.broadinstitute.hellbender.utils.SimpleInterval;
1112
import org.broadinstitute.hellbender.utils.Utils;
@@ -559,4 +560,42 @@ public void testRemoveExcessiveAltAlleleFromVC(){
559560
Assert.assertEquals(reducedVC.getNAlleles(), 3);
560561
Assert.assertTrue(reducedVC.getAlleles().containsAll(Arrays.asList(Allele.create("A", true), Allele.create("T", false), Allele.create("C", false))));
561562
}
563+
564+
@Test
565+
public void testReplaceWithSpanDelVC() {
566+
final VariantContext snp = new VariantContextBuilder("source", "1", 1000000, 1000000,
567+
Arrays.asList(Allele.create("A", true),
568+
Allele.create("G", false))).make();
569+
final VariantContext snpReplacement =
570+
HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(snp, Allele.create("A", true), 1000000);
571+
572+
Assert.assertEquals(snpReplacement, snp);
573+
574+
final VariantContext spanDel = new VariantContextBuilder("source", "1", 999995, 1000005,
575+
Arrays.asList(Allele.create("AAAAAAAAAAA", true),
576+
Allele.create("A", false))).make();
577+
578+
final VariantContext spanDelReplacement =
579+
HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(spanDel, Allele.create("A", true), 1000000);
580+
581+
final VariantContext expectedSpanDelReplacement = new VariantContextBuilder("source", "1", 1000000, 1000000,
582+
Arrays.asList(Allele.create("A", true),
583+
Allele.SPAN_DEL)).make();
584+
585+
VariantContextTestUtils.assertVariantContextsAreEqual(spanDelReplacement,
586+
expectedSpanDelReplacement, Collections.emptyList());
587+
588+
final VariantContext spanDelWithGt = new VariantContextBuilder("source", "1", 999995, 1000005,
589+
Arrays.asList(Allele.create("AAAAAAAAAAA", true),
590+
Allele.create("A", false)))
591+
.genotypes(new GenotypeBuilder("S1",
592+
Arrays.asList(spanDel.getAlleles().get(0), spanDel.getAlleles().get(1))).make()).make();
593+
594+
final VariantContext spanDelWithGTReplacement =
595+
HaplotypeCallerGenotypingEngine.replaceWithSpanDelVC(spanDelWithGt, Allele.create("A", true), 1000000);
596+
597+
VariantContextTestUtils.assertVariantContextsAreEqual(spanDelWithGTReplacement,
598+
expectedSpanDelReplacement, Collections.emptyList());
599+
600+
}
562601
}

src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/expected.testGenotypeGivenAllelesMode.gatk4.vcf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
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
3232
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
3333
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
34+
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

src/test/resources/org/broadinstitute/hellbender/tools/haplotypecaller/testGenotypeGivenAllelesMode_givenAlleles.vcf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
##INFO=<ID=SOR,Number=1,Type=Float,Description="Symmetric Odds Ratio of 2x2 contingency table to detect strand bias">
2626
##contig=<ID=20,length=63025520>
2727
##contig=<ID=21,length=48129895>
28-
#CHROM POS ID REF ALT QUAL FILTER INFO
29-
20 10000694 . G A . . .
30-
20 10001436 . A AAGGCT . . .
31-
20 10001661 . T C . . .
32-
20 10004094 . A T . . .
33-
20 10004769 . TAAAACTATGC T . . .
34-
20 10004771 . A T . . .
35-
20 10006819 . AAAAC T . . .
28+
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SAMPLE1
29+
20 10000694 . G A . . . GT 0|1
30+
20 10001436 . A AAGGCT . . . GT 0|1
31+
20 10001661 . T C . . . GT 0|1
32+
20 10004094 . A T . . . GT 0|1
33+
20 10004769 . TAAAACTATGC T . . . GT 0|1
34+
20 10004771 . A T . . . GT 0|1
35+
20 10006819 . AAAAC T . . . GT 0|1
36+
20 10006823 . C G . . . GT 0|1

0 commit comments

Comments
 (0)