Search in sources :

Example 21 with Frequencies

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

the class BinaryCovarionModelTest method doWithTufflySteel.

private void doWithTufflySteel() {
    Frequencies dummyFreqs = new Frequencies();
    dummyFreqs.initByName("frequencies", "0.25 0.25 0.25 0.25", "estimate", false);
    BinaryCovarion substModel;
    double d = 0.05 + Randomizer.nextDouble() * 0.9;
    RealParameter vfrequencies = new RealParameter(new Double[] { d, 1.0 - d });
    RealParameter switchrate = new RealParameter(new Double[] { Randomizer.nextDouble(), Randomizer.nextDouble() });
    substModel = new BinaryCovarion();
    substModel.initByName("frequencies", dummyFreqs, "vfrequencies", vfrequencies, /* [p0, p1] */
    "alpha", "0.01", "switchRate", switchrate, // "eigenSystem", "beast.evolution.substitutionmodel.RobustEigenSystem",
    "mode", "TUFFLEYSTEEL");
    double[] matrix = new double[16];
    substModel.getTransitionProbabilities(null, 1000, 0, 1.0, matrix);
    double h0 = switchrate.getValue(1) / (switchrate.getValue(0) + switchrate.getValue(1));
    double h1 = switchrate.getValue(0) / (switchrate.getValue(0) + switchrate.getValue(1));
    double[] baseFreqs = new double[] { vfrequencies.getValue(0) * h0, vfrequencies.getValue(1) * h0, vfrequencies.getValue(0) * h1, vfrequencies.getValue(1) * h1 };
    System.err.println("Expected: " + Arrays.toString(baseFreqs));
    System.err.println("Calculat: " + Arrays.toString(matrix));
    for (int j = 0; j < 4; j++) {
        assertEquals(baseFreqs[j], matrix[j], 1e-3);
    }
}
Also used : BinaryCovarion(beast.evolution.substitutionmodel.BinaryCovarion) RealParameter(beast.core.parameter.RealParameter) Frequencies(beast.evolution.substitutionmodel.Frequencies)

Aggregations

Frequencies (beast.evolution.substitutionmodel.Frequencies)21 SiteModel (beast.evolution.sitemodel.SiteModel)14 Alignment (beast.evolution.alignment.Alignment)13 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)13 TreeLikelihood (beast.evolution.likelihood.TreeLikelihood)13 Tree (beast.evolution.tree.Tree)13 Test (org.junit.Test)13 UncertainAlignmentTest (test.beast.evolution.alignment.UncertainAlignmentTest)13 RealParameter (beast.core.parameter.RealParameter)10 HKY (beast.evolution.substitutionmodel.HKY)8 GeneralSubstitutionModel (beast.evolution.substitutionmodel.GeneralSubstitutionModel)5 Sequence (beast.evolution.alignment.Sequence)3 BinaryCovarion (beast.evolution.substitutionmodel.BinaryCovarion)3 GTR (beast.evolution.substitutionmodel.GTR)2 UserDataType (beast.evolution.datatype.UserDataType)1 MutationDeathModel (beast.evolution.substitutionmodel.MutationDeathModel)1 JComboBox (javax.swing.JComboBox)1