Debian Codegraph @

src/dr/evomodel/continuous/AncestralTaxonInTree.java

raw symbols SCIP
1 /*
2 * RestrictedPartials.java
3 *
4 * Copyright (c) 2002-2016 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.continuous;
27
28 import dr.evolution.tree.MutableTreeModel;
29 import dr.evolution.tree.NodeRef;
30 import dr.evolution.tree.TreeUtils;
31 import dr.evolution.util.Taxon;
32 import dr.evolution.util.TaxonList;
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 import java.util.BitSet;
39 import java.util.Set;
40
41 /**
42 * @author Marc A. Suchard
43 */
44 public class AncestralTaxonInTree extends AbstractModel {
45
46 public AncestralTaxonInTree(Taxon ancestor,
47 MutableTreeModel treeModel,
48 TaxonList taxonList,
49 Parameter priorSampleSize) throws TreeUtils.MissingTaxonException {
50 this(ancestor, treeModel, taxonList, priorSampleSize, null, -1);
51 }
52
53 public AncestralTaxonInTree(Taxon ancestor,
54 MutableTreeModel treeModel,
55 TaxonList descendents,
56 Parameter priorSampleSize,
57 NodeRef node, int index) throws TreeUtils.MissingTaxonException {
58
59 super(ancestor.getId());
60
61 this.ancestor = ancestor;
62 this.treeModel = treeModel;
63 this.descendents = descendents;
64 this.pseudoBranchLength = priorSampleSize;
65 this.index = index;
66 this.node = node;
67
68 this.tips = TreeUtils.getTipsForTaxa(treeModel, descendents);
69 this.tipBitSet = TreeUtils.getTipsBitSetForTaxa(treeModel, descendents);
70
71 addVariable(priorSampleSize);
72 }
73
74 // Public API
75
76 final public double getPseudoBranchLength() {
77 return pseudoBranchLength.getParameterValue(0);
78 }
79
80 final MutableTreeModel getTreeModel() { return treeModel; }
81
82 // final double[] getPartials() { return meanParameter.getParameterValues(); }
83
84 // final double getPartial(int i) { return meanParameter.getParameterValue(i); }
85
86 // final double getPriorSampleSize() { return pseudoBranchLength.getParameterValue(0); }
87
88 final double[] getRestrictedPartials() {
89 assert(false);
90 return null;
91 }
92
93 // final PrecisionType getPrecisionType() {
94 // assert(false);
95 // return PrecisionType.SCALAR;
96 // }
97
98 final public int getIndex() { return index; }
99
100 final public void setIndex(int index) { this.index = index; }
101
102 final public NodeRef getNode() { return node; }
103
104 final public void setNode(NodeRef node) { this.node = node; }
105
106 // AbstractModel implementation
107
108 @Override
109 protected void handleModelChangedEvent(Model model, Object object, int index) {
110 throw new RuntimeException("Not yet implemented");
111 }
112
113 @Override
114 protected void storeState() {
115
116 }
117
118 @Override
119 protected void restoreState() {
120
121 }
122
123 @Override
124 protected void acceptState() {
125
126 }
127
128 @Override
129 protected void handleVariableChangedEvent(Variable variable, int index, Parameter.ChangeType type) {
130 fireModelChanged(variable, index);
131 }
132
133 final private Taxon ancestor;
134 final private MutableTreeModel treeModel;
135 final private TaxonList descendents;
136
137 final private Set<Integer> tips;
138 final private BitSet tipBitSet;
139
140 final private Parameter pseudoBranchLength;
141
142 private int index;
143 private NodeRef node;
144
145 public TaxonList getTaxonList() {
146 return descendents;
147 }
148
149 public BitSet getTipBitSet() {
150 return tipBitSet;
151 }
152
153 public Taxon getTaxon() {
154 return ancestor;
155 }
156 }