Search in sources :

Example 1 with GenotypeLikelihoods

use of htsjdk.variant.variantcontext.GenotypeLikelihoods in project gatk by broadinstitute.

the class IndependentSampleGenotypesModelUnitTest method testCalculateLikelihoods.

@Test(dataProvider = "ploidyAndMaximumAlleleAndReadCountsData")
public void testCalculateLikelihoods(final int[] ploidies, final int alleleCount, final int discardAlleleCount, final int[] readCounts) {
    final ReadLikelihoods<Allele> likelihoods = ReadLikelihoodsUnitTester.readLikelihoods(alleleCount, readCounts);
    final AlleleList<Allele> genotypingAlleleList = discardAlleleCount == 0 ? likelihoods : discardAllelesAtRandom(likelihoods, discardAlleleCount);
    final SampleList sampleList = SampleListUnitTester.sampleList(ploidies.length);
    final PloidyModel ploidyModel = new HeterogeneousPloidyModel(sampleList, ploidies);
    final GenotypingData<Allele> data = new GenotypingData<>(ploidyModel, likelihoods);
    final IndependentSampleGenotypesModel model = new IndependentSampleGenotypesModel();
    final GenotypingLikelihoods<Allele> gLikelihoods = model.calculateLikelihoods(genotypingAlleleList, data);
    Assert.assertNotNull(gLikelihoods);
    AlleleListUnitTester.assertAlleleList(gLikelihoods, genotypingAlleleList.asListOfAlleles());
    SampleListUnitTester.assertSampleList(gLikelihoods, sampleList.asListOfSamples());
    final int sampleCount = gLikelihoods.numberOfSamples();
    for (int i = 0; i < sampleCount; i++) {
        final GenotypeLikelihoods sampleLikelihoods = gLikelihoods.sampleLikelihoods(i);
        Assert.assertNotNull(sampleLikelihoods);
        final double[] values = sampleLikelihoods.getAsVector();
        Assert.assertNotNull(values);
        Assert.assertEquals(values.length, new GenotypeLikelihoodCalculators().getInstance(ploidies[i], genotypingAlleleList.numberOfAlleles()).genotypeCount());
        for (int j = 0; j < values.length; j++) Assert.assertTrue(values[j] <= 0);
    }
}
Also used : GenotypeLikelihoods(htsjdk.variant.variantcontext.GenotypeLikelihoods) Allele(htsjdk.variant.variantcontext.Allele) Test(org.testng.annotations.Test)

Example 2 with GenotypeLikelihoods

use of htsjdk.variant.variantcontext.GenotypeLikelihoods in project gatk-protected by broadinstitute.

the class ReferenceConfidenceModelUnitTest method testIndelLikelihoods.

@Test
public void testIndelLikelihoods() {
    GenotypeLikelihoods prev = model.getIndelPLs(HomoSapiensConstants.DEFAULT_PLOIDY, 0);
    Assert.assertEquals(prev.getAsPLs(), new int[] { 0, 0, 0 });
    Assert.assertEquals(-10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, prev.getAsVector()), 0.0);
    for (int i = 1; i <= ReferenceConfidenceModel.MAX_N_INDEL_INFORMATIVE_READS; i++) {
        final GenotypeLikelihoods current = model.getIndelPLs(HomoSapiensConstants.DEFAULT_PLOIDY, i);
        final double prevGQ = -10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, prev.getAsVector());
        final double currGQ = -10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, current.getAsVector());
        Assert.assertTrue(prevGQ < currGQ, "GQ Failed with prev " + prev + " curr " + current + " at " + i);
        Assert.assertTrue(prev.getAsPLs()[1] < current.getAsPLs()[1], "het PL failed with prev " + prev + " curr " + current + " at " + i);
        Assert.assertTrue(prev.getAsPLs()[2] < current.getAsPLs()[2], "hom-var PL Failed with prev " + prev + " curr " + current + " at " + i);
        //            logger.warn("result at " + i + " is " + current);
        prev = current;
    }
}
Also used : GenotypeLikelihoods(htsjdk.variant.variantcontext.GenotypeLikelihoods) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 3 with GenotypeLikelihoods

use of htsjdk.variant.variantcontext.GenotypeLikelihoods in project gatk-protected by broadinstitute.

the class ReferenceConfidenceModelUnitTest method testWorstGL.

@Test
public void testWorstGL() {
    final GenotypeLikelihoods gq10 = GenotypeLikelihoods.fromPLField("0,10,100");
    final GenotypeLikelihoods gq20 = GenotypeLikelihoods.fromPLField("0,20,200");
    final GenotypeLikelihoods gq0 = GenotypeLikelihoods.fromPLField("20,0,200");
    Assert.assertSame(model.getGLwithWorstGQ(gq10, gq20), gq10);
    Assert.assertSame(model.getGLwithWorstGQ(gq20, gq10), gq10);
    Assert.assertSame(model.getGLwithWorstGQ(gq10, gq0), gq0);
    Assert.assertSame(model.getGLwithWorstGQ(gq0, gq10), gq0);
}
Also used : GenotypeLikelihoods(htsjdk.variant.variantcontext.GenotypeLikelihoods) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 4 with GenotypeLikelihoods

use of htsjdk.variant.variantcontext.GenotypeLikelihoods in project gatk by broadinstitute.

the class ReferenceConfidenceModelUnitTest method testWorstGL.

@Test
public void testWorstGL() {
    final GenotypeLikelihoods gq10 = GenotypeLikelihoods.fromPLField("0,10,100");
    final GenotypeLikelihoods gq20 = GenotypeLikelihoods.fromPLField("0,20,200");
    final GenotypeLikelihoods gq0 = GenotypeLikelihoods.fromPLField("20,0,200");
    Assert.assertSame(model.getGLwithWorstGQ(gq10, gq20), gq10);
    Assert.assertSame(model.getGLwithWorstGQ(gq20, gq10), gq10);
    Assert.assertSame(model.getGLwithWorstGQ(gq10, gq0), gq0);
    Assert.assertSame(model.getGLwithWorstGQ(gq0, gq10), gq0);
}
Also used : GenotypeLikelihoods(htsjdk.variant.variantcontext.GenotypeLikelihoods) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 5 with GenotypeLikelihoods

use of htsjdk.variant.variantcontext.GenotypeLikelihoods in project gatk by broadinstitute.

the class ReferenceConfidenceModelUnitTest method testIndelLikelihoods.

@Test
public void testIndelLikelihoods() {
    GenotypeLikelihoods prev = model.getIndelPLs(HomoSapiensConstants.DEFAULT_PLOIDY, 0);
    Assert.assertEquals(prev.getAsPLs(), new int[] { 0, 0, 0 });
    Assert.assertEquals(-10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, prev.getAsVector()), 0.0);
    for (int i = 1; i <= ReferenceConfidenceModel.MAX_N_INDEL_INFORMATIVE_READS; i++) {
        final GenotypeLikelihoods current = model.getIndelPLs(HomoSapiensConstants.DEFAULT_PLOIDY, i);
        final double prevGQ = -10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, prev.getAsVector());
        final double currGQ = -10 * GenotypeLikelihoods.getGQLog10FromLikelihoods(GenotypeType.HOM_REF.ordinal() - 1, current.getAsVector());
        Assert.assertTrue(prevGQ < currGQ, "GQ Failed with prev " + prev + " curr " + current + " at " + i);
        Assert.assertTrue(prev.getAsPLs()[1] < current.getAsPLs()[1], "het PL failed with prev " + prev + " curr " + current + " at " + i);
        Assert.assertTrue(prev.getAsPLs()[2] < current.getAsPLs()[2], "hom-var PL Failed with prev " + prev + " curr " + current + " at " + i);
        //            logger.warn("result at " + i + " is " + current);
        prev = current;
    }
}
Also used : GenotypeLikelihoods(htsjdk.variant.variantcontext.GenotypeLikelihoods) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

GenotypeLikelihoods (htsjdk.variant.variantcontext.GenotypeLikelihoods)6 Test (org.testng.annotations.Test)6 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 Allele (htsjdk.variant.variantcontext.Allele)2