本文整理汇总了Java中beast.evolution.tree.Node.setMetaData方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setMetaData方法的具体用法?Java Node.setMetaData怎么用?Java Node.setMetaData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beast.evolution.tree.Node
的用法示例。
在下文中一共展示了Node.setMetaData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mutateOverTree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
public Tree mutateOverTree(Tree base) throws Exception {
ArrayList<Node> currParents = new ArrayList<Node>();
ArrayList<Node> newParents = new ArrayList<Node>();
currParents.add(base.getRoot());
while (currParents.size() > 0) {
for (Node parent : currParents) {
List<Node> children = parent.getChildren();
for (Node child : children) {
double T = Math.abs(child.getHeight() - parent.getHeight());
Sequence parentLang = getSequence(parent);
Sequence newLang = mutateLang(parentLang, T);
child.setMetaData("lang", newLang);
newParents.add(child);
addEmptyTrait(base, child);
}
}
currParents = new ArrayList<Node>(newParents);
newParents = new ArrayList<Node>();
}
return base;
}
示例2: addEmptyTrait
import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected void addEmptyTrait(Tree t, Node newLangNode) throws Exception {
// Get all nodes in two lists.
List<Node> children = newLangNode.getAllChildNodes();
// Find nodes that aren't children (or trait lang).
List<Node> allNodes = t.getInternalNodes();
allNodes.addAll(t.getExternalNodes());
allNodes.removeAll(children);
allNodes.remove(newLangNode);
// Calculate number of [new] mutations in new language.
Sequence newLang = getSequence(newLangNode);
for (Node n : allNodes) {
Sequence nLang = getSequence(n);
String s = nLang.getData();
Sequence newNodeLang = new Sequence("", s);
while (newNodeLang.getData().length() < newLang.getData().length()) {
String sNew = newNodeLang.getData() + '0';
// System.out.println(newNodeLang);
newNodeLang.dataInput.setValue(sNew, this);
}
n.setMetaData("lang", newNodeLang);
}
}
示例3: mutateOverTree
import beast.evolution.tree.Node; //导入方法依赖的package包/类
public Tree mutateOverTree(Tree base) throws Exception {
ArrayList<Node> currParents = new ArrayList<Node>();
ArrayList<Node> newParents = new ArrayList<Node>();
currParents.add(base.getRoot());
while (currParents.size() > 0) {
for (Node parent : currParents) {
List<Node> children = parent.getChildren();
for (Node child : children) {
double T = Math.abs(child.getHeight() - parent.getHeight());
Sequence parentLang = getSequence(parent);
Sequence newLang = mutateLang(parentLang, T);
child.setMetaData("lang", newLang);
newParents.add(child);
}
}
currParents = new ArrayList<Node>(newParents);
newParents = new ArrayList<Node>();
}
return base;
}
示例4: setTipValues
import beast.evolution.tree.Node; //导入方法依赖的package包/类
void setTipValues(Node node) {
if (node.isLeaf()) {
node.setMetaData("p", p);
node.setMetaData("p_min", p);
node.setMetaData("p_max", p);
p += getCanonicalNodeSpacing(node.getTree());
} else {
double pmin = Double.MAX_VALUE;
double pmax = Double.MIN_VALUE;
for (Node childNode : node.getChildren()) {
setTipValues(childNode);
double cpmin = (Double) childNode.getMetaData("p_min");
double cpmax = (Double) childNode.getMetaData("p_max");
if (cpmin < pmin) pmin = cpmin;
if (cpmax > pmax) pmax = cpmax;
}
node.setMetaData("p_min", pmin);
node.setMetaData("p_max", pmax);
}
}
示例5: annotateModeAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateModeAttribute(Node node, String label, HashMap<Object, Integer> values) {
Object mode = null;
int maxCount = 0;
int totalCount = 0;
int countInMode = 1;
for (Object key : values.keySet()) {
int thisCount = values.get(key);
if (thisCount == maxCount) {
// I hope this is the intention
mode = mode.toString().concat("+" + key);
countInMode++;
} else if (thisCount > maxCount) {
mode = key;
maxCount = thisCount;
countInMode = 1;
}
totalCount += thisCount;
}
double freq = (double) maxCount / (double) totalCount * countInMode;
node.setMetaData(label, mode);
node.setMetaData(label + ".prob", freq);
}
示例6: annotateFrequencyAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateFrequencyAttribute(Node node, String label, HashMap<Object, Integer> values) {
double totalCount = 0;
Set<?> keySet = values.keySet();
int length = keySet.size();
String[] name = new String[length];
Double[] freq = new Double[length];
int index = 0;
for (Object key : values.keySet()) {
name[index] = key.toString();
freq[index] = new Double(values.get(key));
totalCount += freq[index];
index++;
}
for (int i = 0; i < length; i++)
freq[i] /= totalCount;
node.setMetaData(label + ".set", name);
node.setMetaData(label + ".set.prob", freq);
}
示例7: annotateHPDAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateHPDAttribute(Node node, String label, double hpd, double[] values) {
int[] indices = new int[values.length];
HeapSort.sort(values, indices);
double minRange = Double.MAX_VALUE;
int hpdIndex = 0;
int diff = (int) Math.round(hpd * values.length);
for (int i = 0; i <= (values.length - diff); i++) {
double minValue = values[indices[i]];
double maxValue = values[indices[i + diff - 1]];
double range = Math.abs(maxValue - minValue);
if (range < minRange) {
minRange = range;
hpdIndex = i;
}
}
double lower = values[indices[hpdIndex]];
double upper = values[indices[hpdIndex + diff - 1]];
node.setMetaData(label, new Object[]{lower, upper});
}
示例8: scaleAndTranslatePositions
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void scaleAndTranslatePositions(Node node, double scale, double tx, double ty) {
Point2D p = (Point2D) node.getMetaData("p");
node.setMetaData("p", new Point2D.Double(p.getX() * scale + tx, p.getY() * scale + ty));
for (Node child : node.getChildren()) {
scaleAndTranslatePositions(child, scale, tx, ty);
}
}
示例9: setSubTreeLanguages
import beast.evolution.tree.Node; //导入方法依赖的package包/类
protected void setSubTreeLanguages(Node subRoot, Sequence newLang) {
subRoot.setMetaData("lang", newLang);
for (Node n : subRoot.getAllChildNodes()) {
n.setMetaData("lang", newLang);
}
}
示例10: 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);
}
}
示例11: annotateMeanAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateMeanAttribute(Node node, String label, double[] values) {
double mean = DiscreteStatistics.mean(values);
node.setMetaData(label, mean);
}
示例12: annotateMedianAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateMedianAttribute(Node node, String label, double[] values) {
double median = DiscreteStatistics.median(values);
node.setMetaData(label, median);
}
示例13: annotateRangeAttribute
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void annotateRangeAttribute(Node node, String label, double[] values) {
double min = DiscreteStatistics.min(values);
double max = DiscreteStatistics.max(values);
node.setMetaData(label, new Object[]{min, max});
}
示例14: processMetadata
import beast.evolution.tree.Node; //导入方法依赖的package包/类
private void processMetadata(Node node, MetaContext metaContext, boolean isLengthMeta) {
String metaDataString = "";
for (int i=0; i<metaContext.attrib().size(); i++) {
if (i>0)
metaDataString += ",";
metaDataString += metaContext.attrib().get(i).getText();
}
if (isLengthMeta)
node.lengthMetaDataString = metaDataString;
else
node.metaDataString = metaDataString;
if (!suppressMetadata) {
String key;
Object value;
for (NewickParser.AttribContext attribctx : metaContext.attrib()) {
key = attribctx.attribKey.getText();
if (attribctx.attribValue().attribNumber() != null) {
value = Double.parseDouble(attribctx.attribValue().attribNumber().getText());
} else if (attribctx.attribValue().ASTRING() != null) {
String stringValue = attribctx.attribValue().ASTRING().getText();
if (stringValue.startsWith("\"") || stringValue.startsWith("\'")) {
stringValue = stringValue.substring(1, stringValue.length()-1);
}
value = stringValue;
} else if (attribctx.attribValue().vector() != null) {
try {
List<NewickParser.AttribValueContext> elementContexts = attribctx.attribValue().vector().attribValue();
Double[] arrayValues = new Double[elementContexts.size()];
for (int i = 0; i < elementContexts.size(); i++)
arrayValues[i] = Double.parseDouble(elementContexts.get(i).getText());
value = arrayValues;
} catch (NumberFormatException ex) {
throw new TreeParsingException("Encountered vector-valued metadata entry with " +
"one or more non-numeric elements.");
}
} else
throw new TreeParsingException("Encountered unknown metadata value.");
if (isLengthMeta)
node.setLengthMetaData(key, value);
else
node.setMetaData(key, value);
}
}
}