| 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 dr.oldevomodel.treelikelihood; |
| 27 |
|
| 28 |
import dr.evolution.tree.NodeRef; |
| 29 |
import dr.evolution.tree.Tree; |
| 30 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 31 |
import dr.oldevomodel.sitemodel.SiteModel; |
| 32 |
import dr.oldevomodel.substmodel.SubstitutionModel; |
| 33 |
import dr.inference.model.AbstractModel; |
| 34 |
import dr.inference.model.Model; |
| 35 |
import dr.inference.model.Parameter; |
| 36 |
import dr.inference.model.Variable; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
@Deprecated |
| 45 |
public class TreeBranchSubstitutionModel extends AbstractModel { |
| 46 |
|
| 47 |
public TreeBranchSubstitutionModel(String name) { |
| 48 |
super(name); |
| 49 |
} |
| 50 |
|
| 51 |
public TreeBranchSubstitutionModel(String name, SiteModel siteModel, SubstitutionModel substModel, BranchRateModel branchModel) { |
| 52 |
super(name); |
| 53 |
this.siteModel = siteModel; |
| 54 |
this.substModel = substModel; |
| 55 |
this.branchModel = branchModel; |
| 56 |
|
| 57 |
if (siteModel != null) |
| 58 |
addModel(siteModel); |
| 59 |
if (substModel != null) |
| 60 |
addModel(substModel); |
| 61 |
if (branchModel != null) |
| 62 |
addModel(branchModel); |
| 63 |
} |
| 64 |
|
| 65 |
public void getTransitionProbabilities(Tree tree, NodeRef node, int rateCategory, double[] probs) { |
| 66 |
|
| 67 |
NodeRef parent = tree.getParent(node); |
| 68 |
|
| 69 |
final double branchRate = branchModel.getBranchRate(tree, node); |
| 70 |
|
| 71 |
|
| 72 |
final double branchTime = branchRate * (tree.getNodeHeight(parent) - tree.getNodeHeight(node)); |
| 73 |
|
| 74 |
if (branchTime < 0.0) { |
| 75 |
throw new RuntimeException("Negative branch length: " + branchTime); |
| 76 |
} |
| 77 |
|
| 78 |
double branchLength = siteModel.getRateForCategory(rateCategory) * branchTime; |
| 79 |
substModel.getTransitionProbabilities(branchLength, probs); |
| 80 |
} |
| 81 |
|
| 82 |
protected void handleModelChangedEvent(Model model, Object object, int index) { |
| 83 |
} |
| 84 |
|
| 85 |
protected void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) { |
| 86 |
} |
| 87 |
|
| 88 |
protected void storeState() { |
| 89 |
} |
| 90 |
|
| 91 |
protected void restoreState() { |
| 92 |
} |
| 93 |
|
| 94 |
protected void acceptState() { |
| 95 |
} |
| 96 |
|
| 97 |
protected SiteModel siteModel; |
| 98 |
protected SubstitutionModel substModel; |
| 99 |
protected BranchRateModel branchModel; |
| 100 |
|
| 101 |
} |