use of dr.evomodel.continuous.AncestralTaxonInTree in project beast-mcmc by beast-dev.
the class AncestralTraitTreeModel method recursiveSetupMrcaClamps.
private static void recursiveSetupMrcaClamps(Tree tree, NodeRef node, BitSet tips, Map<BitSet, AncestralTaxonInTree> clampList, Map<Integer, List<AncestralTaxonInTree>> nodeToClampMap) {
if (tree.isExternal(node)) {
tips.set(node.getNumber());
} else {
for (int i = 0; i < tree.getChildCount(node); i++) {
NodeRef child = tree.getChild(node, i);
BitSet childTips = new BitSet();
recursiveSetupMrcaClamps(tree, child, childTips, clampList, nodeToClampMap);
tips.or(childTips);
}
if (clampList.containsKey(tips)) {
AncestralTaxonInTree partials = clampList.get(tips);
partials.setNode(node);
addAncestralTaxonToMap(nodeToClampMap, node.getNumber(), partials);
}
}
}
use of dr.evomodel.continuous.AncestralTaxonInTree in project beast-mcmc by beast-dev.
the class AncestralTraitTreeModel method setupAncestralPathClamps.
// private void addAllAncestralNodeHeightParameterBelow(NodeRef node) {
// addAncestralNodeHeightParameter(node);
// for (int i = 0; i < treeModel.getChildCount(node); ++i) {
// addAllAncestralNodeHeightParameterBelow(treeModel.getChild(node, i));
// }
// }
private void setupAncestralPathClamps(Tree tree, Map<BitSet, AncestralTaxonInTree> clampList, Map<Integer, List<AncestralTaxonInTree>> nodeToClampMap) {
hasAncestralPathTaxa = false;
ancestralPathNodeHeightParameters.clear();
for (int i = 0; i < tree.getExternalNodeCount(); ++i) {
NodeRef node = tree.getExternalNode(i);
BitSet tip = new BitSet();
tip.set(node.getNumber());
if (clampList.containsKey(tip)) {
AncestralTaxonInTree partials = clampList.get(tip);
partials.setTipNode(node);
addAncestralNodeHeightParameter(node);
double pathHeight = partials.getHeight();
assert (pathHeight > 0.0);
NodeRef parent = tree.getParent(node);
double parentHeight = tree.getNodeHeight(parent);
boolean isChild0 = tree.getChild(parent, 0) == node;
while (parentHeight < pathHeight && parent != tree.getRoot()) {
node = parent;
addAncestralNodeHeightParameter(node);
parent = tree.getParent(parent);
parentHeight = tree.getNodeHeight(parent);
isChild0 = tree.getChild(parent, 0) == node;
}
addAncestralNodeHeightParameter(parent);
partials.setNode(parent, isChild0 ? 0 : 1);
addAncestralTaxonToMap(nodeToClampMap, parent.getNumber(), partials);
hasAncestralPathTaxa = true;
}
}
}
Aggregations