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


Java Node.getLength方法代码示例

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


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

示例1: height

import beast.evolution.tree.Node; //导入方法依赖的package包/类
double height(Node node) {
 if (node.isLeaf()) {
	 return node.getLength();
 } else {
	 return node.getLength() + Math.max(height(node.getLeft()), height(node.getRight()));
 }
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:8,代码来源:TreeSetParser.java

示例2: computeFactor

import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void computeFactor() {

        //scale mean rate to 1.0 or separate parameter

        double treeRate = 0.0;
        double treeTime = 0.0;

        for (int i = 0; i < tree.getNodeCount(); i++) {
            Node node = tree.getNode(i);
            if (!node.isRoot()) {
                int nodeNumber = node.getNr();
                if (nodeNumber == categories.getDimension()) {
                    // root node has nr less than #categories, so use that nr
                    nodeNumber = node.getTree().getRoot().getNr();
                }
                int rateCategory = categories.getValue(nodeNumber);
                treeRate += rates[rateCategory] * node.getLength();
                treeTime += node.getLength();

                //System.out.println("rates and time\t" + rates[rateCategory] + "\t" + node.getLength());
            }
        }
        //treeRate /= treeTime;

        scaleFactor = 1.0 / (treeRate / treeTime);


        //System.out.println("scaleFactor\t\t\t\t\t" + scaleFactor);
    }
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:30,代码来源:SynchronizableUCRelaxedClock.java

示例3: setTipValues

import beast.evolution.tree.Node; //导入方法依赖的package包/类
void setTipValues(Node node) {

        if (node.isRoot()) {
            node.setMetaData("p", new Point2D.Double(0, 0));
            node.setMetaData("arc", 2 * Math.PI);
            node.setMetaData("direction", -Math.PI / 2.0);
        } else {

            Node parent = node.getParent();

            double direction = (Double) node.getMetaData("direction");

            double length = node.getLength();

            Point2D parentPoint2D = (Point2D) parent.getMetaData("p");

            double x = parentPoint2D.getX() + length * Math.cos(direction);
            double y = parentPoint2D.getY() + length * Math.sin(direction);

            if (x < minX) minX = x;
            if (x > maxX) maxX = x;
            if (y < minY) minY = y;
            if (y > maxY) maxY = y;

            node.setMetaData("p", new Point2D.Double(x, y));
        }

        double arc = (Double) node.getMetaData("arc");

        int leafNodeCount = node.getLeafNodeCount();

        double childDirection = (Double) node.getMetaData("direction");
        for (Node child : node.getChildren()) {
            int childLeafNodeCount = child.getLeafNodeCount();

            double childArc = arc * (double) childLeafNodeCount / (double) leafNodeCount;

            child.setMetaData("arc", childArc);
            child.setMetaData("direction", childDirection - childArc / 2);

            childDirection += childArc;
        }

        for (Node childNode : node.getChildren()) {
            setTipValues(childNode);
        }
    }
 
开发者ID:CompEvol,项目名称:beastshell,代码行数:48,代码来源:UnrootedTreeDrawing.java

示例4: getCommonAncestor

import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected Node getCommonAncestor(Node n1, Node n2) {
    // assert n1.getTree() == n2.getTree();
    if( ! nodesTraversed[n1.getNr()] ) {
        nodesTraversed[n1.getNr()] = true;
        nseen += 1;
    }
    if( ! nodesTraversed[n2.getNr()] ) {
        nodesTraversed[n2.getNr()] = true;
        nseen += 1;
    }
    while (n1 != n2) {
     double h1 = n1.getHeight();
     double h2 = n2.getHeight();
     if ( h1 < h2 ) {
         n1 = n1.getParent();
         if( ! nodesTraversed[n1.getNr()] ) {
             nodesTraversed[n1.getNr()] = true;
             nseen += 1;
         }
     } else if( h2 < h1 ) {
         n2 = n2.getParent();
         if( ! nodesTraversed[n2.getNr()] ) {
             nodesTraversed[n2.getNr()] = true;
             nseen += 1;
         }
     } else {
         //zero length branches hell
         Node n;
         double b1 = n1.getLength();
         double b2 = n2.getLength();
         if( b1 > 0 ) {
             n = n2;
         } else { // b1 == 0
             if( b2 > 0 ) {
                 n = n1;
             } else {
                 // both 0
                 n = n1;
                 while( n != null && n != n2 ) {
                     n = n.getParent();
                 }
                 if( n == n2 ) {
                     // n2 is an ancestor of n1
                     n = n1;
                 } else {
                     // always safe to advance n2
                     n = n2;
                 }
             }
         }
         if( n == n1 ) {
                n = n1 = n.getParent();
            } else {
                n = n2 = n.getParent();
            }
         if( ! nodesTraversed[n.getNr()] ) {
             nodesTraversed[n.getNr()] = true;
             nseen += 1;
         } 
     }
    }
    return n1;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:64,代码来源:MRCAPrior.java

示例5: toNewick

import beast.evolution.tree.Node; //导入方法依赖的package包/类
String toNewick(Node node, List<Function> metadataList, BranchRateModel branchRateModel, PopulationModel populationModel) {
    StringBuffer buf = new StringBuffer();
    if (node.getLeft() != null) {
        buf.append("(");
        buf.append(toNewick(node.getLeft(), metadataList, branchRateModel, populationModel));
        if (node.getRight() != null) {
            buf.append(',');
            buf.append(toNewick(node.getRight(), metadataList, branchRateModel, populationModel));
        }
        buf.append(")");
    } else {
        buf.append(node.getNr() + 1);
    }
    if (someMetaDataNeedsLogging) {
        buf.append("[&");
        if (metadataList.size() > 0) {
            for (Function metadata : metadataList) {
                buf.append(((BEASTObject)metadata).getID());
                buf.append('=');
                if (metadata instanceof Parameter<?>) {
                    Parameter<?> p = (Parameter<?>) metadata;
                    int dim = p.getMinorDimension1();
                    if (dim > 1) {
                        buf.append('{');
                        for (int i = 0; i < dim; i++) {
                            buf.append(p.getMatrixValue(node.getNr(), i));
                            if (i < dim - 1) {
                                buf.append(',');
                            }
                        }
                        buf.append('}');
                    } else {
                        buf.append(metadata.getArrayValue(node.getNr()));
                    }
                } else {
                    buf.append(metadata.getArrayValue(node.getNr()));
                }
                if (metadataList.indexOf(metadata) < metadataList.size() - 1) {
                    buf.append(",");
                }
            }
            if (branchRateModel != null || populationModel != null) {
                buf.append(",");
            }
        }
        if (branchRateModel != null) {
            buf.append("rate=");
            appendDouble(buf, branchRateModel.getRateForBranch(node));
            if (populationModel != null) {
                buf.append(",");
            }
        }

        if (populationModel != null) {
            populationModel.serialize(node, buf, df);
        }

        buf.append(']');
    }
    buf.append(":");

    double nodeLength;
    if (node.isRoot()) {
        nodeLength = getTreeHeight() - node.getHeight();
    } else {
        nodeLength = node.getLength();
    }

    if (substitutions) {
        appendDouble(buf, nodeLength * branchRateModel.getRateForBranch(node));
    } else {
        appendDouble(buf, nodeLength);
    }
    return buf.toString();
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:76,代码来源:SpeciesTreeLogger.java


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