| 1 |
package test.dr.evomodel.substmodel; |
| 2 |
|
| 3 |
import dr.evolution.tree.TreeUtils; |
| 4 |
import dr.evomodel.siteratemodel.GammaSiteRateModel; |
| 5 |
import dr.evomodel.substmodel.FrequencyModel; |
| 6 |
import dr.evomodel.substmodel.nucleotide.HKY; |
| 7 |
import dr.evolution.datatype.Nucleotides; |
| 8 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 9 |
import dr.evomodel.branchratemodel.DefaultBranchRateModel; |
| 10 |
import dr.inference.markovjumps.MarkovJumpsCore; |
| 11 |
import dr.inference.model.Parameter; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
public class VariableBranchCompleteHistorySimulatorTest extends CompleteHistorySimulatorTest { |
| 17 |
|
| 18 |
public int N = 5000; |
| 19 |
|
| 20 |
public void setUp() throws Exception { |
| 21 |
super.setUp(); |
| 22 |
} |
| 23 |
|
| 24 |
public void testHKYVariableSimulation() { |
| 25 |
|
| 26 |
System.out.println("Starting HKY variable branch simulation"); |
| 27 |
Parameter kappa = new Parameter.Default(1, 2.0); |
| 28 |
double[] pi = {0.45, 0.05, 0.25, 0.25}; |
| 29 |
Parameter freqs = new Parameter.Default(pi); |
| 30 |
FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs); |
| 31 |
HKY hky = new HKY(kappa, f); |
| 32 |
int stateCount = hky.getDataType().getStateCount(); |
| 33 |
|
| 34 |
Parameter mu = new Parameter.Default(1, 0.5); |
| 35 |
Parameter alpha = new Parameter.Default(1, 0.5); |
| 36 |
GammaSiteRateModel siteModel = new GammaSiteRateModel("gammaModel", mu, alpha, 4, null); |
| 37 |
siteModel.setSubstitutionModel(hky); |
| 38 |
BranchRateModel branchRateModel = new DefaultBranchRateModel(); |
| 39 |
|
| 40 |
double analyticResult = TreeUtils.getTreeLength(tree, tree.getRoot()) * mu.getParameterValue(0); |
| 41 |
int nSites = 200; |
| 42 |
|
| 43 |
double[] register1 = new double[stateCount * stateCount]; |
| 44 |
double[] register2 = new double[stateCount * stateCount]; |
| 45 |
|
| 46 |
MarkovJumpsCore.fillRegistrationMatrix(register1, stateCount); |
| 47 |
|
| 48 |
|
| 49 |
register1[1 * stateCount + 2] = 0; |
| 50 |
register2[1 * stateCount + 2] = 1; |
| 51 |
|
| 52 |
register1[1 * stateCount + 3] = 0; |
| 53 |
register2[1 * stateCount + 3] = 1; |
| 54 |
|
| 55 |
register1[2 * stateCount + 3] = 0; |
| 56 |
register2[2 * stateCount + 3] = 1; |
| 57 |
|
| 58 |
double[] branchValues = { 10.0, 10.0, 10.0, 10.0, 10.0 }; |
| 59 |
|
| 60 |
Parameter branchValuesParam = new Parameter.Default(branchValues); |
| 61 |
|
| 62 |
runSimulation(N, tree, siteModel, branchRateModel, nSites, |
| 63 |
new double[][] {register1, register2}, analyticResult, kappa, branchValuesParam); |
| 64 |
} |
| 65 |
|
| 66 |
public void testCodonSimulation() { |
| 67 |
|
| 68 |
} |
| 69 |
} |