diff --git a/src/beast/base/parser/NexusParser.java b/src/beast/base/parser/NexusParser.java index 7c10b6a3..0feac83f 100644 --- a/src/beast/base/parser/NexusParser.java +++ b/src/beast/base/parser/NexusParser.java @@ -522,10 +522,20 @@ protected void parseTreesBlock(final BufferedReader fin) throws IOException { } // read trees + int current = 0; while (nextCommand != null && !nextCommand.isEndOfBlock()) { if (nextCommand.isCommand("tree")) { String treeString = nextCommand.arguments; final int i = treeString.indexOf('('); + + + String id = "" + current; + try { + id = treeString.substring(5, i).split("=")[0].trim(); + } catch (Exception e) { + // ignore + } + if (i > 0) { treeString = treeString.substring(i); } @@ -546,8 +556,11 @@ protected void parseTreesBlock(final BufferedReader fin) throws IOException { listener.treeParsed(trees.size(), treeParser); } + treeParser.setID(id); + // this must come after listener or trees.size() gives the wrong index to treeParsed trees.add(treeParser); + current++; } nextCommand = readNextCommand(fin);