Debian Codegraph @

src/dr/evomodel/branchratemodel/AttributeBranchRateModel.java

raw symbols SCIP
1 /*
2 * AttributeBranchRateModel.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.branchratemodel;
27
28 import dr.evolution.tree.NodeRef;
29 import dr.evolution.tree.Tree;
30 import dr.evolution.util.Taxon;
31 import dr.evomodel.branchratemodel.AbstractBranchRateModel;
32 import dr.evomodel.tree.TreeModel;
33 import dr.inference.model.Model;
34 import dr.inference.model.Parameter;
35 import dr.inference.model.Statistic;
36 import dr.inference.model.Variable;
37 import dr.math.MathUtils;
38
39 import java.util.Iterator;
40 import java.util.List;
41
42 /**
43 * @author Andrew Rambaut
44 * @version $Id$
45 */
46 public class AttributeBranchRateModel extends AbstractBranchRateModel {
47
48 public AttributeBranchRateModel(final TreeModel treeModel, final String rateAttributeName) {
49 super(ATTRIBUTE_BRANCH_RATE_MODEL);
50
51 this.treeModel = treeModel;
52 this.rateAttributeName = rateAttributeName;
53
54 addModel(treeModel);
55 }
56
57 @Override
58 protected void handleModelChangedEvent(Model model, Object object, int index) {
59 fireModelChanged();
60 }
61
62 @Override
63 protected void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) {
64 // nothing to do
65 }
66
67 @Override
68 protected void storeState() {
69 // nothing to do
70 }
71
72 @Override
73 protected void restoreState() {
74 // nothing to do
75 }
76
77 @Override
78 protected void acceptState() {
79 // nothing to do
80 }
81
82 @Override
83 public double getBranchRate(Tree tree, NodeRef node) {
84 Object value = tree.getNodeAttribute(node, rateAttributeName);
85 return Double.parseDouble((String)value);
86 }
87
88 @Override
89 public String getTraitName() {
90 return rateAttributeName;
91 }
92
93 public static final String ATTRIBUTE_BRANCH_RATE_MODEL = "attributeBranchRateModel";
94
95 private final TreeModel treeModel;
96 private final String rateAttributeName;
97
98 }