use of dr.oldevomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.
the class LikelihoodTest method testLikelihoodHKY85.
public void testLikelihoodHKY85() {
System.out.println("\nTest Likelihood using HKY85:");
// Sub model
Parameter freqs = new Parameter.Default(alignment.getStateFrequencies());
Parameter kappa = new Parameter.Default(HKYParser.KAPPA, 29.739445, 0, 100);
FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
HKY hky = new HKY(kappa, f);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(hky);
Parameter mu = new Parameter.Default(GammaSiteModelParser.MUTATION_RATE, 1.0, 0, Double.POSITIVE_INFINITY);
siteModel.setMutationRateParameter(mu);
//treeLikelihood
SitePatterns patterns = new SitePatterns(alignment, null, 0, -1, 1, true);
TreeLikelihood treeLikelihood = new TreeLikelihood(patterns, treeModel, siteModel, null, null, false, false, true, false, false);
assertEquals("treeLikelihoodHKY85", format.format(-1825.21317), format.format(treeLikelihood.getLogLikelihood()));
}
use of dr.oldevomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.
the class LikelihoodTest method testLikelihoodHKY85G.
public void testLikelihoodHKY85G() {
System.out.println("\nTest Likelihood using HKY85G:");
// Sub model
Parameter freqs = new Parameter.Default(alignment.getStateFrequencies());
Parameter kappa = new Parameter.Default(HKYParser.KAPPA, 38.829740, 0, 100);
FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
HKY hky = new HKY(kappa, f);
//siteModel
Parameter mu = new Parameter.Default(GammaSiteModelParser.MUTATION_RATE, 1.0, 0, Double.POSITIVE_INFINITY);
Parameter shape = new Parameter.Default(GammaSiteModelParser.GAMMA_SHAPE, 0.137064, 0, 1000.0);
GammaSiteModel siteModel = new GammaSiteModel(hky, mu, shape, 4, null);
//treeLikelihood
SitePatterns patterns = new SitePatterns(alignment, null, 0, -1, 1, true);
TreeLikelihood treeLikelihood = new TreeLikelihood(patterns, treeModel, siteModel, null, null, false, false, true, false, false);
assertEquals("treeLikelihoodHKY85G", format.format(-1789.75936), format.format(treeLikelihood.getLogLikelihood()));
}
use of dr.oldevomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.
the class LikelihoodTest method testLikelihoodK80.
public void testLikelihoodK80() {
System.out.println("\nTest Likelihood using K80:");
// Sub model
Parameter freqs = new Parameter.Default(new double[] { 0.25, 0.25, 0.25, 0.25 });
Parameter kappa = new Parameter.Default(HKYParser.KAPPA, 27.402591, 0, 100);
FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
HKY hky = new HKY(kappa, f);
//siteModel
GammaSiteModel siteModel = new GammaSiteModel(hky);
Parameter mu = new Parameter.Default(GammaSiteModelParser.MUTATION_RATE, 1.0, 0, Double.POSITIVE_INFINITY);
siteModel.setMutationRateParameter(mu);
//treeLikelihood
SitePatterns patterns = new SitePatterns(alignment, null, 0, -1, 1, true);
TreeLikelihood treeLikelihood = new TreeLikelihood(patterns, treeModel, siteModel, null, null, false, false, true, false, false);
assertEquals("treeLikelihoodK80", format.format(-1856.30305), format.format(treeLikelihood.getLogLikelihood()));
}
use of dr.oldevomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.
the class TN93Test method testTN93.
public void testTN93() {
for (Instance test : all) {
Parameter kappa1 = new Parameter.Default(1, test.getKappa1());
Parameter kappa2 = new Parameter.Default(1, test.getKappa2());
double[] pi = test.getPi();
Parameter freqs = new Parameter.Default(pi);
FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
TN93 tn93 = new TN93(kappa1, kappa2, f);
double distance = test.getDistance();
double[] mat = new double[4 * 4];
tn93.getTransitionProbabilities(distance, mat);
final double[] result = test.getExpectedResult();
for (int k = 0; k < mat.length; ++k) {
assertEquals(mat[k], result[k], 1e-10);
// System.out.print(" " + (mat[k] - result[k]));
}
}
}
Aggregations