Search in sources :

Example 6 with HKY

use of beast.evolution.substitutionmodel.HKY in project beast2 by CompEvol.

the class TreeLikelihoodTest method testHKY85Likelihood.

@Test
public void testHKY85Likelihood() throws Exception {
    // Set up HKY85 model: estimated freqs, kappa = 29.739445, 0 gamma categories
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);
    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);
    HKY hky = new HKY();
    hky.initByName("kappa", "29.739445", "frequencies", freqs);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", hky);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);
    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1825.2131708068507, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) HKY(beast.evolution.substitutionmodel.HKY) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel) Frequencies(beast.evolution.substitutionmodel.Frequencies) UncertainAlignmentTest(test.beast.evolution.alignment.UncertainAlignmentTest) Test(org.junit.Test)

Example 7 with HKY

use of beast.evolution.substitutionmodel.HKY in project beast2 by CompEvol.

the class HKYTest method testHKY.

public void testHKY() throws Exception {
    for (Instance test : all) {
        RealParameter f = new RealParameter(test.getPi());
        Frequencies freqs = new Frequencies();
        freqs.initByName("frequencies", f, "estimate", false);
        HKY hky = new HKY();
        hky.initByName("kappa", test.getKappa().toString(), "frequencies", freqs);
        double distance = test.getDistance();
        double[] mat = new double[4 * 4];
        hky.getTransitionProbabilities(null, distance, 0, 1, mat);
        final double[] result = test.getExpectedResult();
        for (int k = 0; k < mat.length; ++k) {
            assertEquals(mat[k], result[k], 1e-10);
            System.out.println(k + " : " + (mat[k] - result[k]));
        }
    }
}
Also used : HKY(beast.evolution.substitutionmodel.HKY) RealParameter(beast.core.parameter.RealParameter) Frequencies(beast.evolution.substitutionmodel.Frequencies)

Example 8 with HKY

use of beast.evolution.substitutionmodel.HKY in project beast2 by CompEvol.

the class TreeLikelihoodTest method testHKY85GILikelihood.

@Test
public void testHKY85GILikelihood() throws Exception {
    // Set up HKY85+G+I model: estimated freqs, kappa = 39.464538, 4 gamma categories, shape = 0.587649, prop invariant = 0.486548
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);
    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);
    HKY hky = new HKY();
    hky.initByName("kappa", "39.464538", "frequencies", freqs);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 4, "shape", "0.587649", "proportionInvariant", "0.486548", "substModel", hky);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.639227747059, BEASTTestCase.PRECISION);
    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.639227747059, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) HKY(beast.evolution.substitutionmodel.HKY) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel) Frequencies(beast.evolution.substitutionmodel.Frequencies) UncertainAlignmentTest(test.beast.evolution.alignment.UncertainAlignmentTest) Test(org.junit.Test)

Aggregations

Frequencies (beast.evolution.substitutionmodel.Frequencies)8 HKY (beast.evolution.substitutionmodel.HKY)8 SiteModel (beast.evolution.sitemodel.SiteModel)7 Alignment (beast.evolution.alignment.Alignment)6 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)6 TreeLikelihood (beast.evolution.likelihood.TreeLikelihood)6 Tree (beast.evolution.tree.Tree)6 Test (org.junit.Test)6 UncertainAlignmentTest (test.beast.evolution.alignment.UncertainAlignmentTest)6 RealParameter (beast.core.parameter.RealParameter)2