Debian Codegraph @

src/dr/evomodel/treelikelihood/AbstractSinglePartitionTreeLikelihood.java

raw symbols SCIP
1 /*
2 * AbstractSinglePartitionTreeLikelihood.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.treelikelihood;
27 /**
28 * ${CLASS_NAME}
29 *
30 * @author Andrew Rambaut
31 * @version $Id$
32 *
33 * $HeadURL$
34 *
35 * $LastChangedBy$
36 * $LastChangedDate$
37 * $LastChangedRevision$
38 */
39
40 import dr.evolution.alignment.PatternList;
41 import dr.evolution.datatype.DataType;
42 import dr.evomodel.tree.TreeModel;
43
44 public abstract class AbstractSinglePartitionTreeLikelihood extends AbstractTreeLikelihood {
45 public AbstractSinglePartitionTreeLikelihood(String name, PatternList patternList, TreeModel treeModel) {
46 super(name, treeModel);
47
48 this.patternList = patternList;
49 this.dataType = patternList.getDataType();
50 patternCount = patternList.getPatternCount();
51 stateCount = dataType.getStateCount();
52
53 patternWeights = patternList.getPatternWeights();
54
55 }
56
57 /**
58 * Set update flag for a pattern
59 */
60 protected void updatePattern(int i) {
61 if (updatePattern != null) {
62 updatePattern[i] = true;
63 }
64 likelihoodKnown = false;
65 }
66
67 /**
68 * Set update flag for all patterns
69 */
70 protected void updateAllPatterns() {
71 if (updatePattern != null) {
72 for (int i = 0; i < patternCount; i++) {
73 updatePattern[i] = true;
74 }
75 }
76 likelihoodKnown = false;
77 }
78
79 public final double[] getPatternWeights() {
80 return patternWeights;
81 }
82
83 /**
84 * Forces a complete recalculation of the likelihood next time getLikelihood is called
85 */
86 public void makeDirty() {
87 super.makeDirty();
88 updateAllPatterns();
89 }
90
91 /**
92 * the patternList
93 */
94 protected PatternList patternList = null;
95 protected DataType dataType = null;
96
97 /**
98 * the pattern weights
99 */
100 protected double[] patternWeights;
101
102 /**
103 * the number of patterns
104 */
105 protected int patternCount;
106
107 /**
108 * the number of states in the data
109 */
110 protected int stateCount;
111
112 /**
113 * Flags to specify which patterns are to be updated
114 */
115 protected boolean[] updatePattern = null;
116
117
118 }