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


Java Tree.getChildCount方法代码示例

本文整理汇总了Java中beast.evolution.tree.Tree.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.getChildCount方法的具体用法?Java Tree.getChildCount怎么用?Java Tree.getChildCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在beast.evolution.tree.Tree的用法示例。


在下文中一共展示了Tree.getChildCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectTimes

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * extract coalescent times and tip information into ArrayList times from tree.
 *
 * @param tree      the tree
 * @param node      the node to start from
 * @param intervals the intervals object to store the events
 */
private void collectTimes(Tree tree, NodeRef node, Set<NodeRef> excludeNodesBelow, Intervals intervals) {

    intervals.addCoalescentEvent(tree.getNodeHeight(node));

    for (int i = 0; i < tree.getChildCount(node); i++) {
        NodeRef child = tree.getChild(node, i);

        // check if this subtree is included in the coalescent density
        boolean include = true;

        if (excludeNodesBelow != null && excludeNodesBelow.contains(child)) {
            include = false;
        }

        if (!include || tree.isExternal(child)) {
            intervals.addSampleEvent(tree.getNodeHeight(child));
        } else {
            collectTimes(tree, child, excludeNodesBelow, intervals);
        }
    }

}
 
开发者ID:armanbilge,项目名称:B3,代码行数:30,代码来源:AbstractCoalescentLikelihood.java

示例2: collectAllTimes

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * Extract coalescent times and tip information into ArrayList times from tree.
 * Upon return times contain the time of each node in the subtree below top, and at the corrosponding index
 * of childs is the descendent count for that time.
 *
 * @param top          the node to start from
 * @param excludeBelow an optional array of nodes to exclude (corresponding subtrees) from density.
 * @param tree         given tree
 * @param times        array to fill with times
 * @param childs       array to fill with descendents count
 */
private static void collectAllTimes(Tree tree, NodeRef top, NodeRef[] excludeBelow,
                                    ArrayList<Double> times, ArrayList<Integer> childs) {

    times.add(tree.getNodeHeight(top));
    childs.add(tree.getChildCount(top));

    for (int i = 0; i < tree.getChildCount(top); i++) {
        NodeRef child = tree.getChild(top, i);
        if (excludeBelow == null) {
            collectAllTimes(tree, child, excludeBelow, times, childs);
        } else {
            // check if this subtree is included in the coalescent density
            boolean include = true;
            for (NodeRef anExcludeBelow : excludeBelow) {
                if (anExcludeBelow.getNumber() == child.getNumber()) {
                    include = false;
                    break;
                }
            }
            if (include)
                collectAllTimes(tree, child, excludeBelow, times, childs);
        }
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:36,代码来源:OldAbstractCoalescentLikelihood.java

示例3: intersectingEdges

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
private int intersectingEdges(Tree tree, NodeRef node, double height, List<NodeRef> directChildren) {

        final NodeRef parent = tree.getParent(node);

        if (tree.getNodeHeight(parent) < height) return 0;

        if (tree.getNodeHeight(node) < height) {
            if (directChildren != null) directChildren.add(node);
            return 1;
        }

        int count = 0;
        for (int i = 0; i < tree.getChildCount(node); i++) {
            count += intersectingEdges(tree, tree.getChild(node, i), height, directChildren);
        }
        return count;
    }
 
开发者ID:armanbilge,项目名称:B3,代码行数:18,代码来源:SubtreeSlideOperator.java

示例4: collectTimes

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * extract coalescent times and tip information into array times from tree.
 */
private static void collectTimes(Tree tree, double[] times, int[] childCounts) {

    for (int i = 0; i < tree.getNodeCount(); i++) {
        NodeRef node = tree.getNode(i);
        times[i] = tree.getNodeHeight(node);
        childCounts[i] = tree.getChildCount(node);
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:12,代码来源:TreeIntervals.java

示例5: addNodeStructure

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * Recursive algorithm to copy a proposed tree structure into the current treeModel.
 */
private void addNodeStructure(Tree donorTree, NodeRef donorNode) {

    NodeRef acceptorNode = null;
    if (donorTree.isExternal(donorNode)) {
        //external nodes can have different numbers between both trees
        acceptorNode = this.nodes[this.getTaxonIndex(donorTree.getTaxonId(donorNode.getNumber()))];
    } else {
        //not really important for internal nodes
        acceptorNode = this.nodes[donorNode.getNumber()];
    }

    setNodeHeight(acceptorNode, donorTree.getNodeHeight(donorNode));

    //removing all child nodes up front currently works
    //((Node)acceptorNode).leftChild = null;
    //((Node)acceptorNode).rightChild = null;
    /*int nrChildren = getChildCount(acceptorNode);
      for (int i = 0; i < nrChildren; i++) {
          this.removeChild(acceptorNode, this.getChild(acceptorNode, i));
      }*/

    for (int i = 0; i < donorTree.getChildCount(donorNode); i++) {
        //add a check when the added child is an external node
        if (donorTree.isExternal(donorTree.getChild(donorNode, i))) {
            addChild(acceptorNode, this.nodes[this.getTaxonIndex(donorTree.getTaxonId(donorTree.getChild(donorNode, i).getNumber()))]);
        } else {
            addChild(acceptorNode, this.nodes[donorTree.getChild(donorNode, i).getNumber()]);
        }
    }

    pushTreeChangedEvent(acceptorNode);

    if (!donorTree.isExternal(donorNode)) {
        for (int i = 0; i < donorTree.getChildCount(donorNode); i++) {
            addNodeStructure(donorTree, donorTree.getChild(donorNode, i));
        }
    }

}
 
开发者ID:armanbilge,项目名称:B3,代码行数:43,代码来源:TreeModel.java

示例6: Node

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * constructor used to clone a node and all children
 */
public Node(Tree tree, NodeRef node) {
    parent = null;
    leftChild = rightChild = null;

    heightParameter = new Parameter.Default(tree.getNodeHeight(node));
    addVariable(heightParameter);

    number = node.getNumber();
    taxon = tree.getNodeTaxon(node);
    heightParameter.setId("" + number);
    for (int i = 0; i < tree.getChildCount(node); i++) {
        addChild(new Node(tree, tree.getChild(node, i)));
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:18,代码来源:TreeModel.java

示例7: calculateNodeLogLikelihood

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
 * Alternative likelihood calculation that uses recursion over the tree and allows
 * a list of taxa to exclude
 *
 * @param tree    the tree
 * @param node
 * @param exclude a list of taxa to exclude
 * @param lnL     a reference to the lnL sum
 * @return the number of included daughter nodes
 */
private int calculateNodeLogLikelihood(Tree tree, NodeRef node, Set<Taxon> exclude, double[] lnL) {
    if (tree.isExternal(node)) {
        if (!exclude.contains(tree.getNodeTaxon(node))) {
            if (includeExternalNodesInLikelihoodCalculation()) {
                lnL[0] += logNodeProbability(tree, node);
            }

            // this tip is included in the subtree...
            return 1;
        }

        // this tip is excluded from the subtree...
        return 0;
    } else {
        int count = 0;
        for (int i = 0; i < tree.getChildCount(node); i++) {
            NodeRef child = tree.getChild(node, i);
            count += calculateNodeLogLikelihood(tree, child, exclude, lnL);
        }

        if (count == 2) {
            // this node is included in the subtree...
            lnL[0] += logNodeProbability(tree, node);
        }

        // if at least one of the children has included tips then return 1 otherwise 0
        return count > 0 ? 1 : 0;
    }
}
 
开发者ID:armanbilge,项目名称:B3,代码行数:40,代码来源:UltrametricSpeciationModel.java


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