Debian Codegraph @

src/dr/evomodel/continuous/MissingTraits.java

raw symbols SCIP
1 /*
2 * MissingTraits.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.continuous;
27
28 import dr.evolution.tree.MutableTreeModel;
29 import dr.evomodel.tree.TreeModel;
30
31 import java.util.Arrays;
32 import java.util.List;
33 import java.util.logging.Logger;
34
35 /**
36 * @author Marc A. Suchard
37 * @author Guy Baele
38 */
39 public interface MissingTraits {
40
41 public void handleMissingTips();
42
43 public boolean isCompletelyMissing(int index);
44
45 public boolean isPartiallyMissing(int index);
46
47 void computeWeightedAverage(double[] meanCache, int meanOffset0, double precision0,
48 int meanOffset1, double precision1, int meanThisOffset, int dim);
49
50 abstract class Abstract implements MissingTraits {
51
52 protected static final boolean DEBUG = false;
53
54 Abstract(MutableTreeModel treeModel, List<Integer> missingIndices, int dim) {
55 this.treeModel = treeModel;
56 this.dim = dim;
57 this.missingIndices = missingIndices;
58
59 completelyMissing = new boolean[treeModel.getNodeCount()];
60 Arrays.fill(completelyMissing, 0, treeModel.getExternalNodeCount(), false);
61 Arrays.fill(completelyMissing, treeModel.getExternalNodeCount(), treeModel.getNodeCount(), true); // All internal and root nodes are missing
62 }
63
64 final protected MutableTreeModel treeModel;
65 final protected int dim;
66 final protected List<Integer> missingIndices;
67 final protected boolean[] completelyMissing;
68 }
69
70 public class CompletelyMissing extends Abstract {
71
72 CompletelyMissing(MutableTreeModel treeModel, List<Integer> missingIndices, int dim) {
73 super(treeModel, missingIndices, dim);
74 }
75
76 public void handleMissingTips() {
77 for (Integer i : missingIndices) {
78 int whichTip = i / dim;
79 Logger.getLogger("dr.evomodel").info(
80 "\tMarking taxon " + treeModel.getTaxonId(whichTip) + " as completely missing");
81 completelyMissing[whichTip] = true;
82 }
83 }
84
85 public boolean isCompletelyMissing(int index) {
86 return completelyMissing[index];
87 }
88
89 public boolean isPartiallyMissing(int index) {
90 return false;
91 }
92
93 public void computeWeightedAverage(double[] meanCache,
94 int meanOffset0, double precision0,
95 int meanOffset1, double precision1,
96 int meanThisOffset, int dim) {
97 IntegratedMultivariateTraitLikelihood.computeWeightedAverage(
98 meanCache, meanOffset0, precision0,
99 meanCache, meanOffset1, precision1,
100 meanCache, meanThisOffset, dim);
101 }
102 }
103
104 public class PartiallyMissing extends Abstract {
105
106 PartiallyMissing(TreeModel treeModel, List<Integer> missingIndices, int dim) {
107 super(treeModel, missingIndices, dim);
108 }
109
110 public void handleMissingTips() {
111 throw new RuntimeException("Not yet implemented");
112 }
113
114 public boolean isCompletelyMissing(int index) {
115 throw new RuntimeException("Not yet implemented");
116 }
117
118 public boolean isPartiallyMissing(int index) {
119 throw new RuntimeException("Not yet implemented");
120 }
121
122 public void computeWeightedAverage(double[] meanCache, int meanOffset0, double precision0, int meanOffset1, double precision1, int meanThisOffset, int dim) {
123 throw new RuntimeException("Not yet implemented");
124 }
125 }
126 }