From 95d74892773dede6aeb3a4791340f022d2df8903 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 23 Apr 2010 15:11:10 +0000 Subject: [PATCH] next attempt for Bug #36198 - appears to work reproducibly --- src/jalview/io/AnnotationFile.java | 43 +++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index ce1afc2..87b21d3 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -210,10 +210,15 @@ public class AnnotationFile if (row.annotations[j] != null) { comma = ""; - if (row.annotations[j].secondaryStructure != ' ') // could be also hasGlyphs || ... + if (hasGlyphs) // could be also hasGlyphs || ... { - text.append(comma + row.annotations[j].secondaryStructure); + text.append(comma); + if (row.annotations[j].secondaryStructure != ' ') + { + // only write out the field if its not whitespace. + text.append(row.annotations[j].secondaryStructure); + } comma = ","; } if (hasValues) @@ -717,8 +722,10 @@ public class AnnotationFile StringTokenizer st = new StringTokenizer(string, ",", true); String token; boolean seenContent=false; + int pass=0; while (st.hasMoreTokens()) { + pass++; token = st.nextToken().trim(); if (token.equals(",")) { @@ -746,8 +753,12 @@ public class AnnotationFile } catch (NumberFormatException ex) { } + } else { + if (token.length()==1) + { + displayChar = token; + } } - if (hasSymbols && (token.equals("H") || token.equals("E") || token.equals(" "))) { // Either this character represents a helix or sheet @@ -758,7 +769,7 @@ public class AnnotationFile displayChar = ""; } } - else if (desc == null) + else if (desc == null || (parsedValue && pass>2)) { desc = token; } @@ -768,19 +779,21 @@ public class AnnotationFile // { // displayChar = " "; // empty display char symbol. // } - if (displayChar != null && displayChar.length() > 1 && desc != null - && desc.length() == 1) + if (displayChar != null && desc!=null && desc.length()==1) { - String tmp = displayChar; - displayChar = desc; - desc = tmp; + if (displayChar.length() > 1) + { + // switch desc and displayChar - legacy support + String tmp = displayChar; + displayChar = desc; + desc = tmp; + } else { + if (displayChar.equals(desc)) { + // duplicate label - hangover from the 'robust parser' above + desc = null; + } + } } - /* - * In principle, this code will ensure that the Annotation element generated - * is renderable by any of the applet or application rendering code but - * instead we check for null strings when the display character is rendered. - * if (displayChar==null) { displayChar=""; } - */ Annotation anot = new Annotation(displayChar, desc, ss, value); anot.colour = colour; -- 1.7.10.2