Debian Codegraph @

src/dr/evomodel/tree/TreeTransform.java

raw symbols SCIP
1 /*
2 * TreeTransform.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.tree;
27
28 import dr.evolution.tree.NodeRef;
29 import dr.evolution.tree.Tree;
30 import dr.evolution.tree.TreeTrait;
31 import dr.evolution.tree.TreeTraitProvider;
32 import dr.inference.model.AbstractModel;
33 import dr.inference.model.Model;
34 import dr.inference.model.Variable;
35 import dr.util.Author;
36 import dr.util.Citable;
37 import dr.util.Citation;
38 import dr.util.CommonCitations;
39
40 import java.util.*;
41
42 /**
43 * @author Marc A. Suchard
44 */
45 public abstract class TreeTransform extends AbstractModel implements TreeTraitProvider, Citable {
46
47 public static final String TREE_TRANSFORM_PREFIX = "treeTransform";
48
49 public TreeTransform(String name) {
50 super(name);
51 setupTraits();
52 }
53
54 private void setupTraits() {
55 TreeTrait baseTrait = new TreeTrait.D() {
56
57 public String getTraitName() {
58 return TREE_TRANSFORM_PREFIX;
59 }
60
61 public Intent getIntent() {
62 return Intent.BRANCH;
63 }
64
65 public Double getTrait(Tree tree, NodeRef node) {
66 return getScaleForNode(tree, node);
67 }
68
69 public boolean getLoggable() {
70 return true;
71 }
72 };
73 treeTraits.addTrait(baseTrait);
74 }
75
76 // TODO originalHeight is not necessary to pass anymore; remove
77 public abstract double transform(Tree tree, NodeRef node, double originalHeight);
78
79 protected abstract double getScaleForNode(Tree tree, NodeRef node);
80
81 public abstract String getInfo();
82
83 protected void handleModelChangedEvent(Model model, Object object, int index) {
84 }
85
86 protected void handleVariableChangedEvent(Variable variable, int index, Variable.ChangeType type) {
87 }
88
89 protected void storeState() {
90 }
91
92 protected void restoreState() {
93 }
94
95 protected void acceptState() {
96 }
97
98 public TreeTrait[] getTreeTraits() {
99 return treeTraits.getTreeTraits();
100 }
101
102 public TreeTrait getTreeTrait(String key) {
103 return treeTraits.getTreeTrait(key);
104 }
105
106 private final Helper treeTraits = new Helper();
107
108 @Override
109 public Citation.Category getCategory() {
110 return Citation.Category.TRAIT_MODELS;
111 }
112
113 @Override
114 public String getDescription() {
115 return "Branch-specific phenotypic mixture model";
116 }
117
118 @Override
119 public List<Citation> getCitations() {
120 return Collections.singletonList(CommonCitations.VRANCKEN_2015_SIMULTANEOUSLY);
121 }
122
123
124 }
125