Debian Codegraph @

src/dr/evomodel/branchmodel/ExternalInternalBranchModel.java

raw symbols SCIP
1 /*
2 * ExternalInternalBranchModel.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.branchmodel;
27
28 import dr.evomodel.substmodel.FrequencyModel;
29 import dr.evomodel.substmodel.SubstitutionModel;
30 import dr.evolution.tree.NodeRef;
31 import dr.evomodel.tree.TreeModel;
32 import dr.inference.model.AbstractModel;
33 import dr.inference.model.Model;
34 import dr.inference.model.Variable;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 /**
40 * @author Andrew Rambaut
41 * @author Filip Bielejec
42 * @author Marc A. Suchard
43 * @version $Id$
44 */
45 public class ExternalInternalBranchModel extends AbstractModel implements BranchModel {
46 public ExternalInternalBranchModel(TreeModel tree, SubstitutionModel externalSubstModel, SubstitutionModel internalSubstModel) {
47 super("ExternalInternalBranchModel");
48
49 this.tree = tree;
50 this.externalSubstModel = externalSubstModel;
51 this.internalSubstModel = internalSubstModel;
52
53 addModel(tree);
54 addModel(externalSubstModel);
55 addModel(internalSubstModel);
56 }
57
58 public Mapping getBranchModelMapping(final NodeRef node) {
59 return new Mapping() {
60 public int[] getOrder() {
61 return new int[] { tree.isExternal(node) ? 0 : 1 };
62 }
63
64 public double[] getWeights() {
65 return new double[] { 1.0 };
66 }
67 };
68 }
69
70 // @Override // use java 1.5
71 public List<SubstitutionModel> getSubstitutionModels() {
72 List<SubstitutionModel> substitutionModels = new ArrayList<SubstitutionModel>();
73 substitutionModels.add(externalSubstModel);
74 substitutionModels.add(internalSubstModel);
75 return substitutionModels;
76 }
77
78 // @Override
79 public SubstitutionModel getRootSubstitutionModel() {
80 return internalSubstModel;
81 }
82
83 public FrequencyModel getRootFrequencyModel() {
84 return getRootSubstitutionModel().getFrequencyModel();
85 }
86
87 // @Override
88 public boolean requiresMatrixConvolution() {
89 return false;
90 }
91
92 @Override
93 protected void handleModelChangedEvent(Model model, Object object, int index) {
94 fireModelChanged();
95 }
96
97 @Override
98 protected void handleVariableChangedEvent(Variable variable, int index, Variable.ChangeType type) {
99 }
100
101 @Override
102 protected void storeState() {
103 }
104
105 @Override
106 protected void restoreState() {
107 }
108
109 @Override
110 protected void acceptState() {
111 }
112
113 private final TreeModel tree;
114 private final SubstitutionModel externalSubstModel;
115 private final SubstitutionModel internalSubstModel;
116 }