Skip to content

Commit

Permalink
make TreeWithMetaDataLogger produce correct nr of commas. fixes #1177
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Jan 5, 2025
1 parent 3ed7a39 commit 0e97234
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/beast/base/evolution/TreeWithMetaDataLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ String toNewick(Node node, List<Function> metadataList, BranchRateModel.Base bra
if (someMetaDataNeedsLogging) {
buf2.append("[&");
if (metadataList.size() > 0) {
boolean needsComma = false;
for (Function metadata : metadataList) {
if (metadata instanceof Parameter<?>) {
Parameter<?> p = (Parameter<?>) metadata;
int dim = p.getMinorDimension1();
if (p.getMinorDimension2() > node.getNr()) {
if (needsComma) {
buf2.append(",");
}
buf2.append(((BEASTObject) metadata).getID());
buf2.append('=');
if (dim > 1) {
Expand All @@ -152,19 +156,21 @@ String toNewick(Node node, List<Function> metadataList, BranchRateModel.Base bra
buf2.append(metadata.getArrayValue(node.getNr()));
}
}
needsComma = true;
} else {

}
} else {
if (metadata.getDimension() > node.getNr()) {
if (needsComma) {
buf2.append(",");
}
buf2.append(((BEASTObject) metadata).getID());
buf2.append('=');
buf2.append(metadata.getArrayValue(node.getNr()));
needsComma = true;
}
}
if (buf2.length() > 2 && metadataList.indexOf(metadata) < metadataList.size() - 1) {
buf2.append(",");
}
}
if (buf2.length() > 2 && branchRateModel != null) {
buf2.append(",");
Expand Down

0 comments on commit 0e97234

Please sign in to comment.