Debian Codegraph @

src/dr/oldevomodel/treelikelihood/TreeBranchSubstitutionModel.java

raw symbols SCIP
1 /*
2 * TreeBranchSubstitutionModel.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * TreeBranchSubstitutionModel - provides a model for making substitution model epoches.
40 *
41 * @author Marc A. Suchard
42 */
43
44 @Deprecated // Switching to BEAGLE
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 // Get the operational time of the branch
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 } // getTransitionProbabilities
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 }