1 Clazz.declarePackage ("jalview.io");
2 Clazz.load (null, "jalview.io.AnnotationFile", ["jalview.analysis.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.ColumnSelection", "$.GraphLine", "$.SequenceGroup", "jalview.io.AppletFormatAdapter", "jalview.jsdev.GenericFileAdapter", "jalview.schemes.ColourSchemeProperty", "$.ResidueProperties", "$.UserColourScheme", "jalview.util.Comparison", "$.Format", "java.awt.Color", "java.io.BufferedReader", "$.InputStreamReader", "$.StringReader", "java.lang.Boolean", "$.Float", "$.StringBuffer", "java.util.ArrayList", "$.BitSet", "$.Date", "$.Hashtable", "$.StringTokenizer", "$.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) {
7 jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ ();
13 Clazz.instantialize (this, arguments);
14 }, jalview.io, "AnnotationFile");
15 Clazz.prepareFields (c$, function () {
16 this.newline = System.getProperty ("line.separator");
18 Clazz.makeConstructor (c$,
22 Clazz.defineMethod (c$, "setNewlineString",
27 Clazz.defineMethod (c$, "getNewlineString",
31 Clazz.defineMethod (c$, "init",
33 this.text = new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " + new java.util.Date () + this.newline + this.newline);
36 }, $fz.isPrivate = true, $fz));
37 Clazz.defineMethod (c$, "printAnnotations",
38 function (annotations, list, properties) {
39 return this.printAnnotations (annotations, list, properties, null, null, null);
40 }, "~A,java.util.List,java.util.Hashtable");
41 Clazz.defineMethod (c$, "printAnnotations",
42 function (annotations, list, properties, cs, al, view) {
44 if (view.viewname != null) {
45 this.text.append ("VIEW_DEF\t" + view.viewname + "\n");
47 list = view.visibleGroups;
51 }}if (al != null && al.hasSeqrep ()) {
52 this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n");
53 }if (cs != null && cs.hasHiddenColumns ()) {
54 this.text.append ("VIEW_HIDECOLS\t");
55 var hc = cs.getHiddenColumns ();
57 for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) {
61 this.text.append (",");
62 }this.text.append ("" + r[0]);
63 this.text.append ("-");
64 this.text.append ("" + r[1]);
66 this.text.append ("\n");
67 }if (annotations != null) {
73 var colours = new StringBuffer ();
74 var graphLine = new StringBuffer ();
75 var rowprops = new StringBuffer ();
76 var graphGroup = new java.util.Hashtable ();
77 var graphGroup_refs = new java.util.Hashtable ();
78 var graphGroupSeen = new java.util.BitSet ();
80 for (var i = 0; i < annotations.length; i++) {
82 if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) {
86 this.writeSequence_Ref (refSeq, row.sequenceRef);
87 refSeq = row.sequenceRef;
88 this.writeGroup_Ref (refGroup, row.groupRef);
89 refGroup = row.groupRef;
90 var hasGlyphs = row.hasIcons;
91 var hasLabels = row.hasText;
92 var hasValues = row.$hasScore;
94 for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) {
95 if (row.annotations[j] != null) {
96 hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf ();
97 hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf ();
98 hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf ();
99 hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf ();
101 if (row.graph == 0) {
102 this.text.append ("NO_GRAPH\t");
105 if (row.graph == 1) {
106 this.text.append ("BAR_GRAPH\t");
108 } else if (row.graph == 2) {
110 this.text.append ("LINE_GRAPH\t");
111 }if (row.getThreshold () != null) {
112 graphLine.append ("GRAPHLINE\t");
113 graphLine.append (row.label);
114 graphLine.append ("\t");
115 graphLine.append (row.getThreshold ().value);
116 graphLine.append ("\t");
117 graphLine.append (row.getThreshold ().label);
118 graphLine.append ("\t");
119 graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour));
120 graphLine.append (this.newline);
121 }if (row.graphGroup > -1) {
122 graphGroupSeen.set (row.graphGroup);
123 var key = new Integer (row.graphGroup);
124 if (graphGroup.containsKey (key)) {
125 graphGroup.put (key, graphGroup.get (key) + "\t" + row.label);
127 graphGroup_refs.put (key, Clazz.newArray (-1, [refSeq, refGroup]));
128 graphGroup.put (key, row.label);
129 }}}this.text.append (row.label + "\t");
130 if (row.description != null) {
131 this.text.append (row.description + "\t");
132 }for (var j = 0; row.annotations != null && j < row.annotations.length; j++) {
133 if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) {
135 }if (row.annotations[j] != null) {
138 this.text.append (comma);
139 if (row.annotations[j].secondaryStructure != ' ') {
140 this.text.append (row.annotations[j].secondaryStructure);
143 if (!Float.isNaN (row.annotations[j].value)) {
144 this.text.append (comma + row.annotations[j].value);
146 System.err.println ("Skipping NaN - not valid value.");
147 this.text.append (comma + 0);
150 if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) {
151 this.text.append (comma + row.annotations[j].displayCharacter);
154 if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) {
155 this.text.append (comma + row.annotations[j].description);
157 }}if (color != null && !color.equals (row.annotations[j].colour)) {
159 }color = row.annotations[j].colour;
160 if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) {
161 this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]");
163 }}this.text.append ("|");
165 if (row.hasScore ()) {
166 this.text.append ("\t" + row.score);
167 }this.text.append (this.newline);
168 if (color != null && color !== java.awt.Color.black && oneColour) {
169 colours.append ("COLOUR\t");
170 colours.append (row.label);
171 colours.append ("\t");
172 colours.append (jalview.util.Format.getHexString (color));
173 colours.append (this.newline);
174 }if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) {
175 rowprops.append ("ROWPROPERTIES\t");
176 rowprops.append (row.label);
177 rowprops.append ("\tscaletofit=");
178 rowprops.append (row.scaleColLabel);
179 rowprops.append ("\tshowalllabs=");
180 rowprops.append (row.showAllColLabels);
181 rowprops.append ("\tcentrelabs=");
182 rowprops.append (row.centreColLabels);
183 rowprops.append (this.newline);
184 }if (graphLine.length () > 0) {
185 this.text.append (graphLine.toString ());
186 graphLine.setLength (0);
188 this.text.append (this.newline);
189 this.text.append (colours.toString ());
190 if (graphGroup.size () > 0) {
191 var oldRefSeq = refSeq;
192 var oldRefGroup = refGroup;
193 for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) {
194 var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ());
195 this.writeSequence_Ref (refSeq, seqRefAndGroup[0]);
196 refSeq = seqRefAndGroup[0];
197 this.writeGroup_Ref (refGroup, seqRefAndGroup[1]);
198 refGroup = seqRefAndGroup[1];
199 this.text.append ("COMBINE\t");
200 this.text.append (combine_statement.getValue ());
201 this.text.append (this.newline);
203 this.writeSequence_Ref (refSeq, oldRefSeq);
205 this.writeGroup_Ref (refGroup, oldRefGroup);
206 refGroup = oldRefGroup;
207 }this.text.append (rowprops.toString ());
209 this.printGroups (list);
210 }if (properties != null) {
211 this.text.append (this.newline);
212 this.text.append (this.newline);
213 this.text.append ("ALIGNMENT");
214 var en = properties.keys ();
215 while (en.hasMoreElements ()) {
216 var key = en.nextElement ().toString ();
217 this.text.append ("\t");
218 this.text.append (key);
219 this.text.append ("=");
220 this.text.append (properties.get (key));
222 }return this.text.toString ();
223 }, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef");
224 Clazz.defineMethod (c$, "writeGroup_Ref",
225 ($fz = function (refGroup, next_refGroup) {
226 if (next_refGroup == null) {
227 if (refGroup != null) {
228 this.text.append (this.newline);
229 this.text.append ("GROUP_REF\t");
230 this.text.append ("ALIGNMENT");
231 this.text.append (this.newline);
234 if (refGroup == null || refGroup !== next_refGroup) {
235 this.text.append (this.newline);
236 this.text.append ("GROUP_REF\t");
237 this.text.append (next_refGroup.getName ());
238 this.text.append (this.newline);
241 }, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup");
242 Clazz.defineMethod (c$, "writeSequence_Ref",
243 ($fz = function (refSeq, next_refSeq) {
244 if (next_refSeq == null) {
245 if (refSeq != null) {
246 this.text.append (this.newline);
247 this.text.append ("SEQUENCE_REF\t");
248 this.text.append ("ALIGNMENT");
249 this.text.append (this.newline);
252 if (refSeq == null || refSeq !== next_refSeq) {
253 this.text.append (this.newline);
254 this.text.append ("SEQUENCE_REF\t");
255 this.text.append (next_refSeq.getName ());
256 this.text.append (this.newline);
259 }, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");
260 Clazz.defineMethod (c$, "printGroups",
263 for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
264 if (!sg.hasSeqrep ()) {
265 this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t");
268 seqrep = sg.getSeqrep ();
269 this.text.append ("SEQUENCE_REF\t");
270 this.text.append (seqrep.getName ());
271 this.text.append (this.newline);
272 this.text.append ("SEQUENCE_GROUP\t");
273 this.text.append (sg.getName ());
274 this.text.append ("\t");
275 this.text.append ("" + (seqrep.findPosition (sg.getStartRes ())));
276 this.text.append ("\t");
277 this.text.append ((seqrep.findPosition (sg.getEndRes ())));
278 this.text.append ("\t");
279 this.text.append ("-1\t");
280 }for (var s = 0; s < sg.getSize (); s++) {
281 this.text.append (sg.getSequenceAt (s).getName ());
282 this.text.append ("\t");
284 this.text.append (this.newline);
285 this.text.append ("PROPERTIES\t");
286 this.text.append (sg.getName ());
287 this.text.append ("\t");
288 if (sg.getDescription () != null) {
289 this.text.append ("description=");
290 this.text.append (sg.getDescription ());
291 this.text.append ("\t");
292 }if (sg.cs != null) {
293 this.text.append ("colour=");
294 this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs));
295 this.text.append ("\t");
296 if (sg.cs.getThreshold () != 0) {
297 this.text.append ("pidThreshold=");
298 this.text.append (sg.cs.getThreshold ());
299 }if (sg.cs.conservationApplied ()) {
300 this.text.append ("consThreshold=");
301 this.text.append (sg.cs.getConservationInc ());
302 this.text.append ("\t");
303 }}this.text.append ("outlineColour=");
304 this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ()));
305 this.text.append ("\t");
306 this.text.append ("displayBoxes=");
307 this.text.append (sg.getDisplayBoxes ());
308 this.text.append ("\t");
309 this.text.append ("displayText=");
310 this.text.append (sg.getDisplayText ());
311 this.text.append ("\t");
312 this.text.append ("colourText=");
313 this.text.append (sg.getColourText ());
314 this.text.append ("\t");
315 this.text.append ("showUnconserved=");
316 this.text.append (sg.getShowNonconserved ());
317 this.text.append ("\t");
318 if (sg.textColour !== java.awt.Color.black) {
319 this.text.append ("textCol1=");
320 this.text.append (jalview.util.Format.getHexString (sg.textColour));
321 this.text.append ("\t");
322 }if (sg.textColour2 !== java.awt.Color.white) {
323 this.text.append ("textCol2=");
324 this.text.append (jalview.util.Format.getHexString (sg.textColour2));
325 this.text.append ("\t");
326 }if (sg.thresholdTextColour != 0) {
327 this.text.append ("textColThreshold=");
328 this.text.append (sg.thresholdTextColour);
329 this.text.append ("\t");
330 }if (sg.idColour != null) {
331 this.text.append ("idColour=");
332 this.text.append (jalview.util.Format.getHexString (sg.idColour));
333 this.text.append ("\t");
334 }if (sg.isHidereps ()) {
335 this.text.append ("hide=true\t");
336 }if (sg.isHideCols ()) {
337 this.text.append ("hidecols=true\t");
338 }if (seqrep != null) {
339 this.text.append (this.newline);
340 this.text.append ("SEQUENCE_REF");
341 }this.text.append (this.newline);
342 this.text.append (this.newline);
344 }, "java.util.List");
345 Clazz.defineMethod (c$, "annotateAlignmentView",
346 function (viewport, file, protocol) {
347 var colSel = viewport.getColumnSelection ();
348 if (colSel == null) {
349 colSel = new jalview.datamodel.ColumnSelection ();
350 }var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol);
351 if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) {
352 viewport.setColumnSelection (colSel);
354 }, "jalview.api.AlignViewportI,~S,~S");
355 Clazz.defineMethod (c$, "readAnnotationFile",
356 function (al, file, protocol) {
357 return this.readAnnotationFile (al, null, file, protocol);
358 }, "jalview.datamodel.AlignmentI,~S,~S");
359 Clazz.defineMethod (c$, "readAnnotationFile",
360 function (al, colSel, file, protocol) {
363 if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) {
364 $in = jalview.jsdev.GenericFileAdapter.getReader (file, false);
365 } else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) {
366 $in = jalview.jsdev.GenericFileAdapter.getReader (file, true);
367 } else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) {
368 $in = new java.io.BufferedReader ( new java.io.StringReader (file));
369 } else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {
370 var is = this.getClass ().getResourceAsStream ("/" + file);
372 $in = new java.io.BufferedReader ( new java.io.InputStreamReader (is));
374 return this.parseAnnotationFrom (al, colSel, $in);
376 if (Clazz.exceptionOf (ex, Exception)) {
377 ex.printStackTrace ();
378 System.out.println ("Problem reading annotation file: " + ex);
379 if (this.nlinesread > 0) {
380 System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ...");
387 }, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S");
388 Clazz.defineMethod (c$, "parseAnnotationFrom",
389 function (al, colSel, $in) {
391 var combineAnnotation_calls = new java.util.ArrayList ();
392 var deferredAnnotation_calls = new java.util.ArrayList ();
393 var modified = false;
395 var groupRefRows = new java.util.Hashtable ();
396 var autoAnnots = new java.util.Hashtable ();
405 var existingAnnotations = 0;
406 var overrideAutoAnnot = false;
407 if (al.getAlignmentAnnotation () != null) {
408 existingAnnotations = al.getAlignmentAnnotation ().length;
409 if (existingAnnotations > 0) {
410 var aa = al.getAlignmentAnnotation ();
411 for (var aai = 0; aai < aa.length; aai++) {
412 if (aa[aai].autoCalculated) {
413 autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())), new Integer (1));
415 }}var alWidth = al.getWidth ();
418 var annotation = null;
419 var jvAnnotationFile = false;
420 while ((line = $in.readLine ()) != null) {
422 this.lastread = String.instantialize (line);
423 if (line.indexOf ("#") == 0) {
425 }if (line.indexOf ("JALVIEW_ANNOTATION") > -1) {
426 jvAnnotationFile = true;
429 if (!jvAnnotationFile) {
432 }while ((line = $in.readLine ()) != null) {
434 this.lastread = String.instantialize (line);
435 if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) {
437 }st = new java.util.StringTokenizer (line, "\t");
438 token = st.nextToken ();
439 if (token.equalsIgnoreCase ("COLOUR")) {
440 this.colourAnnotations (al, st.nextToken (), st.nextToken ());
443 } else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) {
444 combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef]));
447 } else if (token.equalsIgnoreCase ("ROWPROPERTIES")) {
448 this.addRowProperties (al, st);
451 } else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) {
452 deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef]));
455 } else if (token.equalsIgnoreCase ("SEQUENCE_REF")) {
456 if (st.hasMoreTokens ()) {
457 this.refSeq = al.findName (this.refSeqId = st.nextToken ());
458 if (this.refSeq == null) {
459 this.refSeqId = null;
461 refSeqIndex = Integer.parseInt (st.nextToken ());
462 if (refSeqIndex < 1) {
464 System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");
466 if (Clazz.exceptionOf (ex, Exception)) {
474 this.refSeqId = null;
476 } else if (token.equalsIgnoreCase ("GROUP_REF")) {
478 if (st.hasMoreTokens ()) {
479 groupRef = st.nextToken ();
480 if (groupRef.length < 1) {
483 if (groupRefRows.get (groupRef) == null) {
484 groupRefRows.put (groupRef, new java.util.Vector ());
486 } else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) {
487 this.addGroup (al, st);
490 } else if (token.equalsIgnoreCase ("PROPERTIES")) {
491 this.addProperties (al, st);
494 } else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) {
495 this.setBelowAlignment (al, st);
498 } else if (token.equalsIgnoreCase ("ALIGNMENT")) {
499 this.addAlignmentDetails (al, st);
502 } else if (token.equalsIgnoreCase ("VIEW_SETREF")) {
503 if (this.refSeq != null) {
504 al.setSeqrep (this.refSeq);
507 } else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) {
508 if (st.hasMoreTokens ()) {
509 if (colSel == null) {
510 colSel = new jalview.datamodel.ColumnSelection ();
511 }this.parseHideCols (colSel, st.nextToken ());
514 } else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) {
515 var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq;
517 sr = al.getSequenceAt (0);
519 if (colSel == null) {
520 System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line);
522 colSel.hideInsertionsFor (sr);
525 }graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token);
526 label = st.nextToken ();
528 annotations = new Array (alWidth);
531 if (st.hasMoreTokens ()) {
532 line = st.nextToken ();
533 if (line.indexOf ("|") == -1) {
535 if (st.hasMoreTokens ()) {
536 line = st.nextToken ();
537 }}if (st.hasMoreTokens ()) {
538 score = Float.$valueOf (st.nextToken ()).floatValue ();
539 }st = new java.util.StringTokenizer (line, "|", true);
540 var emptyColumn = true;
541 var onlyOneElement = (st.countTokens () == 1);
542 while (st.hasMoreElements () && index < alWidth) {
543 token = st.nextToken ().trim ();
544 if (onlyOneElement) {
546 score = Float.$valueOf (token).floatValue ();
549 if (Clazz.exceptionOf (ex, NumberFormatException)) {
554 }if (token.equals ("|")) {
559 annotations[index++] = this.parseAnnotation (token, graphStyle);
562 }annotation = new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle);
563 annotation.score = score;
564 if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) {
566 }if (this.refSeq != null) {
567 annotation.belowAlignment = false;
568 var referedSeq = this.refSeq;
570 var ann = new jalview.datamodel.AlignmentAnnotation (annotation);
571 annotation.createSequenceMapping (referedSeq, refSeqIndex, false);
572 annotation.adjustForAlignment ();
573 referedSeq.addAlignmentAnnotation (annotation);
574 al.addAnnotation (annotation);
575 al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);
576 if (groupRef != null) {
577 (groupRefRows.get (groupRef)).addElement (annotation);
579 } while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null);
581 al.addAnnotation (annotation);
582 al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);
583 if (groupRef != null) {
584 (groupRefRows.get (groupRef)).addElement (annotation);
587 var groupRefLookup = new java.util.Hashtable ();
588 var en = groupRefRows.keys ();
589 while (en.hasMoreElements ()) {
590 groupRef = en.nextElement ();
592 for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) {
593 if (theGroup.getName ().equals (groupRef)) {
595 System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'");
598 var rowset = groupRefRows.get (groupRef);
599 groupRefLookup.put (groupRef, theGroup);
600 if (rowset != null && rowset.size () > 0) {
602 for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) {
603 alan = rowset.elementAt (elm);
604 alan.groupRef = theGroup;
607 (groupRefRows.get (groupRef)).removeAllElements ();
609 for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) {
610 if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) {
611 this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3]));
613 var combinecount = 0;
614 for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) {
615 this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2]));
618 }, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader");
619 Clazz.defineMethod (c$, "parseHideCols",
620 ($fz = function (colSel, nextToken) {
621 var inval = new java.util.StringTokenizer (nextToken, ",");
622 while (inval.hasMoreTokens ()) {
623 var range = inval.nextToken ().trim ();
625 var to = range.indexOf ("-");
627 from = to = Integer.parseInt (range);
629 colSel.hideColumns (from, to);
631 from = Integer.parseInt (range.substring (0, to));
632 if (to < range.length - 1) {
633 to = Integer.parseInt (range.substring (to + 1));
636 }if (from > 0 && to >= from) {
637 colSel.hideColumns (from, to);
639 }, $fz.isPrivate = true, $fz), "jalview.datamodel.ColumnSelection,~S");
640 Clazz.defineMethod (c$, "autoAnnotsKey",
641 ($fz = function (annotation, refSeq, groupRef) {
642 return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : "");
643 }, $fz.isPrivate = true, $fz), "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S");
644 Clazz.defineMethod (c$, "parseAnnotation",
645 function (string, graphStyle) {
646 var hasSymbols = (graphStyle == 0);
648 var displayChar = null;
651 var parsedValue = false;
654 var i = string.indexOf ("[");
655 var j = string.indexOf ("]");
656 if (i > -1 && j > -1) {
657 var ucs = new jalview.schemes.UserColourScheme ();
658 colour = ucs.getColourFromString (string.substring (i + 1, j));
659 if (i > 0 && string.charAt (i - 1) == ',') {
661 }string = string.substring (0, i) + string.substring (j + 1);
662 }var st = new java.util.StringTokenizer (string, ",", true);
664 var seenContent = false;
666 while (st.hasMoreTokens ()) {
668 token = st.nextToken ().trim ();
669 if (token.equals (",")) {
670 if (!seenContent && parsedValue && !dcset) {
673 }seenContent = false;
680 value = new Float (token).floatValue ();
684 if (Clazz.exceptionOf (ex, NumberFormatException)) {
690 if (token.length == 1) {
692 }}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) {
693 ss = token.charAt (0);
694 if (displayChar.equals (token.substring (0, 1))) {
696 }} else if (desc == null || (parsedValue && pass > 2)) {
699 if (displayChar != null && desc != null && desc.length == 1) {
700 if (displayChar.length > 1) {
701 var tmp = displayChar;
705 if (displayChar.equals (desc)) {
707 }}}var anot = new jalview.datamodel.Annotation (displayChar, desc, ss, value);
708 anot.colour = colour;
711 Clazz.defineMethod (c$, "colourAnnotations",
712 function (al, label, colour) {
713 var ucs = new jalview.schemes.UserColourScheme (colour);
715 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
716 if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) {
717 annotations = al.getAlignmentAnnotation ()[i].annotations;
718 for (var j = 0; j < annotations.length; j++) {
719 if (annotations[j] != null) {
720 annotations[j].colour = ucs.findColour ('A');
723 }, "jalview.datamodel.AlignmentI,~S,~S");
724 Clazz.defineMethod (c$, "combineAnnotations",
725 function (al, combineCount, st, seqRef, groupRef) {
726 var group = st.nextToken ();
728 if (al.getAlignmentAnnotation () != null) {
729 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
730 var aa = al.getAlignmentAnnotation ()[i];
731 if (aa.graphGroup > graphGroup) {
732 graphGroup = aa.graphGroup + 1;
733 }if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {
734 if (aa.graphGroup > -1) {
735 graphGroup = aa.graphGroup;
737 if (graphGroup <= combineCount) {
738 graphGroup = combineCount + 1;
739 }aa.graphGroup = graphGroup;
742 while (st.hasMoreTokens ()) {
743 group = st.nextToken ();
744 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
745 var aa = al.getAlignmentAnnotation ()[i];
746 if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {
747 aa.graphGroup = graphGroup;
752 System.err.println ("Couldn't combine annotations. None are added to alignment yet!");
753 }}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");
754 Clazz.defineMethod (c$, "addLine",
755 function (al, st, seqRef, groupRef) {
756 var group = st.nextToken ();
757 var annotation = null;
758 var alannot = al.getAlignmentAnnotation ();
759 var value = new Float (st.nextToken ()).floatValue ();
760 var label = st.hasMoreTokens () ? st.nextToken () : null;
762 if (st.hasMoreTokens ()) {
763 var ucs = new jalview.schemes.UserColourScheme (st.nextToken ());
764 colour = ucs.findColour ('A');
765 }if (alannot != null) {
766 for (var i = 0; i < alannot.length; i++) {
767 if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) {
768 alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour));
770 }if (annotation == null) {
772 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");
773 Clazz.defineMethod (c$, "addGroup",
775 var sg = new jalview.datamodel.SequenceGroup ();
776 sg.setName (st.nextToken ());
779 rng = st.nextToken ();
780 if (rng.length > 0 && !rng.startsWith ("*")) {
781 sg.setStartRes (Integer.parseInt (rng) - 1);
784 }rng = st.nextToken ();
785 if (rng.length > 0 && !rng.startsWith ("*")) {
786 sg.setEndRes (Integer.parseInt (rng) - 1);
788 sg.setEndRes (al.getWidth () - 1);
790 if (Clazz.exceptionOf (e, Exception)) {
791 System.err.println ("Couldn't parse Group Start or End Field as '*' or a valid column or sequence index: '" + rng + "' - assuming alignment width for group.");
793 sg.setEndRes (al.getWidth () - 1);
798 var index = st.nextToken ();
799 if (index.equals ("-1")) {
800 while (st.hasMoreElements ()) {
801 sg.addSequence (al.findName (st.nextToken ()), false);
804 var st2 = new java.util.StringTokenizer (index, ",");
805 while (st2.hasMoreTokens ()) {
806 var tmp = st2.nextToken ();
807 if (tmp.equals ("*")) {
808 for (var i = 0; i < al.getHeight (); i++) {
809 sg.addSequence (al.getSequenceAt (i), false);
811 } else if (tmp.indexOf ("-") >= 0) {
812 var st3 = new java.util.StringTokenizer (tmp, "-");
813 var start = (Integer.parseInt (st3.nextToken ()));
814 var end = (Integer.parseInt (st3.nextToken ()));
816 for (var i = start; i <= end; i++) {
817 sg.addSequence (al.getSequenceAt (i - 1), false);
820 sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false);
822 }if (this.refSeq != null) {
823 sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1);
824 sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1);
825 sg.setSeqrep (this.refSeq);
826 }if (sg.getSize () > 0) {
828 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
829 Clazz.defineMethod (c$, "addRowProperties",
831 var label = st.nextToken ();
835 var scaletofit = false;
836 var centerlab = false;
837 var showalllabs = false;
838 while (st.hasMoreTokens ()) {
839 keyValue = st.nextToken ();
840 key = keyValue.substring (0, keyValue.indexOf ("="));
841 value = keyValue.substring (keyValue.indexOf ("=") + 1);
842 if (key.equalsIgnoreCase ("scaletofit")) {
843 scaletofit = Boolean.$valueOf (value).booleanValue ();
844 }if (key.equalsIgnoreCase ("showalllabs")) {
845 showalllabs = Boolean.$valueOf (value).booleanValue ();
846 }if (key.equalsIgnoreCase ("centrelabs")) {
847 centerlab = Boolean.$valueOf (value).booleanValue ();
848 }var alr = al.getAlignmentAnnotation ();
850 for (var i = 0; i < alr.length; i++) {
851 if (alr[i].label.equalsIgnoreCase (label)) {
852 alr[i].centreColLabels = centerlab;
853 alr[i].scaleColLabel = scaletofit;
854 alr[i].showAllColLabels = showalllabs;
857 }, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
858 Clazz.defineMethod (c$, "addProperties",
860 if (al.getGroups () == null) {
862 }var name = st.nextToken ();
864 for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) {
865 if ((sg = _sg).getName ().equals (name)) {
876 while (st.hasMoreTokens ()) {
877 keyValue = st.nextToken ();
878 key = keyValue.substring (0, keyValue.indexOf ("="));
879 value = keyValue.substring (keyValue.indexOf ("=") + 1);
880 if (key.equalsIgnoreCase ("description")) {
881 sg.setDescription (value);
882 } else if (key.equalsIgnoreCase ("colour")) {
883 sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value);
884 } else if (key.equalsIgnoreCase ("pidThreshold")) {
885 sg.cs.setThreshold (Integer.parseInt (value), true);
886 } else if (key.equalsIgnoreCase ("consThreshold")) {
887 sg.cs.setConservationInc (Integer.parseInt (value));
888 var c = new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1);
890 c.verdict (false, 25);
891 sg.cs.setConservation (c);
892 } else if (key.equalsIgnoreCase ("outlineColour")) {
893 sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A'));
894 } else if (key.equalsIgnoreCase ("displayBoxes")) {
895 sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ());
896 } else if (key.equalsIgnoreCase ("showUnconserved")) {
897 sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ());
898 } else if (key.equalsIgnoreCase ("displayText")) {
899 sg.setDisplayText (Boolean.$valueOf (value).booleanValue ());
900 } else if (key.equalsIgnoreCase ("colourText")) {
901 sg.setColourText (Boolean.$valueOf (value).booleanValue ());
902 } else if (key.equalsIgnoreCase ("textCol1")) {
903 sg.textColour = new jalview.schemes.UserColourScheme (value).findColour ('A');
904 } else if (key.equalsIgnoreCase ("textCol2")) {
905 sg.textColour2 = new jalview.schemes.UserColourScheme (value).findColour ('A');
906 } else if (key.equalsIgnoreCase ("textColThreshold")) {
907 sg.thresholdTextColour = Integer.parseInt (value);
908 } else if (key.equalsIgnoreCase ("idColour")) {
909 sg.setIdColour ((def = new jalview.schemes.UserColourScheme (value)).findColour ('A'));
910 } else if (key.equalsIgnoreCase ("hide")) {
911 sg.setHidereps (true);
912 } else if (key.equalsIgnoreCase ("hidecols")) {
913 sg.setHideCols (true);
914 }sg.recalcConservation ();
918 }}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
919 Clazz.defineMethod (c$, "setBelowAlignment",
923 var ala = al.getAlignmentAnnotation ();
925 System.err.print ("Warning - no annotation to set below for sequence associated annotation:");
926 }while (st.hasMoreTokens ()) {
927 token = st.nextToken ();
929 System.err.print (" " + token);
931 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {
932 aa = al.getAlignmentAnnotation ()[i];
933 if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) {
934 aa.belowAlignment = true;
938 System.err.print ("\n");
939 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
940 Clazz.defineMethod (c$, "addAlignmentDetails",
945 while (st.hasMoreTokens ()) {
946 keyValue = st.nextToken ();
947 key = keyValue.substring (0, keyValue.indexOf ("="));
948 value = keyValue.substring (keyValue.indexOf ("=") + 1);
949 al.setProperty (key, value);
951 }, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");
952 Clazz.defineMethod (c$, "printCSVAnnotations",
953 function (annotations) {
954 var sp = new StringBuffer ();
955 for (var i = 0; i < annotations.length; i++) {
956 var atos = annotations[i].toString ();
959 var cp = atos.indexOf ("\n", p);
960 sp.append (annotations[i].label);
963 sp.append (atos.substring (p, cp + 1));
965 sp.append (atos.substring (p));
966 sp.append (this.newline);
970 return sp.toString ();
972 Clazz.defineMethod (c$, "printAnnotationsForView",
973 function (viewport) {
974 return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null);
975 }, "jalview.api.AlignViewportI");
976 Clazz.defineMethod (c$, "printAnnotationsForAlignment",
978 return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null);
979 }, "jalview.datamodel.AlignmentI");
980 c$.$AnnotationFile$ViewDef$ = function () {
982 c$ = Clazz.decorateAsClass (function () {
983 Clazz.prepareCallback (this, arguments);
984 this.viewname = null;
986 this.hiddencols = null;
987 this.visibleGroups = null;
988 this.hiddenRepSeqs = null;
989 Clazz.instantialize (this, arguments);
990 }, jalview.io.AnnotationFile, "ViewDef");
991 Clazz.makeConstructor (c$,
992 function (a, b, c, d) {
996 this.hiddenRepSeqs = d;
997 }, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable");
1000 Clazz.defineStatics (c$,
1001 "GRAPHLINE", "GRAPHLINE",
1002 "COMBINE", "COMBINE");