| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package test.dr.app.beagle; |
| 27 |
|
| 28 |
import dr.evomodel.substmodel.EigenDecomposition; |
| 29 |
import dr.evomodel.substmodel.FrequencyModel; |
| 30 |
import dr.evomodel.substmodel.nucleotide.TN93; |
| 31 |
import dr.evolution.datatype.Nucleotides; |
| 32 |
import dr.inference.model.Parameter; |
| 33 |
import dr.math.matrixAlgebra.Vector; |
| 34 |
import test.dr.math.MathTestCase; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class TN93Test extends MathTestCase { |
| 40 |
|
| 41 |
public void testTN93() { |
| 42 |
|
| 43 |
Parameter kappa1 = new Parameter.Default(5.0); |
| 44 |
Parameter kappa2 = new Parameter.Default(2.0); |
| 45 |
double[] pi = new double[]{0.40, 0.20, 0.30, 0.10}; |
| 46 |
double time = 0.1; |
| 47 |
|
| 48 |
FrequencyModel freqModel = new FrequencyModel(Nucleotides.INSTANCE, pi); |
| 49 |
TN93 tn = new TN93(kappa1, kappa2, freqModel); |
| 50 |
|
| 51 |
EigenDecomposition decomp = tn.getEigenDecomposition(); |
| 52 |
|
| 53 |
Vector eval = new Vector(decomp.getEigenValues()); |
| 54 |
System.out.println("Eval = " + eval); |
| 55 |
|
| 56 |
double[] probs = new double[16]; |
| 57 |
tn.getTransitionProbabilities(time, probs); |
| 58 |
System.out.println("new probs = " + new Vector(probs)); |
| 59 |
|
| 60 |
|
| 61 |
dr.oldevomodel.substmodel.FrequencyModel oldFreq = new dr.oldevomodel.substmodel.FrequencyModel(Nucleotides.INSTANCE, pi); |
| 62 |
dr.oldevomodel.substmodel.TN93 oldTN = new dr.oldevomodel.substmodel.TN93(kappa1, kappa2, oldFreq); |
| 63 |
|
| 64 |
double[] oldProbs = new double[16]; |
| 65 |
oldTN.getTransitionProbabilities(time, oldProbs); |
| 66 |
System.out.println("old probs = " + new Vector(oldProbs)); |
| 67 |
assertEquals(probs, oldProbs, 10E-6); |
| 68 |
} |
| 69 |
|
| 70 |
} |