Debian Codegraph @

src/dr/evomodel/arg/ARGRelaxedClock.java

raw symbols SCIP
1 /*
2 * ARGRelaxedClock.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.evomodel.arg;
27
28 import dr.evolution.tree.NodeRef;
29 import dr.evolution.tree.Tree;
30 import dr.evomodel.arg.ARGModel.Node;
31 import dr.evomodel.branchratemodel.AbstractBranchRateModel;
32 import dr.inference.model.Model;
33 import dr.inference.model.Parameter;
34 import dr.inference.model.Variable;
35 import dr.inference.model.Variable.ChangeType;
36 import dr.xml.*;
37
38 public class ARGRelaxedClock extends AbstractBranchRateModel {
39
40 public static final String ARG_LOCAL_CLOCK = "argLocalClock";
41 public static final String PARTITION = "partition";
42
43 private Parameter globalRateParameter;
44
45 private ARGModel arg;
46 private int partition;
47
48
49 public ARGRelaxedClock(String name) {
50 super(name);
51 }
52
53 public ARGRelaxedClock(String name, ARGModel arg, int partition, Parameter rate) {
54 super(name);
55
56 this.arg = arg;
57 this.partition = partition;
58
59 globalRateParameter = rate;
60
61 addModel(arg);
62 addVariable(rate);
63 }
64
65 protected void acceptState() {
66
67 }
68
69 protected void handleModelChangedEvent(Model model, Object object, int index) {
70 //do nothing
71 }
72
73
74 protected void handleVariableChangedEvent(Variable variable, int index, ChangeType type) {
75 //do nothing
76 }
77
78
79 protected void restoreState() {
80
81 }
82
83
84 protected void storeState() {
85
86 }
87
88 public double getBranchRate(Tree tree, NodeRef nodeRef) {
89
90 Node treeNode = (Node) nodeRef;
91 Node argNode = (Node) treeNode.mirrorNode;
92
93
94 return globalRateParameter.getParameterValue(0) * argNode.getRate(partition);
95 }
96
97 public static XMLObjectParser PARSER = new AbstractXMLObjectParser() {
98
99 public String getParserDescription() {
100 return null;
101 }
102
103 public Class getReturnType() {
104
105 return ARGRelaxedClock.class;
106 }
107
108 public XMLSyntaxRule[] getSyntaxRules() {
109
110 return null;
111 }
112
113 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
114
115 ARGModel arg = (ARGModel) xo.getChild(ARGModel.class);
116
117 int partition = xo.getAttribute(PARTITION, 0);
118
119 Parameter rate = (Parameter) xo.getChild(Parameter.class);
120
121 return new ARGRelaxedClock("", arg, partition, rate);
122 }
123
124 public String getParserName() {
125 return ARG_LOCAL_CLOCK;
126 }
127
128 };
129
130 }