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);
}
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]));
}
}
}
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);
}
Aggregations