From: jprocter Date: Wed, 28 Apr 2010 10:16:32 +0000 (+0000) Subject: group/annotation association X-Git-Tag: Release_2_5~42 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=12b928f827972f429471a5bf7a832fa634259a16;p=jalview.git group/annotation association --- diff --git a/help/html/features/annotationsFormat.html b/help/html/features/annotationsFormat.html index fcec5c0..fc0d4c4 100755 --- a/help/html/features/annotationsFormat.html +++ b/help/html/features/annotationsFormat.html @@ -33,13 +33,13 @@ separated value fields. Each value field is itself a comma separated list of fie GRAPH_TYPE. The allowed values of GRAPH_TYPE and the format of their respective value fields (with the trailing "|" symbol) are shown below: Any or all value fields may be left empty, as well as the BAR_GRAPH's @@ -55,11 +55,17 @@ associated with that sequence, and the first field in the Value field list will (optionally) be placed at the startIndex'th column.

+sequence's name followed by the annotation row's description.
+New in Jalview 2.5: Clicking on a sequence or group associated annotation row's label will highlight the sequence or sequence group in the alignment, and double clicking the annotation row label will select the associated sequence or group.

Sequence associations are turned off for subsequent annotation definitions by:

SEQUENCE_REF	ALIGNMENT

+

Since version 2.5, Jalview allows annotation rows to be associated with a group defined on the alignment, by preceding the annotation row with the line: +

GROUP_REF	group_name
+Group association is turned off for subsequent annotation rows by +
GROUP_REF	ALIGNMENT
+Annotations may be associated with both a sequence and a group, however - group annotations are still experimental and unexpected behaviour may be observed when editing alignments containing both group and sequence associated annotation rows.

LINE_GRAPH type annotations can be given a colour (specified as 24 bit RGB triplet in hexadecimal or comma separated values), combined onto the same vertical axis, and have ordinate lines @@ -69,13 +75,13 @@ following commands (respectively): COMBINE graph_1_name graph_2_name GRAPHLINE graph_name value label colour -

(Since Jalview 2.4.1) ROWPROPERTIES

+

(Since Jalview 2.5) ROWPROPERTIES

The visual display properties for a set of annotation rows can be modified using the following tab-delimited line:

ROWPROPERTIES	Row label	centrelabs=true( or false)	showalllabs=true(default is false)	scaletofit=true (default is false)

This sets the visual display properties according to the given values for all the annotation rows with labels matching Row label. The properties mostly affect the display of multi-character column labels, and are as follows:

(Since Jalview 2.2.1) SEQUENCE_GROUP

Groups of sequences can be defined using the tab delimited line

@@ -108,8 +114,9 @@ GRAPHLINE graph_name value label colo textCol2=black
textColThreshold=0
idColour=ff3322
+ showunconserved=false

An example Annotation file is given below: diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index aac48eb..01daf39 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -72,8 +72,11 @@ public class AnnotationFile this.hiddenRepSeqs = hiddenRepSeqs; } } + /** - * Prepare an annotation file given a set of annotations, groups, alignment properties and views. + * Prepare an annotation file given a set of annotations, groups, alignment + * properties and views. + * * @param annotations * @param groups * @param properties @@ -83,13 +86,15 @@ public class AnnotationFile 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. + // TODO: resolve views issue : annotationFile could contain visible region, + // or full data + hidden region specifications for a view. if (annotations != null) { boolean oneColour = true; AlignmentAnnotation row; String comma; SequenceI refSeq = null; + SequenceGroup refGroup = null; StringBuffer colours = new StringBuffer(); StringBuffer graphLine = new StringBuffer(); @@ -120,11 +125,34 @@ public class AnnotationFile refSeq = null; } - else if (refSeq == null || refSeq != row.sequenceRef) + else + { + if (refSeq == null || refSeq != row.sequenceRef) + { + refSeq = row.sequenceRef; + text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n"); + } + } + // mark any group references for the row + if (row.groupRef == null) + { + + if (refGroup != null) + { + text.append("\nGROUP_REF\tALIGNMENT\n"); + } + + refGroup = null; + } + else { - refSeq = row.sequenceRef; - text.append("\nSEQUENCE_REF\t" + refSeq.getName() + "\n"); + if (refGroup == null || refGroup != row.groupRef) + { + refGroup = row.groupRef; + text.append("\nGROUP_REF\t" + refGroup.getName() + "\n"); + } } + boolean hasGlyphs = row.hasIcons, hasLabels = row.hasText, hasValues = row.hasScore, hasText = false; // lookahead to check what the annotation row object actually contains. for (int j = 0; row.annotations != null @@ -138,8 +166,8 @@ public class AnnotationFile .equals(" ")); hasGlyphs |= (row.annotations[j].secondaryStructure != 0 && row.annotations[j].secondaryStructure != ' '); hasValues |= (row.annotations[j].value != Float.NaN); // NaNs can't - // be - // rendered.. + // be + // rendered.. hasText |= (row.annotations[j].description != null && row.annotations[j].description .length() > 0); } @@ -210,7 +238,7 @@ public class AnnotationFile if (row.annotations[j] != null) { comma = ""; - if (hasGlyphs) // could be also hasGlyphs || ... + if (hasGlyphs) // could be also hasGlyphs || ... { text.append(comma); @@ -288,12 +316,13 @@ public class AnnotationFile colours.append("COLOUR\t" + row.label + "\t" + jalview.util.Format.getHexString(color) + "\n"); } - if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) + if (row.scaleColLabel || row.showAllColLabels + || row.centreColLabels) { - rowprops.append("ROWPROPERTIES\t"+row.label); - rowprops.append("\tscaletofit="+row.scaleColLabel); - rowprops.append("\tshowalllabs="+row.showAllColLabels); - rowprops.append("\tcentrelabs="+row.centreColLabels); + rowprops.append("ROWPROPERTIES\t" + row.label); + rowprops.append("\tscaletofit=" + row.scaleColLabel); + rowprops.append("\tshowalllabs=" + row.showAllColLabels); + rowprops.append("\tcentrelabs=" + row.centreColLabels); rowprops.append("\n"); } } @@ -433,7 +462,10 @@ public class AnnotationFile public boolean readAnnotationFile(AlignmentI al, String file, String protocol) { - Hashtable autoAnnots=new Hashtable(); + String groupRef = null; + Hashtable groupRefRows = new Hashtable(); + + Hashtable autoAnnots = new Hashtable(); try { BufferedReader in = null; @@ -463,21 +495,28 @@ public class AnnotationFile int graphStyle, index; int refSeqIndex = 1; int existingAnnotations = 0; - // when true - will add new rows regardless of whether they are duplicate auto-annotation like consensus or conservation graphs - boolean overrideAutoAnnot=false; + // when true - will add new rows regardless of whether they are duplicate + // auto-annotation like consensus or conservation graphs + boolean overrideAutoAnnot = false; if (al.getAlignmentAnnotation() != null) { existingAnnotations = al.getAlignmentAnnotation().length; - if (existingAnnotations>0) + if (existingAnnotations > 0) { AlignmentAnnotation[] aa = al.getAlignmentAnnotation(); - for (int aai=0;aai 0) + { + AlignmentAnnotation alan = null; + for (int elm = 0, elmSize = rowset.size(); elm < elmSize; elm++) + { + alan = (AlignmentAnnotation) rowset.elementAt(elm); + alan.groupRef = theGroup; + } + } + } + } + } + ((Vector) groupRefRows.get(groupRef)).removeAllElements(); + } } catch (Exception ex) { ex.printStackTrace(); @@ -718,7 +835,15 @@ public class AnnotationFile 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 + 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; @@ -733,7 +858,7 @@ public class AnnotationFile UserColourScheme ucs = new UserColourScheme(); colour = ucs.getColourFromString(string.substring(i + 1, j)); - if ( i>0 && string.charAt(i-1)==',') + if (i > 0 && string.charAt(i - 1) == ',') { // clip the preceding comma as well i--; @@ -743,8 +868,8 @@ public class AnnotationFile StringTokenizer st = new StringTokenizer(string, ",", true); String token; - boolean seenContent=false; - int pass=0; + boolean seenContent = false; + int pass = 0; while (st.hasMoreTokens()) { pass++; @@ -759,7 +884,9 @@ public class AnnotationFile } seenContent = false; continue; - } else { + } + else + { seenContent = true; } @@ -767,7 +894,7 @@ public class AnnotationFile { try { - displayChar = token; + displayChar = token; // foo value = new Float(token).floatValue(); parsedValue = true; @@ -775,13 +902,17 @@ public class AnnotationFile } catch (NumberFormatException ex) { } - } else { - if (token.length()==1) + } + else + { + if (token.length() == 1) { displayChar = token; } } - if (hasSymbols && (token.equals("H") || token.equals("E") || token.equals(" "))) + if (hasSymbols + && (token.equals("H") || token.equals("E") || token + .equals(" "))) { // Either this character represents a helix or sheet // or an integer which can be displayed @@ -791,26 +922,29 @@ public class AnnotationFile displayChar = ""; } } - else if (desc == null || (parsedValue && pass>2)) + else if (desc == null || (parsedValue && pass > 2)) { desc = token; } } -// if (!dcset && string.charAt(string.length() - 1) == ',') -// { -// displayChar = " "; // empty display char symbol. -// } - if (displayChar != null && desc!=null && desc.length()==1) + // if (!dcset && string.charAt(string.length() - 1) == ',') + // { + // displayChar = " "; // empty display char symbol. + // } + if (displayChar != null && desc != null && desc.length() == 1) { if (displayChar.length() > 1) { - // switch desc and displayChar - legacy support + // switch desc and displayChar - legacy support String tmp = displayChar; displayChar = desc; desc = tmp; - } else { - if (displayChar.equals(desc)) { + } + else + { + if (displayChar.equals(desc)) + { // duplicate label - hangover from the 'robust parser' above desc = null; } @@ -999,33 +1133,38 @@ public class AnnotationFile void addRowProperties(AlignmentI al, StringTokenizer st) { - String label = st.nextToken(),keyValue,key,value; - boolean scaletofit=false,centerlab=false,showalllabs=false; - while (st.hasMoreTokens()) { - keyValue=st.nextToken(); + String label = st.nextToken(), keyValue, key, value; + boolean scaletofit = false, centerlab = false, showalllabs = false; + while (st.hasMoreTokens()) + { + keyValue = st.nextToken(); key = keyValue.substring(0, keyValue.indexOf("=")); value = keyValue.substring(keyValue.indexOf("=") + 1); - if (key.equalsIgnoreCase("scaletofit")) { + if (key.equalsIgnoreCase("scaletofit")) + { scaletofit = Boolean.valueOf(value).booleanValue(); } - if (key.equalsIgnoreCase("showalllabs")) { - showalllabs = Boolean.valueOf(value).booleanValue(); - } - if (key.equalsIgnoreCase("centrelabs")) { - centerlab = Boolean.valueOf(value).booleanValue(); - } - AlignmentAnnotation[] alr = al.getAlignmentAnnotation(); - for (int i = 0; i < alr.length; i++) + if (key.equalsIgnoreCase("showalllabs")) + { + showalllabs = Boolean.valueOf(value).booleanValue(); + } + if (key.equalsIgnoreCase("centrelabs")) + { + centerlab = Boolean.valueOf(value).booleanValue(); + } + AlignmentAnnotation[] alr = al.getAlignmentAnnotation(); + for (int i = 0; i < alr.length; i++) + { + if (alr[i].label.equalsIgnoreCase(label)) { - if (alr[i].label.equalsIgnoreCase(label)) - { - alr[i].centreColLabels = centerlab; - alr[i].scaleColLabel = scaletofit; - alr[i].showAllColLabels = showalllabs; - } + alr[i].centreColLabels = centerlab; + alr[i].scaleColLabel = scaletofit; + alr[i].showAllColLabels = showalllabs; } + } } } + void addProperties(AlignmentI al, StringTokenizer st) {