Search in sources :

Example 1 with TN93

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);
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) Variable(dr.inference.model.Variable) TN93(dr.oldevomodel.substmodel.TN93)

Example 2 with TN93

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]));
        }
    }
}
Also used : FrequencyModel(dr.oldevomodel.substmodel.FrequencyModel) TN93(dr.oldevomodel.substmodel.TN93) Parameter(dr.inference.model.Parameter)

Aggregations

FrequencyModel (dr.oldevomodel.substmodel.FrequencyModel)2 TN93 (dr.oldevomodel.substmodel.TN93)2 Parameter (dr.inference.model.Parameter)1 Variable (dr.inference.model.Variable)1