本文整理汇总了Java中beast.evolution.tree.Node.setID方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setID方法的具体用法?Java Node.setID怎么用?Java Node.setID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Node
的用法示例。
在下文中一共展示了Node.setID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lengthToHeight
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/** convert length to height
* and set ID of leafs
*/
private double lengthToHeight(Node node, double offSet) {
if (node.isLeaf()) {
node.setHeight(-offSet - node.getHeight());
node.setID(m_sLabels.get(node.getNr()));
return -node.getHeight();
} else {
double posY = offSet + node.getHeight();
double yMax = 0;
yMax = Math.max(yMax, lengthToHeight(node.getLeft(), posY));
if (node.getRight() != null) {
yMax = Math.max(yMax, lengthToHeight(node.getRight(), posY));
}
node.setHeight(-posY);
return yMax;
}
}
示例2: translateLeafIds
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* Given a map of name translations (string to string),
* rewrites all leaf ids that match a key in the map
* to the respective value in the matching key/value pair.
* If current leaf id is null, then interpret translation keys as node numbers (origin 1)
* and set leaf id of node n to map.get(n-1).
*
* @param translationMap map of name translations
*/
public void translateLeafIds(final Map<String, String> translationMap) {
for (final Node leaf : getExternalNodes()) {
String id = leaf.getID();
if (id == null || !integerLeafLabels) {
id = Integer.toString(leaf.getNr() + 1);
}
final String newId = translationMap.get(id);
if (newId != null) {
leaf.setID(newId);
}
}
}
示例3: convertTree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void convertTree(Node node) {
if (!node.isLeaf()) {
if (node.isFake()) {
Node directAncestor = node.getDirectAncestorChild();
node.removeChild(directAncestor);
node.setNr(directAncestor.getNr());
node.setID(directAncestor.getID());
directAncestor.setParent(null);
}
for (int i = 0; i < node.getChildCount(); i++) {
Node childNode = node.getChild(i);
convertTree(childNode);
}
}
}
示例4: translateLeafIds
import beast.evolution.tree.Node; //导入方法依赖的package包/类
/**
* Given a map of name translations (string to string),
* rewrites all leaf ids that match a key in the map
* to the respective value in the matching key/value pair.
* If current leaf id is null, then interpret translation keys as node numbers (origin 1)
* and set leaf id of node n to map.get(n-1).
*
* @param translationMap
*/
public void translateLeafIds(Map<String, String> translationMap) {
for (Node leaf : getExternalNodes()) {
String id = leaf.getID();
if (id == null) {
id = (leaf.getNr() + 1) + "";
}
String newId = translationMap.get(id);
if (newId != null) {
leaf.setID(newId);
}
}
}
示例5: labelNonLabeledNodes
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void labelNonLabeledNodes(Node node, int[] lastLabel) {
for (Node child : node.getChildren()) {
labelNonLabeledNodes(child, lastLabel);
}
if (node.getNr() == -1) {
node.setNr(lastLabel[0] + 1);
lastLabel[0] += 1;
} else if (labels != null && node.getNr() < labels.size()) {
node.setID(labels.get(node.getNr()));
}
}
示例6: visitNode
import beast.evolution.tree.Node; //导入方法依赖的package包/类
@Override
public Node visitNode(NewickParser.NodeContext ctx) {
Node node = newNode();
for (NewickParser.NodeContext ctxChild : ctx.node()) {
node.addChild(visit(ctxChild));
}
NewickParser.PostContext postCtx = ctx.post();
// Process metadata
if (postCtx.nodeMeta != null)
processMetadata(node, postCtx.nodeMeta, false);
if (postCtx.lengthMeta != null)
processMetadata(node, postCtx.lengthMeta, true);
// Process edge length
if (postCtx.length != null)
node.setHeight(Double.parseDouble(postCtx.length.getText()));
else
node.setHeight(DEFAULT_LENGTH);
// Process label
node.setNr(-1);
if (postCtx.label() != null) {
node.setID(postCtx.label().getText());
if (postCtx.label().number() == null
|| postCtx.label().number().INT() == null)
integerLeafLabels = false;
// Treat labels as node numbers in certain situations
if (!isLabelledNewickInput.get()
&& postCtx.label().number() != null
&& postCtx.label().number().INT() != null) {
int nodeNr = Integer.parseInt(postCtx.label().getText()) - offsetInput.get();
if (nodeNr<0)
throw new TreeParsingException("Node number given " +
"is smaller than current offset (" +
offsetInput.get() + "). Perhaps offset is " +
"too high?");
node.setNr(nodeNr);
numberedNodeCount += 1;
} else {
if (node.isLeaf()) {
node.setNr(getLabelIndex(postCtx.label().getText()));
numberedNodeCount += 1;
}
}
}
if (node.getChildCount()==1 && !allowSingleChildInput.get())
throw new TreeParsingException("Node with single child found.");
// Use length-zero edges to binarize multifurcations.
if (binarizeMultifurcationsInput.get())
binarizeMultifurcation(node);
return node;
}