JAL-1316 recognise and extract quoted region as nodename
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 14 Jun 2013 15:17:58 +0000 (16:17 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Fri, 14 Jun 2013 15:17:58 +0000 (16:17 +0100)
src/jalview/io/NewickFile.java

index d664dcf..d653811 100755 (executable)
@@ -292,6 +292,7 @@ public class NewickFile extends FileParse
 
     int nextcp = 0;
     int ncp = cp;
+    boolean parsednodename=false;
     while (majorsyms.searchFrom(nf, cp) && (Error == null))
     {
       int fcp = majorsyms.matchedFrom();
@@ -349,14 +350,16 @@ public class NewickFile extends FileParse
       case '\'':
 
         com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex(
-                "([^']|'')+'");
+                "'([^']|'')+'");
 
         if (qnodename.searchFrom(nf, fcp))
         {
           int nl = qnodename.stringMatched().length();
-          nodename = new String(qnodename.stringMatched().substring(0,
+          nodename = new String(qnodename.stringMatched().substring(1,
                   nl - 1));
-          cp = fcp + nl + 1;
+          // jump to after end of quoted nodename
+          nextcp = fcp + nl + 1;
+          parsednodename=true;
         }
         else
         {
@@ -425,7 +428,7 @@ public class NewickFile extends FileParse
         com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex(
                 ":([-0-9Ee.+]+)");
 
-        if (uqnodename.search(fstring)
+        if (!parsednodename && uqnodename.search(fstring)
                 && ((uqnodename.matchedFrom(1) == 0) || (fstring
                         .charAt(uqnodename.matchedFrom(1) - 1) != ':'))) // JBPNote
         // HACK!
@@ -584,6 +587,7 @@ public class NewickFile extends FileParse
         distance = DefDistance;
         bootstrap = DefBootstrap;
         commentString2 = null;
+        parsednodename=false;
       }
       if (nextcp == 0)
       {