Skip to content

Commit c520aaf

Browse files
committed
set ids of trees parsed from NEXUS file. fixes CompEvol/BeastFX#87
1 parent fe85402 commit c520aaf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/beast/base/parser/NexusParser.java

+13
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,20 @@ protected void parseTreesBlock(final BufferedReader fin) throws IOException {
522522
}
523523

524524
// read trees
525+
int current = 0;
525526
while (nextCommand != null && !nextCommand.isEndOfBlock()) {
526527
if (nextCommand.isCommand("tree")) {
527528
String treeString = nextCommand.arguments;
528529
final int i = treeString.indexOf('(');
530+
531+
532+
String id = "" + current;
533+
try {
534+
id = treeString.substring(5, i).split("=")[0].trim();
535+
} catch (Exception e) {
536+
// ignore
537+
}
538+
529539
if (i > 0) {
530540
treeString = treeString.substring(i);
531541
}
@@ -546,8 +556,11 @@ protected void parseTreesBlock(final BufferedReader fin) throws IOException {
546556
listener.treeParsed(trees.size(), treeParser);
547557
}
548558

559+
treeParser.setID(id);
560+
549561
// this must come after listener or trees.size() gives the wrong index to treeParsed
550562
trees.add(treeParser);
563+
current++;
551564

552565
}
553566
nextCommand = readNextCommand(fin);

0 commit comments

Comments
 (0)