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


Java Tree.getChild方法代码示例

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


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

import beast.evolution.tree.Tree; //导入方法依赖的package包/类
/**
* @param tree   the tree
* @param parent the parent
* @param child  the child that you want the sister of
* @return the other child of the given parent.
*/
  protected NodeRef getOtherChild(Tree tree, NodeRef parent, NodeRef child) {
      if( tree.getChild(parent, 0) == child ) {
          return tree.getChild(parent, 1);
      } else {
          return tree.getChild(parent, 0);
      }
  }
 
开发者ID:armanbilge,项目名称:B3,代码行数:14,代码来源:AbstractTreeOperator.java

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