X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FNewickFile.java;h=9ed14916c0e51b9fb1dbac0740175f2d4c2d4808;hb=8f2bef6f91e7a6e47e41e78a82f45f7e406ef90a;hp=8e374ac0d722eab205ae4112b8f53545ac4059f2;hpb=d423f22792e47dbc800ae220a58677f988971d06;p=jalview.git diff --git a/src/jalview/io/NewickFile.java b/src/jalview/io/NewickFile.java index 8e374ac..9ed1491 100755 --- a/src/jalview/io/NewickFile.java +++ b/src/jalview/io/NewickFile.java @@ -1,13 +1,13 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) + * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -215,8 +215,8 @@ public class NewickFile extends FileParse + " at position " + p + " ( " - + s.substring(((p - r) < 0) ? 0 : (p - r), ((p + r) > s - .length()) ? s.length() : (p + r)) + " )\n"; + + s.substring(((p - r) < 0) ? 0 : (p - r), + ((p + r) > s.length()) ? s.length() : (p + r)) + " )\n"; } // @tree annotations @@ -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,20 @@ 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; + // unpack any escaped colons + com.stevesoft.pat.Regex xpandquotes = com.stevesoft.pat.Regex.perlCode("s/''/'/"); + String widernodename = xpandquotes.replaceAll(nodename); + nodename=widernodename; + // jump to after end of quoted nodename + nextcp = fcp + nl + 1; + parsednodename=true; } else { @@ -425,7 +432,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! @@ -470,8 +477,8 @@ public class NewickFile extends FileParse } catch (Exception e) { Error = ErrorStringrange(Error, - "Can't parse bootstrap value", 4, ncp - + nbootstrap.matchedFrom(), nf); + "Can't parse bootstrap value", 4, + ncp + nbootstrap.matchedFrom(), nf); } } } @@ -488,8 +495,8 @@ public class NewickFile extends FileParse } catch (Exception e) { Error = ErrorStringrange(Error, - "Can't parse node distance value", 7, ncp - + ndist.matchedFrom(), nf); + "Can't parse node distance value", 7, + ncp + ndist.matchedFrom(), nf); } } @@ -584,6 +591,7 @@ public class NewickFile extends FileParse distance = DefDistance; bootstrap = DefBootstrap; commentString2 = null; + parsednodename=false; } if (nextcp == 0) {