use of dr.oldevomodel.substmodel.TN93 in project beast-mcmc by beast-dev.
the class TN93Parser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Variable kappa1Param = (Variable) xo.getElementFirstChild(KAPPA1);
Variable kappa2Param = (Variable) xo.getElementFirstChild(KAPPA2);
FrequencyModel freqModel = (FrequencyModel) xo.getElementFirstChild(FREQUENCIES);
Logger.getLogger("dr.evomodel").info("Creating TN93 substitution model. Initial kappa = " + kappa1Param.getValue(0) + "," + kappa2Param.getValue(0));
return new TN93(kappa1Param, kappa2Param, freqModel);
}
use of dr.oldevomodel.substmodel.TN93 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