From: jprocter Date: Mon, 22 Mar 2010 17:13:12 +0000 (+0000) Subject: See note in Mantis bug #55537 : inconsistency between loading in exported histogram... X-Git-Tag: Release_2_5~123 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=75a1f7cee379a690c42b5ac2c5f58c4475f46564;p=jalview.git See note in Mantis bug #55537 : inconsistency between loading in exported histogram annotation and annotation row type dependent parsing of the column annotation fields. --- diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 9381020..00b7ead 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -72,10 +72,18 @@ public class AnnotationFile this.hiddenRepSeqs = hiddenRepSeqs; } } - + /** + * Prepare an annotation file given a set of annotations, groups, alignment properties and views. + * @param annotations + * @param groups + * @param properties + * @param views + * @return annotation file + */ public String printAnnotations(AlignmentAnnotation[] annotations, Vector groups, Hashtable properties, ViewDef[] views) { + // TODO: resolve views issue : annotationFile could contain visible region, or full data + hidden region specifications for a view. if (annotations != null) { boolean oneColour = true; @@ -224,7 +232,6 @@ public class AnnotationFile if (hasLabels) { // TODO: labels are emitted after values for bar graphs. - text.append(comma); if // empty labels are allowed, so (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length() > 0 @@ -627,7 +634,7 @@ public class AnnotationFile } else { - annotations[index++] = parseAnnotation(token); + annotations[index++] = parseAnnotation(token, graphStyle); emptyColumn = false; } } @@ -682,8 +689,9 @@ public class AnnotationFile return true; } - Annotation parseAnnotation(String string) + Annotation parseAnnotation(String string, int graphStyle) { + boolean hasSymbols = (graphStyle == AlignmentAnnotation.NO_GRAPH); // don't do the glyph test if we don't want secondary structure String desc = null, displayChar = null; char ss = ' '; // secondaryStructure float value = 0; @@ -698,31 +706,40 @@ public class AnnotationFile UserColourScheme ucs = new UserColourScheme(); colour = ucs.getColourFromString(string.substring(i + 1, j)); - + if ( i>0 && string.charAt(i-1)==',') + { + // clip the preceding comma as well + i--; + } string = string.substring(0, i) + string.substring(j + 1); } - StringTokenizer st = new StringTokenizer(string, ","); + StringTokenizer st = new StringTokenizer(string, ",", true); String token; + boolean seenContent=false; while (st.hasMoreTokens()) { token = st.nextToken().trim(); - if (token.length() == 0) + if (token.equals(",")) { - if (parsedValue && !dcset) + if (!seenContent && parsedValue && !dcset) { // allow the value below the bar/line to be empty dcset = true; displayChar = " "; } + seenContent = false; continue; + } else { + seenContent = true; } if (!parsedValue) { try { - displayChar = token; + displayChar = token; + // foo value = new Float(token).floatValue(); parsedValue = true; continue; @@ -731,7 +748,7 @@ public class AnnotationFile } } - if (token.equals("H") || token.equals("E")) + if (hasSymbols && (token.equals("H") || token.equals("E"))) { // Either this character represents a helix or sheet // or an integer which can be displayed @@ -747,10 +764,10 @@ public class AnnotationFile } } - if (!dcset && string.charAt(string.length() - 1) == ',') - { - displayChar = " "; // empty display char symbol. - } +// if (!dcset && string.charAt(string.length() - 1) == ',') +// { +// displayChar = " "; // empty display char symbol. +// } if (displayChar != null && displayChar.length() > 1 && desc != null && desc.length() == 1) {