当前位置: 首页>>代码示例>>Java>>正文


Java Tree.getRoot方法代码示例

本文整理汇总了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("");
}
 
开发者ID:mrc-ide,项目名称:PhyDyn,代码行数:23,代码来源:STreeRootLogger.java

示例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;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:22,代码来源:CoordinatedExponential.java

示例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;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:17,代码来源:CoordinatedExchange.java

示例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;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:22,代码来源:CoordinatedUniform.java

示例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;
}
 
开发者ID:lutrasdebtra,项目名称:Beast-Borrowing-Plugin,代码行数:15,代码来源:LanguageSubsitutionModel.java

示例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();
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:11,代码来源:AbstractCoalescentLikelihood.java

示例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;
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:53,代码来源:SAScaleOperator.java

示例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;
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:52,代码来源:ScaleOperatorForZeroBranchSATrees.java

示例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();
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:8,代码来源:OldAbstractCoalescentLikelihood.java


注:本文中的beast.evolution.tree.Tree.getRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。