- // ascending should not be set\r
- // New Internal node\r
- if (ascending) {\r
- Error = ErrorStringrange(Error, "Unexpected '('", 7, fcp, nf);\r
-\r
- continue;\r
- }\r
-\r
- ;\r
- d++;\r
-\r
- if (c.right() == null) {\r
- c.setRight(new SequenceNode(null, c, null, DefDistance,\r
- DefBootstrap, false));\r
- c = (SequenceNode) c.right();\r
- } else {\r
- if (c.left() != null) {\r
- // Dummy node for polytomy - keeps c.left free for new node\r
- SequenceNode tmpn = new SequenceNode(null, c, null, 0,\r
- 0, true);\r
- tmpn.SetChildren(c.left(), c.right());\r
- c.setRight(tmpn);\r
- }\r
-\r
- c.setLeft(new SequenceNode(null, c, null, DefDistance,\r
- DefBootstrap, false));\r
- c = (SequenceNode) c.left();\r
- }\r
-\r
- if (realroot == null) {\r
- realroot = c;\r
- }\r
-\r
- nodename = null;\r
- distance = DefDistance;\r
- bootstrap = DefBootstrap;\r
- cp = fcp + 1;\r
-\r
- break;\r
-\r
- // Deal with quoted fields\r
- case '\'':\r
-\r
- com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex(\r
- "([^']|'')+'");\r
-\r
- if (qnodename.searchFrom(nf, fcp)) {\r
- int nl = qnodename.stringMatched().length();\r
- nodename = new String(qnodename.stringMatched().substring(0,\r
- nl - 1));\r
- cp = fcp + nl + 1;\r
- } else {\r
- Error = ErrorStringrange(Error,\r
- "Unterminated quotes for nodename", 7, fcp, nf);\r
- }\r
-\r
- break;\r
-\r
- case ';':\r
-\r
- if (d != -1) {\r
- Error = ErrorStringrange(Error,\r
- "Wayward semicolon (depth=" + d + ")", 7, fcp, nf);\r
- }\r
-\r
- // cp advanced at the end of default\r
- default:\r
-\r
- // Parse simpler field strings\r
- String fstring = nf.substring(cp, fcp);\r
- com.stevesoft.pat.Regex uqnodename = new com.stevesoft.pat.Regex(\r
- "\\b([^' :;\\](),]+)");\r
- com.stevesoft.pat.Regex nbootstrap = new com.stevesoft.pat.Regex(\r
- "\\S+([0-9+]+)\\S*:");\r
- com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex(\r
- ":([-0-9.+]+)");\r
-\r
- if (uqnodename.search(fstring) &&\r
- ((uqnodename.matchedFrom(1) == 0) ||\r
- (fstring.charAt(uqnodename.matchedFrom(1) - 1) != ':'))) // JBPNote HACK!\r
- {\r
- if (nodename == null) {\r
- if (ReplaceUnderscores) {\r
- nodename = uqnodename.stringMatched(1).replace('_',\r
- ' ');\r
- } else {\r
- nodename = uqnodename.stringMatched(1);\r
- }\r
- } else {\r
- Error = ErrorStringrange(Error,\r
- "File has broken algorithm - overwritten nodename",\r
- 10, fcp, nf);\r
- }\r
- }\r
-\r
- if (nbootstrap.search(fstring) &&\r
- (nbootstrap.matchedFrom(1) > (uqnodename.matchedFrom(1) +\r
- uqnodename.stringMatched().length()))) {\r
- try {\r
- bootstrap = (new Integer(nbootstrap.stringMatched(1))).intValue();\r
- HasBootstrap = true;\r
- } catch (Exception e) {\r
- Error = ErrorStringrange(Error,\r
- "Can't parse bootstrap value", 4,\r
- cp + nbootstrap.matchedFrom(), nf);\r
- }\r
- }\r
-\r
- boolean nodehasdistance = false;\r
-\r
- if (ndist.search(fstring)) {\r
- try {\r
- distance = (new Float(ndist.stringMatched(1))).floatValue();\r
- HasDistances = true;\r
- nodehasdistance = true;\r
- } catch (Exception e) {\r
- Error = ErrorStringrange(Error,\r
- "Can't parse node distance value", 7,\r
- cp + ndist.matchedFrom(), nf);\r
- }\r
- }\r
-\r
- if (ascending) {\r
- // Write node info here\r
- c.setName(nodename);\r
- c.dist = (HasDistances) ? distance : 0;\r
- c.setBootstrap((HasBootstrap) ? bootstrap : 0);\r
-\r
- if (c == realroot) {\r
- RootHasDistance = nodehasdistance; // JBPNote This is really UGLY!!!\r
- }\r
- } else {\r
- // Find a place to put the leaf\r
- SequenceNode newnode = new SequenceNode(null, c, nodename,\r
- (HasDistances) ? distance : DefDistance,\r
- (HasBootstrap) ? bootstrap : DefBootstrap, false);\r
-\r
- if (c.right() == null) {\r
- c.setRight(newnode);\r
- } else {\r
- if (c.left() == null) {\r
- c.setLeft(newnode);\r
- } else {\r
- // Insert a dummy node for polytomy\r
- SequenceNode newdummy = new SequenceNode(null, c,\r
- null, 0, 0, true);\r
- newdummy.SetChildren(c.left(), newnode);\r
- c.setLeft(newdummy);\r
- }\r
- }\r
- }\r