本文整理汇总了Java中beast.evolution.tree.Tree.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getRoot方法的具体用法?Java Tree.getRoot怎么用?Java Tree.getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Tree
的用法示例。
在下文中一共展示了Tree.getRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
* log this sample for current state to PrintStream,
* e.g. value of a parameter, list of parameters or Newick tree
*
* @param nSample chain sample number
* @param out log stream
*/
public void log(int nSample, PrintStream out) {
out.print(nSample+"\t");
Tree tree = (Tree)treeInput.get().getCurrent();
Node root = tree.getRoot();
StateProbabilities sp = densityInput.get().getStateProbabilities();
DoubleMatrix probs = sp.getStateProbs(root.getNr());
if (probs != null) {
for(int i=0; i < numStates; i++)
out.print(probs.get(i)+"\t");
} else {
for(int i=0; i < numStates; i++)
out.print(0.00+"\t");
}
// out.println("");
}
示例2: getConnectingNodes
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom) {
final Node leftChildNode = speciesTreeNode.getLeft();
final Node rightChildNode = speciesTreeNode.getRight();
final int leftChildNodeNumber = leftChildNode.getNr();
final int rightChildNodeNumber = rightChildNode.getNr();
final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);
final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
final List<Tree> geneTrees = geneTreeInput.get();
for (int j = 0; j < nGeneTrees; j++) {
final Tree geneTree = geneTrees.get(j);
final Node geneTreeRootNode = geneTree.getRoot();
final Set<Node> jConnectingNodes = new HashSet<Node>();
findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom);
allConnectingNodes.putAll(j, jConnectingNodes);
geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
}
return allConnectingNodes;
}
示例3: getGraftBranches
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
protected SetMultimap<Integer, Node> getGraftBranches(Node yNode) {
final int yNumber = yNode.getNr();
final Set<String> cousinDescendants = findDescendants(yNode, yNumber);
final SetMultimap<Integer, Node> allGraftBranches = HashMultimap.create();
final List<Tree> geneTrees = geneTreeInput.get();
for (int j = 0; j < nGeneTrees; j++) {
final Tree geneTree = geneTrees.get(j);
final Node geneTreeRootNode = geneTree.getRoot();
final Set<Node> jGraftBranches = new LinkedHashSet<>();
findGraftBranches(geneTreeRootNode, jGraftBranches, cousinDescendants);
allGraftBranches.putAll(j, jGraftBranches);
}
return allGraftBranches;
}
示例4: getConnectingNodes
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private SetMultimap<Integer, Node> getConnectingNodes(Node speciesTreeNode, MinimumDouble tipwardFreedom, MinimumDouble rootwardFreedom) {
final Node leftChildNode = speciesTreeNode.getLeft();
final Node rightChildNode = speciesTreeNode.getRight();
final int leftChildNodeNumber = leftChildNode.getNr();
final int rightChildNodeNumber = rightChildNode.getNr();
final Set<String> leftChildDescendants = findDescendants(leftChildNode, leftChildNodeNumber);
final Set<String> rightChildDescendants = findDescendants(rightChildNode, rightChildNodeNumber);
final SetMultimap<Integer, Node> allConnectingNodes = HashMultimap.create();
final List<Tree> geneTrees = geneTreeInput.get();
for (int j = 0; j < nGeneTrees; j++) {
final Tree geneTree = geneTrees.get(j);
final Node geneTreeRootNode = geneTree.getRoot();
final Set<Node> jConnectingNodes = new HashSet<Node>();
findConnectingNodes(geneTreeRootNode, jConnectingNodes, leftChildDescendants, rightChildDescendants, tipwardFreedom, rootwardFreedom);
allConnectingNodes.putAll(j, jConnectingNodes);
geneTree.startEditing(null); // hack to stop beast.core.State.Trie memory leak
}
return allConnectingNodes;
}
示例5: getAliveNodes
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
public ArrayList<Node> getAliveNodes(Tree base, Double t) {
ArrayList<Node> aliveNodes = new ArrayList<Node>();
Node root = base.getRoot();
for (Node child : root.getChildren()) {
if (child.getHeight() <= t) {
aliveNodes.add(child);
} else {
aliveNodes.addAll(aliveNodes(child, t));
}
}
return aliveNodes;
}
示例6: getIncludedMRCA
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
* @return the node ref of the MRCA of this coalescent prior in the given tree.
*/
protected NodeRef getIncludedMRCA(Tree tree) {
if (includedLeafSet != null) {
return Tree.Utils.getCommonAncestorNode(tree, includedLeafSet);
} else {
return tree.getRoot();
}
}
示例7: bifurcating
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
@Override //WARNING works with bifurcating (exactly 2 children) trees only
// sampled ancestors are assumed to be on zero branches
public double proposal() {
final double scale = getScaler();
final boolean scaleSNodes = false; // m_pScaleSNodes.get();
try {
if (m_bIsTreeScaler) {
Tree tree = treeInput.get(this);
if (rootOnlyInput.get()) {
Node root = tree.getRoot();
if ((root).isFake() && !scaleSNodes) {
return Double.NEGATIVE_INFINITY;
}
double fNewHeight = root.getHeight() * scale;
//make sure the new height doesn't make a parent younger than a child
double oldestChildHeight;
if ((root).isFake()) {
oldestChildHeight = root.getNonDirectAncestorChild().getHeight();
} else oldestChildHeight = Math.max(root.getLeft().getHeight(), root.getRight().getHeight());
if (fNewHeight < oldestChildHeight) {
return Double.NEGATIVE_INFINITY;
}
if ((root).isFake() && scaleSNodes) {
Node directAncestor = root.getLeft();
if (!(directAncestor).isDirectAncestor())
directAncestor = root.getRight();
root.setHeight(fNewHeight);
directAncestor.setHeight(fNewHeight);
} else {
root.setHeight(fNewHeight);
}
return -Math.log(scale);
} else {
// scale the beast.tree
final int nScaledDimensions = tree.scale(scale);
//final int nScaledDimensions = tree.scale(scale, scaleSNodes);
return Math.log(scale) * (nScaledDimensions - 2);
}
}
return Double.NEGATIVE_INFINITY;
} catch (Exception e) {
return Double.NEGATIVE_INFINITY;
}
}
示例8: bifurcating
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
@Override //WARNING works with bifurcating (exactly 2 children) trees only
// sampled ancestors are assumed to be on zero branches
public double proposal() {
final double scale = getScaler();
final boolean scaleSNodes = m_pScaleSNodes.get();
try {
if (m_bIsTreeScaler) {
Tree tree = treeInput.get(this);
if (rootOnlyInput.get()) {
Node root = tree.getRoot();
if (((ZeroBranchSANode)root).isFake() && !scaleSNodes) {
return Double.NEGATIVE_INFINITY;
}
double fNewHeight = root.getHeight() * scale;
//make sure the new height doesn't make a parent younger than a child
double oldestChildHeight;
if (((ZeroBranchSANode)root).isFake()) {
oldestChildHeight = root.getNonDirectAncestorChild().getHeight();
} else oldestChildHeight = Math.max(root.getLeft().getHeight(), root.getRight().getHeight());
if (fNewHeight < oldestChildHeight) {
return Double.NEGATIVE_INFINITY;
}
if (((ZeroBranchSANode)root).isFake() && scaleSNodes) {
Node directAncestor = root.getLeft();
if (!((ZeroBranchSANode)directAncestor).isDirectAncestor())
directAncestor = root.getRight();
root.setHeight(fNewHeight);
directAncestor.setHeight(fNewHeight);
} else {
root.setHeight(fNewHeight);
}
return -Math.log(scale);
} else {
// scale the beast.tree
final int nScaledDimensions = ((ZeroBranchSATree)tree).scale(scale, scaleSNodes);
return Math.log(scale) * (nScaledDimensions - 2);
}
}
return Double.NEGATIVE_INFINITY;
} catch (Exception e) {
return Double.NEGATIVE_INFINITY;
}
}
示例9: getMRCAOfCoalescent
import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
* @param tree given tree
* @return the node ref of the MRCA of this coalescent prior in the given tree (i.e. root of tree)
*/
public NodeRef getMRCAOfCoalescent(Tree tree) {
return tree.getRoot();
}