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


Java Node.setRight方法代码示例

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


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

示例1: reorder

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * randomly changes left and right children in every internal node *
 */
private void reorder(final Node node) {
    if (!node.isLeaf()) {
        if (Randomizer.nextBoolean()) {
            final Node tmp = node.getLeft();
            node.setLeft(node.getRight());
            node.setRight(tmp);
        }
        reorder(node.getLeft());
        reorder(node.getRight());
    }
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:15,代码来源:NodeReheight2.java

示例2: toNode

import beast.evolution.tree.Node; //导入方法依赖的package包/类
Node toNode() {
    final Node node = newNode();
    node.setHeight(m_fHeight);
    if (m_left == null) {
        node.setLeft(newNode());
        node.getLeft().setNr(m_iLeftInstance);
        node.getLeft().setID(taxaNames.get(m_iLeftInstance));
        node.getLeft().setHeight(m_fHeight - m_fLeftLength);
        if (m_right == null) {
            node.setRight(newNode());
            node.getRight().setNr(m_iRightInstance);
            node.getRight().setID(taxaNames.get(m_iRightInstance));
            node.getRight().setHeight(m_fHeight - m_fRightLength);
        } else {
            node.setRight(m_right.toNode());
        }
    } else {
        node.setLeft(m_left.toNode());
        if (m_right == null) {
            node.setRight(newNode());
            node.getRight().setNr(m_iRightInstance);
            node.getRight().setID(taxaNames.get(m_iRightInstance));
            node.getRight().setHeight(m_fHeight - m_fRightLength);
        } else {
            node.setRight(m_right.toNode());
        }
    }
    if (node.getHeight() < node.getLeft().getHeight() + EPSILON) {
        node.setHeight(node.getLeft().getHeight() + EPSILON);
    }
    if (node.getHeight() < node.getRight().getHeight() + EPSILON) {
        node.setHeight(node.getRight().getHeight() + EPSILON);
    }

    node.getRight().setParent(node);
    node.getLeft().setParent(node);
    return node;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:39,代码来源:ClusterTree.java

示例3: convertToFakeSATree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
public static void convertToFakeSATree(Node node, int[] nextNr) {
    if (!node.isLeaf()) {
        convertToFakeSATree(node.getLeft(), nextNr);
        if (node.getRight() != null) {
            convertToFakeSATree(node.getRight(), nextNr);
        }
    }
    if (node.getChildCount() == 1) {
        Node parent = new Node();
        parent.setHeight(node.getHeight());
        Node child = node.getLeft();
        parent.setLeft(child);
        child.setParent(parent);
        node.removeChild(child);
        parent.setRight(node);
        parent.setNr(nextNr[0]);
        nextNr[0]++;
        if (!node.isRoot()) {
            Node grandparent = node.getParent();

            if (grandparent.getLeft().getNr() == node.getNr()) {
                grandparent.setLeft(parent);
            }  else {
                grandparent.setRight(parent);
            }
            parent.setParent(grandparent);
        }  else {
            node.getTree().setRoot(parent);
        }
        node.setParent(parent);
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:33,代码来源:SampledAncestorTreeComparator.java

示例4: convertToFakeSATree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * convert a tree with single child node to ZeroBranchSATree.
 *
 * @param node all the nodes that are under this node and have single child will be
 *             replaced with zero branches
 * @throws Exception
 */

private void convertToFakeSATree(Node node, int[] lastLabel) throws Exception {
    if (!node.isLeaf()) {
        convertToFakeSATree(node.getLeft(), lastLabel);
        if (node.getRight() != null) {
            convertToFakeSATree(node.getRight(), lastLabel);
        }
    }
    if (node.getChildCount() == 1) {
        Node parent = newNode();
        parent.setNr(-1);
        parent.setHeight(node.getHeight());
        Node child = node.getLeft();
        parent.setLeft(child);
        child.setParent(parent);
        node.removeChild(child);
        parent.setRight(node);
        if (!node.isRoot()) {
            Node grandparent = node.getParent();

            if (grandparent.getLeft().equals(node)) {
                grandparent.setLeft(parent);
            }  else {
                grandparent.setRight(parent);
            }
            parent.setParent(grandparent);
        }
        node.setParent(parent);
        if (node.getNr() == -1) {
            node.setNr(lastLabel[0]+1);
            lastLabel[0]++;
        }
    }
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:42,代码来源:ZeroBranchSATreeParser.java

示例5: reconstructTree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private Node reconstructTree(final double[] heights, final int[] reverseOrder, final int from, final int to, final boolean[] hasParent) {
    //nodeIndex = maxIndex(heights, 0, heights.length);
    int nodeIndex = -1;
    double max = Double.NEGATIVE_INFINITY;
    for (int j = from; j < to; j++) {
        if (max < heights[j] && !m_nodes[reverseOrder[j]].isLeaf()) {
            max = heights[j];
            nodeIndex = j;
        }
    }
    if (nodeIndex < 0) {
        return null;
    }
    final Node node = m_nodes[reverseOrder[nodeIndex]];
    final boolean keepLeftChild = node.getLeft().isDirectAncestor();
    final boolean keepRightChild = node.getRight().isDirectAncestor();

    if (!keepLeftChild) {
     //int left = maxIndex(heights, 0, nodeIndex);
     int left = -1;
     max = Double.NEGATIVE_INFINITY;
     for (int j = from; j < nodeIndex; j++) {
         if (max < heights[j] && !hasParent[j]) {
             max = heights[j];
             left = j;
         }
     }
     /* if (left >= reverseOrder.length || left < 0) {
            System.out.println("(reverseOrder[" + left + "] out of bounds) Node number = " + node.getNr());
            System.out.println(node.toNewick());
        } */
     node.setLeft(m_nodes[reverseOrder[left]]);
     node.getLeft().setParent(node);
     if (node.getLeft().isLeaf()) {
         heights[left] = Double.NEGATIVE_INFINITY;
     }
     hasParent[left] = true;
    }

    if (!keepRightChild) {
     int right = -1;
     max = Double.NEGATIVE_INFINITY;
     for (int j = nodeIndex + 1; j < to; j++) {
         if (max < heights[j] && !hasParent[j]) {
             max = heights[j];
             right = j;
         }
     }
     node.setRight(m_nodes[reverseOrder[right]]);
     node.getRight().setParent(node);
     if (node.getRight().isLeaf()) {
         heights[right] = Double.NEGATIVE_INFINITY;
     }
     hasParent[right] = true;
    }

    heights[nodeIndex] = Double.NEGATIVE_INFINITY;
    reconstructTree(heights, reverseOrder, from, nodeIndex, hasParent);
    reconstructTree(heights, reverseOrder, nodeIndex, to, hasParent);
    return node;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:62,代码来源:NodeReheight2.java

示例6: reconstructTree

import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
 * construct tree top down by joining heighest left and right nodes *
 */


private Node reconstructTree(final double[] heights, final int[] reverseOrder, final int from, final int to, final boolean[] hasParent) {
    //nodeIndex = maxIndex(heights, 0, heights.length);
    int nodeIndex = -1;
    double max = Double.NEGATIVE_INFINITY;
    for (int j = from; j < to; j++) {
        if (max < heights[j] && !m_nodes[reverseOrder[j]].isLeaf()) {
            max = heights[j];
            nodeIndex = j;
        }
    }
    if (nodeIndex < 0) {
        return null;
    }
    final Node node = m_nodes[reverseOrder[nodeIndex]];

    //int left = maxIndex(heights, 0, nodeIndex);
    int left = -1;
    max = Double.NEGATIVE_INFINITY;
    for (int j = from; j < nodeIndex; j++) {
        if (max < heights[j] && !hasParent[j]) {
            max = heights[j];
            left = j;
        }
    }

    //int right = maxIndex(heights, nodeIndex+1, heights.length);
    int right = -1;
    max = Double.NEGATIVE_INFINITY;
    for (int j = nodeIndex + 1; j < to; j++) {
        if (max < heights[j] && !hasParent[j]) {
            max = heights[j];
            right = j;
        }
    }

    node.setLeft(m_nodes[reverseOrder[left]]);
    node.getLeft().setParent(node);
    node.setRight(m_nodes[reverseOrder[right]]);
    node.getRight().setParent(node);
    if (node.getLeft().isLeaf()) {
        heights[left] = Double.NEGATIVE_INFINITY;
    }
    if (node.getRight().isLeaf()) {
        heights[right] = Double.NEGATIVE_INFINITY;
    }
    hasParent[left] = true;
    hasParent[right] = true;
    heights[nodeIndex] = Double.NEGATIVE_INFINITY;


    reconstructTree(heights, reverseOrder, from, nodeIndex, hasParent);
    reconstructTree(heights, reverseOrder, nodeIndex, to, hasParent);
    return node;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:60,代码来源:NodeReheight.java

示例7: connectParentToChildren

import beast.evolution.tree.Node; //导入方法依赖的package包/类
public void connectParentToChildren(Node parent, Node left, Node right) {
    parent.setLeft(left);
    parent.setRight(right);
    left.setParent(parent);
    right.setParent(parent);
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:7,代码来源:SABDSkylineTreeSimulatorArbitraryRateChanges.java

示例8: main

import beast.evolution.tree.Node; //导入方法依赖的package包/类
public static void main (String[] arg) throws Exception{


        Node root = new Node();
        root.setNr(4);
        root.setHeight(2.0);
        Node left = new Node();
        left.setNr(3);
        left.setHeight(1.0);
        root.setLeft(left);
        left.setParent(root);
        Node right = new Node();
        right.setNr(2);
        right.setHeight(2.0);
        root.setRight(right);
        right.setParent(root);
        Node leftLeft = new Node();
        leftLeft.setNr(0);
        leftLeft.setHeight(0.0);
        left.setLeft(leftLeft);
        leftLeft.setParent(left);
        Node leftRight = new Node();
        leftRight.setNr(1);
        leftRight.setHeight(1.0);
        left.setRight(leftRight);
        leftRight.setParent(left);
        Tree tree = new Tree(root);

        System.out.println("The tree is " + tree.getRoot().toShortNewick(false));


        SATreeComparingAnalysis analysis = new SATreeComparingAnalysis();
        //process tree. consider Fake SA trees
        ArrayList<Integer> dAPattern = new ArrayList<Integer>();
        for (int i=tree.getLeafNodeCount(); i< tree.getNodeCount(); i++){
            if (((ZeroBranchSANode)tree.getNode(i)).isFake()) {
                int descendantsCount = tree.getNode(i).getLeafNodeCount() - 1;
                if (descendantsCount > 0) {
                    for(int j=dAPattern.size(); j<descendantsCount; j++){
                        dAPattern.add(0);
                    }
                    int tmp = dAPattern.get(descendantsCount-1);
                    tmp++;
                    dAPattern.set(descendantsCount - 1, tmp);
                }
            }
        }

        SATreeComparingAnalysis.TreeSummary treeSummary = analysis.new TreeSummary(tree.getRoot().getHeight(), tree.getLeafNodeCount() - ((ZeroBranchSATree)tree).getDirectAncestorNodeCount(), dAPattern);

        System.out.println(treeSummary.dAPattern.toString());
        ArrayList<Integer> a = new ArrayList<Integer> (Arrays.asList(new Integer[]{1, 1}));
        System.out.println(treeSummary.dAPattern.equals(a));
    }
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:55,代码来源:SATreeComparingAnalysis.java


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