use of beast.core.parameter.Parameter in project beast2 by CompEvol.
the class BeautiBase method assertParameterCountInPriorIs.
void assertParameterCountInPriorIs(int i) {
// count nr of parameters in Prior objects in prior
// including those for prior distributions (Normal, etc)
// useful to make sure they do (or do not) get linked
Set<Function> parameters = new LinkedHashSet<>();
CompoundDistribution prior = (CompoundDistribution) doc.pluginmap.get("prior");
for (Distribution p : prior.pDistributions.get()) {
if (p instanceof Prior) {
Prior p2 = (Prior) p;
parameters.add(p2.m_x.get());
for (BEASTInterface o : p2.distInput.get().listActiveBEASTObjects()) {
if (o instanceof Parameter) {
parameters.add((Parameter<?>) o);
}
}
}
}
System.err.println("Number of parameters in prior = " + parameters.size());
if (i >= 0) {
assertThat(parameters.size()).as("Expected " + i + " parameters in prior").isEqualTo(i);
}
}
use of beast.core.parameter.Parameter in project beast2 by CompEvol.
the class SpeciesTreeLogger method toNewick.
String toNewick(final Node node, final Function metadata, final Function metadataTop, List<Function> metadataList) {
final StringBuilder buf = new StringBuilder();
if (node.getLeft() != null) {
buf.append("(");
buf.append(toNewick(node.getLeft(), metadata, metadataTop, metadataList));
if (node.getRight() != null) {
buf.append(',');
buf.append(toNewick(node.getRight(), metadata, metadataTop, metadataList));
}
buf.append(")");
} else {
buf.append(node.getNr() + Tree.taxaTranslationOffset);
}
buf.append("[&");
switch(popSizeFunction) {
case constant:
{
final double popStart = metadata.getArrayValue(node.getNr());
buf.append(dmv + "=").append(popStart);
break;
}
case linear:
case linear_with_constant_root:
buf.append(dmt + "=");
final double b;
if (node.isRoot()) {
b = treeTopFinderInput.get().getHighestTreeHeight() - node.getHeight();
} else {
b = node.getLength();
}
buf.append(b).append("," + dmv + "={");
final double popStart;
if (node.isLeaf()) {
popStart = metadata.getArrayValue(node.getNr());
} else {
popStart = (getMetaDataTopValue(node.getLeft(), metadataTop) + getMetaDataTopValue(node.getRight(), metadataTop));
}
buf.append(popStart);
final double popEnd;
if (node.isRoot() && popSizeFunction == TreePopSizeFunction.linear_with_constant_root) {
popEnd = popStart;
} else {
popEnd = getMetaDataTopValue(node, metadataTop);
}
buf.append(",").append(popEnd).append("}");
break;
}
if (metadataList.size() > 0) {
for (Function metadata2 : metadataList) {
if (metadataList.indexOf(metadata2) > 0 || buf.length() > 1) {
buf.append(",");
}
buf.append(((BEASTObject) metadata2).getID());
buf.append('=');
if (metadata2 instanceof Parameter<?>) {
Parameter<?> p = (Parameter<?>) metadata2;
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(metadata2.getArrayValue(node.getNr()));
}
} else {
buf.append(metadata2.getArrayValue(node.getNr()));
}
}
}
buf.append(']');
if (!node.isRoot()) {
buf.append(":").append(node.getLength());
}
return buf.toString();
}
Aggregations