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


Java PopulationFunction类代码示例

本文整理汇总了Java中beast.evolution.tree.coalescent.PopulationFunction的典型用法代码示例。如果您正苦于以下问题:Java PopulationFunction类的具体用法?Java PopulationFunction怎么用?Java PopulationFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: simulateCoalescent

import beast.evolution.tree.coalescent.PopulationFunction; //导入依赖的package包/类
/**
 * @param nodes
 * @param demographic
 * @return the root node of the given array of nodes after simulation of the
 *         coalescent under the given demographic model.
 * @throws beast.evolution.tree.RandomTree.ConstraintViolatedException
 */
public Node simulateCoalescent(boolean isStronglyMonophyletic, final List<Node> nodes, final PopulationFunction demographic) throws ConstraintViolatedException {
    // sanity check - disjoint trees

    // if( ! Tree.Utils.allDisjoint(nodes) ) {
    // throw new RuntimeException("non disjoint trees");
    // }

    if (nodes.size() == 0) {
        throw new IllegalArgumentException("empty nodes set");
    }

    for (int attempts = 0; attempts < 1000; ++attempts) {
        final List<Node> rootNode = simulateCoalescent(isStronglyMonophyletic, nodes, demographic, 0.0, Double.POSITIVE_INFINITY);
        if (rootNode.size() == 1) {
            return rootNode.get(0);
        }
    }

    throw new RuntimeException("failed to merge trees after 1000 tries!");
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:28,代码来源:ZeroBranchSARandomTree.java

示例2: simulateCoalescentWithMax

import beast.evolution.tree.coalescent.PopulationFunction; //导入依赖的package包/类
@Override
    public Node simulateCoalescentWithMax(List<Node> nodes, PopulationFunction demographic, final double maxHeight) {
        // sanity check - disjoint trees

//        if( ! Tree.Utils.allDisjoint(nodes) ) {
//            throw new RuntimeException("non disjoint trees");
//        }

        if (nodes.size() == 0) {
            throw new IllegalArgumentException("empty nodes set");
        }

        final double lowestHeight = speciesTreeInput.get().getRoot().getHeight();

        for (int attempts = 0; attempts < 1000; ++attempts) {
            try {
                final List<Node> rootNode = simulateCoalescent(nodes, demographic, lowestHeight, maxHeight);
                if (rootNode.size() == 1) {
                    return rootNode.get(0);
                }
            } catch (ConstraintViolatedException e) {
                // TODO: handle exception
            }
        }

        throw new RuntimeException("failed to merge trees after 1000 tries!");
    }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:28,代码来源:RandomGeneTree.java

示例3: simulateCoalescentWithMax

import beast.evolution.tree.coalescent.PopulationFunction; //导入依赖的package包/类
/**
 * @param nodes
 * @param demographic
 * @return the root node of the given array of nodes after simulation of the
 *         coalescent under the given demographic model.
 * @throws beast.evolution.tree.RandomTree.ConstraintViolatedException
 */
public Node simulateCoalescentWithMax(final List<Node> nodes, final PopulationFunction demographic,
                                      final double maxHeight) throws ConstraintViolatedException {
    // sanity check - disjoint trees

    // if( ! Tree.Utils.allDisjoint(nodes) ) {
    // throw new RuntimeException("non disjoint trees");
    // }

    if (nodes.size() == 0) {
        throw new IllegalArgumentException("empty nodes set");
    }

    for (int attempts = 0; attempts < 1000; ++attempts) {
        final List<Node> rootNode = simulateCoalescent(nodes, demographic, 0.0, maxHeight);
        if (rootNode.size() == 1) {
            return rootNode.get(0);
        }
    }

    if( Double.isFinite(maxHeight) ){
        double h = -1;

        for( Node n : nodeList ) {
            h = Math.max(h, n.getHeight());
        }
        assert h < maxHeight;
        double dt = (maxHeight - h)/ (nodeList.size() + 1);
        while (nodeList.size() > 1) {
            int k = nodeList.size() - 1;
            final Node left = nodeList.remove(k);
            final Node right = nodeList.get(k-1);
            final Node newNode = newNode();
            newNode.setNr(nextNodeNr++);   // multiple tries may generate an excess of nodes assert(nextNodeNr <= nrOfTaxa*2-1);
            newNode.setHeight(h + dt);
            newNode.setLeft(left);
            left.setParent(newNode);
            newNode.setRight(right);
            right.setParent(newNode);
            nodeList.set(k-1, newNode);
        }
        assert (nodeList.size() == 1);
        return nodeList.get(0);
    }
    throw new RuntimeException("failed to merge trees after 1000 tries!");
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:53,代码来源:RandomTree.java

示例4: simulateCoalescent

import beast.evolution.tree.coalescent.PopulationFunction; //导入依赖的package包/类
public List<Node> simulateCoalescent(final List<Node> nodes, final PopulationFunction demographic, double currentHeight,
                                     final double maxHeight) throws ConstraintViolatedException {
    // If only one node, return it
    // continuing results in an infinite loop
    if (nodes.size() == 1)
        return nodes;

    final double[] heights = new double[nodes.size()];
    for (int i = 0; i < nodes.size(); i++) {
        heights[i] = nodes.get(i).getHeight();
    }
    final int[] indices = new int[nodes.size()];
    HeapSort.sort(heights, indices);

    // node list
    nodeList.clear();
    activeNodeCount = 0;
    for (int i = 0; i < nodes.size(); i++) {
        nodeList.add(nodes.get(indices[i]));
    }
    setCurrentHeight(currentHeight);

    // get at least two tips
    while (getActiveNodeCount() < 2) {
        currentHeight = getMinimumInactiveHeight();
        setCurrentHeight(currentHeight);
    }

    // simulate coalescent events
    double nextCoalescentHeight = currentHeight
            + PopulationFunction.Utils.getSimulatedInterval(demographic, getActiveNodeCount(), currentHeight);

    // while (nextCoalescentHeight < maxHeight && (getNodeCount() > 1)) {
    while (nextCoalescentHeight < maxHeight && (nodeList.size() > 1)) {

        if (nextCoalescentHeight >= getMinimumInactiveHeight()) {
            currentHeight = getMinimumInactiveHeight();
            setCurrentHeight(currentHeight);
        } else {
            currentHeight = coalesceTwoActiveNodes(currentHeight, nextCoalescentHeight);
        }

        // if (getNodeCount() > 1) {
        if (nodeList.size() > 1) {
            // get at least two tips
            while (getActiveNodeCount() < 2) {
                currentHeight = getMinimumInactiveHeight();
                setCurrentHeight(currentHeight);
            }

            // nextCoalescentHeight = currentHeight +
            // DemographicFunction.Utils.getMedianInterval(demographic,
            // getActiveNodeCount(), currentHeight);
            nextCoalescentHeight = currentHeight
                    + PopulationFunction.Utils.getSimulatedInterval(demographic, getActiveNodeCount(),
                    currentHeight);
        }
    }

    return nodeList;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:62,代码来源:RandomTree.java


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