use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class GenotypingEngineUnitTest method testCalculateGenotypes.
// Want to run testCoveredByDeletion first to ensure clean list or recorded deletions
@Test(dependsOnMethods = { "testCoveredByDeletion" })
public void testCalculateGenotypes() {
genotypingEngine.clearUpstreamDeletionsLoc();
// Remove deletion
final List<Genotype> genotypes = Arrays.asList(// first alt
new GenotypeBuilder("sample1").alleles(gtAlleles).PL(new double[] { 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }).make(), // second alt
new GenotypeBuilder("sample2").alleles(gtAlleles).PL(new double[] { 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0 }).make());
final VariantContext vc = new VariantContextBuilder("test", "1", 1, refAllele.length(), allelesDel).genotypes(genotypes).make();
final VariantContext vcOut = genotypingEngine.calculateGenotypes(vc, GenotypeLikelihoodsCalculationModel.INDEL, null);
Assert.assertFalse(vcOut.getAlleles().contains(altT));
// Make sure the spanning deletion is removed since the deletion was removed
final Allele refAlleleSpanDel = Allele.create("C", true);
final List<Allele> vcAllelesSpanDel = new ArrayList<>(Arrays.asList(refAlleleSpanDel, Allele.SPAN_DEL, GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE));
final List<Genotype> genotypesSpanDel = Arrays.asList(// first alt
new GenotypeBuilder("sample1").alleles(gtAlleles).PL(new double[] { 0, 0, 100, 0, 0, 0 }).make(), new GenotypeBuilder("sample2").alleles(gtAlleles).PL(new double[] { 0, 0, 0, 0, 0, 0 }).make());
final VariantContext vcSpanDel = new VariantContextBuilder("test1", "1", 2, 2 + refAlleleSpanDel.length() - 1, vcAllelesSpanDel).genotypes(genotypesSpanDel).make();
final VariantContext vcOut1 = genotypingEngine.calculateGenotypes(vcSpanDel, GenotypeLikelihoodsCalculationModel.INDEL, null);
Assert.assertFalse(vcOut1.getAlleles().contains(Allele.SPAN_DEL));
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class GenotypingEngineUnitTest method testCoveredByDeletion.
@Test(dataProvider = "testCoveredByDeletionData")
public void testCoveredByDeletion(final String test, final SimpleInterval location, final boolean isCovered) {
final VariantContext vc = new VariantContextBuilder("test", location.getContig(), location.getStart(), location.getEnd(), allelesDel).make();
Assert.assertEquals(isCovered, genotypingEngine.isVcCoveredByDeletion(vc), test + " failed");
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class GenotypingEngineUnitTest method testGenotypesWithNonRefSymbolicAllelesAreNotNulled.
@Test
public void testGenotypesWithNonRefSymbolicAllelesAreNotNulled() {
final VariantContext vc = new VariantContextBuilder(null, "1", 100, 100, Arrays.asList(refA, GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE)).genotypes(GenotypeBuilder.create(SAMPLES.getSample(0), Arrays.asList(refA, GATKVCFConstants.NON_REF_SYMBOLIC_ALLELE))).make();
Assert.assertNotNull(getGenotypingEngine().calculateGenotypes(vc, GenotypeLikelihoodsCalculationModel.SNP, null));
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class GenotypingEngineUnitTest method testNoIndexOutOfBoundsExceptionWhenSubsettingToNoAlleles.
//test for https://github.com/broadinstitute/gatk/issues/2530
@Test
public void testNoIndexOutOfBoundsExceptionWhenSubsettingToNoAlleles() {
final VariantContext vc = new VariantContextBuilder(null, "1", 100, 100, Arrays.asList(refA, altT)).genotypes(GenotypeBuilder.create(SAMPLES.getSample(0), Arrays.asList(refA, refA))).make();
getGenotypingEngine().calculateGenotypes(vc, GenotypeLikelihoodsCalculationModel.SNP, null);
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class IndependentAllelesDiploidExactAFCalculatorUnitTest method makeTestMakeAlleleConditionalContexts.
@DataProvider(name = "TestMakeAlleleConditionalContexts")
public Object[][] makeTestMakeAlleleConditionalContexts() {
List<Object[]> tests = new ArrayList<>();
final VariantContextBuilder root = new VariantContextBuilder("x", "1", 1, 1, Arrays.asList(A));
final VariantContextBuilder vcAC = new VariantContextBuilder(root).alleles(Arrays.asList(A, C));
final VariantContextBuilder vcAG = new VariantContextBuilder(root).alleles(Arrays.asList(A, G));
final VariantContextBuilder vcACG = new VariantContextBuilder(root).alleles(Arrays.asList(A, C, G));
final VariantContextBuilder vcAGC = new VariantContextBuilder(root).alleles(Arrays.asList(A, G, C));
final Genotype gACG = makePL(0, 1, 2, 3, 4, 5);
final Genotype gAGC = makePL(0, 4, 5, 1, 3, 2);
final Genotype gACcombined = makePL(0, 2, 5);
final Genotype gACcombined2 = makePL(0, 1, 4);
final Genotype gAGcombined = makePL(0, 4, 9);
// biallelic
tests.add(new Object[] { vcAC.genotypes(gACcombined).make(), Arrays.asList(vcAC.genotypes(gACcombined).make()) });
// tri-allelic
tests.add(new Object[] { vcACG.genotypes(gACG).make(), Arrays.asList(vcAC.genotypes(gACcombined).make(), vcAG.genotypes(gAGcombined).make()) });
tests.add(new Object[] { vcAGC.genotypes(gAGC).make(), Arrays.asList(vcAG.genotypes(gAGcombined).make(), vcAC.genotypes(gACcombined2).make()) });
return tests.toArray(new Object[][] {});
}
Aggregations