Search in sources :

Example 41 with VariantContextBuilder

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));
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) ArrayList(java.util.ArrayList) Genotype(htsjdk.variant.variantcontext.Genotype) VariantContext(htsjdk.variant.variantcontext.VariantContext) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 42 with VariantContextBuilder

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");
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 43 with VariantContextBuilder

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));
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 44 with VariantContextBuilder

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);
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) VariantContext(htsjdk.variant.variantcontext.VariantContext) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 45 with VariantContextBuilder

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[][] {});
}
Also used : VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) Genotype(htsjdk.variant.variantcontext.Genotype) DataProvider(org.testng.annotations.DataProvider)

Aggregations

VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)57 VariantContext (htsjdk.variant.variantcontext.VariantContext)40 Test (org.testng.annotations.Test)26 Allele (htsjdk.variant.variantcontext.Allele)25 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)21 Genotype (htsjdk.variant.variantcontext.Genotype)12 ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)8 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)7 GenotypeBuilder (htsjdk.variant.variantcontext.GenotypeBuilder)6 GenotypesContext (htsjdk.variant.variantcontext.GenotypesContext)6 File (java.io.File)6 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)5 VCFHeader (htsjdk.variant.vcf.VCFHeader)5 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)5 BeforeTest (org.testng.annotations.BeforeTest)5 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)4 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)4 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)3 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3