Skip to content

Commit

Permalink
Fix error in genotype given alleles mode when input alleles have geno…
Browse files Browse the repository at this point in the history
…types (#5341)

* fix issue of alleles not being replaced with star alleles when the given allele variants have genotypes

* add unit test to replaceWithSpanDelVC
  • Loading branch information
cwhelan authored and droazen committed Oct 23, 2018
1 parent 4618323 commit 5d95d60
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,21 @@ 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 {
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file not shown.

0 comments on commit 5d95d60

Please sign in to comment.