| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 |
|
| 37 |
|
| 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); |
| 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 |
} |