本文整理汇总了Java中pal.tree.Node.isLeaf方法的典型用法代码示例。如果您正苦于以下问题:Java Node.isLeaf方法的具体用法?Java Node.isLeaf怎么用?Java Node.isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal.tree.Node
的用法示例。
在下文中一共展示了Node.isLeaf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printNH2
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH2(PrintWriter out, Node node, Map<Node, Attributes> nodeAttributes) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH2(out, node.getChild(i), nodeAttributes);
}
out.print(")");
}
if (!node.isRoot()) {
String id = nodeAttributes.get(node).get(Attributes.Key.REALNAME);
out.print(id);
out.print(":");
FormattedOutput.getInstance().displayDecimal(out, node.getBranchLength(), 7);
}
}
示例2: rootedSupport
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates rooted support.
*
* @param wTree the weighted tree instance
* @param node the node
* @param support the support
*
* @return the fixed bit set
*/
private FixedBitSet rootedSupport(WeightedTree wTree, Node node, Map<FixedBitSet, Support> support) {
FixedBitSet clade = new FixedBitSet(numTaxa);
if (node.isLeaf()) {
clade.set(idGroup.whichIdNumber(node.getIdentifier().getName()));
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
FixedBitSet childClade = rootedSupport(wTree, n, support);
clade.union(childClade);
}
}
Support s = support.get(clade);
if (s == null) {
s = new Support();
support.put(clade, s);
}
s.add(wTree.getWeight(), TreeUtilities.safeNodeHeight(wTree.getTree(), node), node.getBranchLength());
return clade;
}
示例3: insureConsistency
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Make sure subtree below node has consistent heights, i.e. node height is higher than it's descendants
*
* @param tree the tree
* @param node the node
*
* @return height of node
*/
public static double insureConsistency(Tree tree, Node node) {
double height = TreeUtilities.safeNodeHeight(tree, node);
if (node.isLeaf()) {
return height;
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
final double childHeight = insureConsistency(tree, n);
height = Math.max(height, childHeight);
}
}
node.setNodeHeight(height);
return height;
}
示例4: insureConsistency
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Make sure subtree below node has consistent heights, i.e. node height is higher than it's descendants
*
* @param tree the tree
* @param node the node
*
* @return height of node
*/
public static double insureConsistency(Tree tree, Node node) {
double height = TreeUtils.safeNodeHeight(tree, node);
if (node.isLeaf()) {
return height;
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
final double childHeight = insureConsistency(tree, n);
height = Math.max(height, childHeight);
}
}
node.setNodeHeight(height);
return height;
}
示例5: rootedSupport
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates rooted support.
*
* @param wTree the weighted tree instance
* @param node the node
* @param support the support
*
* @return the fixed bit set
*/
private FixedBitSet rootedSupport(WeightedTree wTree, Node node, Map<FixedBitSet, Support> support) {
FixedBitSet clade = new FixedBitSet(numTaxa);
if (node.isLeaf()) {
clade.set(idGroup.whichIdNumber(node.getIdentifier().getName()));
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
FixedBitSet childClade = rootedSupport(wTree, n, support);
clade.union(childClade);
}
}
Support s = support.get(clade);
if (s == null) {
s = new Support();
support.put(clade, s);
}
s.add(wTree.getWeight(), TreeUtils.safeNodeHeight(wTree.getTree(), node), node.getBranchLength());
return clade;
}
示例6: getAttributes
import pal.tree.Node; //导入方法依赖的package包/类
private Attributes getAttributes(Node node, List<Substitution> substitutions) {
String name;
if (node.isLeaf() && names.size() > 0) {
name = names.get(Integer.parseInt(getSequenceKey(node).split("_")[1]) - 1);
} else {
// MODIFICATION: Change REALNAME of internal nodes (branches)
//name = getSequenceKey(node);
name = "branch_" + Integer.toString(getBranchNumber(node));
}
Attributes a = new Attributes(Attributes.Key.REALNAME, name);
a.add(Attributes.Key.NUMBER, Integer.toString(getBranchNumber(node)));
if (substitutions.size() > 0) a.add(Attributes.Key.ALLSUBS, substitutions.toString());
Collection<Substitution> nonsynSubs = Collections2.filter(substitutions, Predicates.not(new Substitution.isSynSubPredicate()));
if (nonsynSubs.size() > 0) a.add(Attributes.Key.NONSYNSUBS, nonsynSubs.toString());
a.add(Attributes.Key.FULL,
String.format("%s - %s %s",
a.get(Attributes.Key.NUMBER),
a.get(Attributes.Key.REALNAME),
a.get(Attributes.Key.ALLSUBS)));
a.add(Attributes.Key.NAME_AND_SUBS,
String.format("%s %s",
a.get(Attributes.Key.REALNAME),
a.get(Attributes.Key.NONSYNSUBS)));
return a;
}
示例7: getSequenceKey
import pal.tree.Node; //导入方法依赖的package包/类
private String getSequenceKey(Node n) {
// MODIFIED: now all labels can be obtained from trees[1]
if (n.isLeaf()) {
return trees[1].getExternalNode(n.getNumber()).getIdentifier().getName();
//return trees[0].getExternalNode(n.getNumber()).getIdentifier().getName();
} else {
return trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
//return "node#" + trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
}
}
示例8: nodeDistance
import pal.tree.Node; //导入方法依赖的package包/类
/**
* Calculates the number of branches from node to most remote tip.
*
* @param node the starting node
*
* @return the node distance
*/
public static int nodeDistance(final Node node) {
if (node.isLeaf()) {
return 0;
}
int d = 0;
for (int i = 0; i < node.getChildCount(); i++) {
Node n = node.getChild(i);
d = Math.max(d, nodeDistance(n));
}
return d + 1;
}
示例9: printlnNodeWithNumberAndLabel
import pal.tree.Node; //导入方法依赖的package包/类
private static void printlnNodeWithNumberAndLabel(PrintWriter out, Node node, int level,
int numExternalNodes, boolean[] umbrella, int[] position) {
for (int i = 0; i < level - 1; i++) {
if (umbrella[i]) {
putCharAtLevel(out, i, '|', position);
} else {
putCharAtLevel(out, i, ' ', position);
}
}
putCharAtLevel(out, level - 1, '+', position);
int branchNumber;
if (node.isLeaf()) {
branchNumber = node.getNumber() + 1;
} else {
branchNumber = node.getNumber() + 1 + numExternalNodes;
}
String numberAsString = Integer.toString(branchNumber);
int numDashs = position[level] - numberAsString.length();
for (int i = 0; i < numDashs ; i++) {
out.print('-');
}
out.print(numberAsString);
if (node.isLeaf()) {
out.println(" " + node.getIdentifier());
} else {
if (!node.getIdentifier().equals(Identifier.ANONYMOUS)) {
out.print("(" + node.getIdentifier() + ")");
}
out.println();
}
}
示例10: printNH
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH(PrintWriter out, Tree tree, Node node,
boolean printLengths, boolean printInternalLabels,
boolean printCladeSupport) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH(out, tree, node.getChild(i), printLengths,
printInternalLabels, printCladeSupport);
}
out.print(")");
}
if (!node.isRoot()) {
if (node.isLeaf() || printInternalLabels) {
String id = node.getIdentifier().toString();
out.print(id);
}
if (printCladeSupport) {
if (tree.getAttribute(node, TREE_CLADE_SUPPORT_ATTRIBUTE) != null) {
double support = (Double) tree.getAttribute(node,
TREE_CLADE_SUPPORT_ATTRIBUTE);
out.printf(":" + FormattedOutput.getInstance().getDecimalString(support, 4));
}
}
if (printLengths) {
out.printf(":" + FormattedOutput.getInstance().getDecimalString(node.getBranchLength(), 10));
}
}
}
示例11: getLeavesFromNode
import pal.tree.Node; //导入方法依赖的package包/类
private void getLeavesFromNode(Node node, Set<String> leaves) {
if (node.isLeaf()) {
leaves.add(node.getIdentifier().getName());
} else {
for (int i = 0; i < node.getChildCount(); i++) {
Node child = node.getChild(i);
getLeavesFromNode(child, leaves);
}
}
}
示例12: getDescendants
import pal.tree.Node; //导入方法依赖的package包/类
public void getDescendants(Node node, Collection<String> names) {
if (node.isLeaf()) names.add(node.getIdentifier().getName());
for (int i = 0; i < node.getChildCount(); i++) {
getDescendants(node.getChild(i), names);
}
}
示例13: getAttributes
import pal.tree.Node; //导入方法依赖的package包/类
private Attributes getAttributes(Node node, List<Substitution> substitutions) {
String name;
if (node.isLeaf() && names.size() > 0) {
name = names.get(Integer.parseInt(getSequenceKey(node).split("_")[1]) - 1);
} else {
name = getSequenceKey(node);
}
Attributes a = new Attributes(Attributes.Key.REALNAME, name);
a.add(Attributes.Key.NUMBER, Integer.toString(getBranchNumber(node)));
if (substitutions.size() > 0) a.add(Attributes.Key.ALLSUBS, substitutions.toString());
Collection<Substitution> nonsynSubs = Collections2.filter(substitutions, Predicates.not(new Substitution.isSynSubPredicate()));
if (nonsynSubs.size() > 0) a.add(Attributes.Key.NONSYNSUBS, nonsynSubs.toString());
a.add(Attributes.Key.FULL,
String.format("%s - %s %s",
a.get(Attributes.Key.NUMBER),
a.get(Attributes.Key.REALNAME),
a.get(Attributes.Key.ALLSUBS)));
a.add(Attributes.Key.NAME_AND_SUBS,
String.format("%s %s",
a.get(Attributes.Key.REALNAME),
a.get(Attributes.Key.NONSYNSUBS)));
return a;
}
示例14: getSequenceKey
import pal.tree.Node; //导入方法依赖的package包/类
private String getSequenceKey(Node n) {
if (n.isLeaf()) {
return trees[0].getExternalNode(n.getNumber()).getIdentifier().getName();
} else {
return "node#" + trees[1].getInternalNode(n.getNumber()).getIdentifier().getName();
}
}
示例15: printNH
import pal.tree.Node; //导入方法依赖的package包/类
public static void printNH(PrintWriter out, Node node, Map<Node, Attributes> nodeAttributes) {
if (!node.isLeaf()) {
out.print("(");
for (int i = 0; i < node.getChildCount(); i++) {
if (i != 0) {
out.print(",");
}
printNH(out, node.getChild(i), nodeAttributes);
}
out.print(")");
}
if (!node.isRoot()) {
if (node.isLeaf()) {
// String id = node.getIdentifier().toString();
String id = nodeAttributes.get(node).get(Attributes.Key.REALNAME);
out.print("'" + id + "'");
} else {
if (nodeAttributes.get(node).size() > 0) {
out.print(nodeAttributes.get(node).toString());
}
}
out.print(":");
FormattedOutput.getInstance().displayDecimal(out, node.getBranchLength(), 7);
}
}