From e85b1902d37f75f3b4b68a5f4b8f21b8e7261b1d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 14 Jun 2013 16:17:58 +0100 Subject: [PATCH] JAL-1316 recognise and extract quoted region as nodename --- src/jalview/io/NewickFile.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jalview/io/NewickFile.java b/src/jalview/io/NewickFile.java index d664dcf..d653811 100755 --- a/src/jalview/io/NewickFile.java +++ b/src/jalview/io/NewickFile.java @@ -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) { -- 1.7.10.2