JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / jalview / io / AnnotationFile.js
1 Clazz.declarePackage ("jalview.io");\r
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 () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.newline = null;\r
5 this.text = null;\r
6 if (!Clazz.isClassDefined ("jalview.io.AnnotationFile.ViewDef")) {\r
7 jalview.io.AnnotationFile.$AnnotationFile$ViewDef$ ();\r
8 }\r
9 this.refSeq = null;\r
10 this.refSeqId = null;\r
11 this.nlinesread = 0;\r
12 this.lastread = "";\r
13 Clazz.instantialize (this, arguments);\r
14 }, jalview.io, "AnnotationFile");\r
15 Clazz.prepareFields (c$, function () {\r
16 this.newline = System.getProperty ("line.separator");\r
17 });\r
18 Clazz.makeConstructor (c$, \r
19 function () {\r
20 this.init ();\r
21 });\r
22 Clazz.defineMethod (c$, "setNewlineString", \r
23 function (nl) {\r
24 this.newline = nl;\r
25 this.init ();\r
26 }, "~S");\r
27 Clazz.defineMethod (c$, "getNewlineString", \r
28 function () {\r
29 return this.newline;\r
30 });\r
31 Clazz.defineMethod (c$, "init", \r
32  function () {\r
33 this.text =  new StringBuffer ("JALVIEW_ANNOTATION" + this.newline + "# Created: " +  new java.util.Date () + this.newline + this.newline);\r
34 this.refSeq = null;\r
35 this.refSeqId = null;\r
36 });\r
37 Clazz.defineMethod (c$, "printAnnotations", \r
38 function (annotations, list, properties) {\r
39 return this.printAnnotations (annotations, list, properties, null, null, null);\r
40 }, "~A,java.util.List,java.util.Hashtable");\r
41 Clazz.defineMethod (c$, "printAnnotations", \r
42 function (annotations, list, properties, cs, al, view) {\r
43 if (view != null) {\r
44 if (view.viewname != null) {\r
45 this.text.append ("VIEW_DEF\t" + view.viewname + "\n");\r
46 }if (list == null) {\r
47 list = view.visibleGroups;\r
48 }if (cs == null) {\r
49 cs = view.hiddencols;\r
50 }if (al == null) {\r
51 }}if (al != null && al.hasSeqrep ()) {\r
52 this.text.append ("VIEW_SETREF\t" + al.getSeqrep ().getName () + "\n");\r
53 }if (cs != null && cs.hasHiddenColumns ()) {\r
54 this.text.append ("VIEW_HIDECOLS\t");\r
55 var hc = cs.getHiddenColumns ();\r
56 var comma = false;\r
57 for (var r, $r = hc.iterator (); $r.hasNext () && ((r = $r.next ()) || true);) {\r
58 if (!comma) {\r
59 comma = true;\r
60 } else {\r
61 this.text.append (",");\r
62 }this.text.append (r[0]);\r
63 this.text.append ("-");\r
64 this.text.append (r[1]);\r
65 }\r
66 this.text.append ("\n");\r
67 }if (annotations != null) {\r
68 var oneColour = true;\r
69 var row;\r
70 var comma;\r
71 var refSeq = null;\r
72 var refGroup = null;\r
73 var colours =  new StringBuffer ();\r
74 var graphLine =  new StringBuffer ();\r
75 var rowprops =  new StringBuffer ();\r
76 var graphGroup =  new java.util.Hashtable ();\r
77 var graphGroup_refs =  new java.util.Hashtable ();\r
78 var graphGroupSeen =  new java.util.BitSet ();\r
79 var color;\r
80 for (var i = 0; i < annotations.length; i++) {\r
81 row = annotations[i];\r
82 if (!row.visible && !row.hasScore () && !(row.graphGroup > -1 && graphGroupSeen.get (row.graphGroup))) {\r
83 continue;\r
84 }color = null;\r
85 oneColour = true;\r
86 this.writeSequence_Ref (refSeq, row.sequenceRef);\r
87 refSeq = row.sequenceRef;\r
88 this.writeGroup_Ref (refGroup, row.groupRef);\r
89 refGroup = row.groupRef;\r
90 var hasGlyphs = row.hasIcons;\r
91 var hasLabels = row.hasText;\r
92 var hasValues = row.$hasScore;\r
93 var hasText = false;\r
94 for (var j = 0; row.annotations != null && j < row.annotations.length && (!hasGlyphs || !hasLabels || !hasValues); j++) {\r
95 if (row.annotations[j] != null) {\r
96 hasLabels = new Boolean (hasLabels | (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" "))).valueOf ();\r
97 hasGlyphs = new Boolean (hasGlyphs | ((row.annotations[j].secondaryStructure).charCodeAt (0) != 0 && row.annotations[j].secondaryStructure != ' ')).valueOf ();\r
98 hasValues = new Boolean (hasValues | (!Float.isNaN (row.annotations[j].value))).valueOf ();\r
99 hasText = new Boolean (hasText | (row.annotations[j].description != null && row.annotations[j].description.length > 0)).valueOf ();\r
100 }}\r
101 if (row.graph == 0) {\r
102 this.text.append ("NO_GRAPH\t");\r
103 hasValues = false;\r
104 } else {\r
105 if (row.graph == 1) {\r
106 this.text.append ("BAR_GRAPH\t");\r
107 hasGlyphs = false;\r
108 } else if (row.graph == 2) {\r
109 hasGlyphs = false;\r
110 this.text.append ("LINE_GRAPH\t");\r
111 }if (row.getThreshold () != null) {\r
112 graphLine.append ("GRAPHLINE\t");\r
113 graphLine.append (row.label);\r
114 graphLine.append ("\t");\r
115 graphLine.append (row.getThreshold ().value);\r
116 graphLine.append ("\t");\r
117 graphLine.append (row.getThreshold ().label);\r
118 graphLine.append ("\t");\r
119 graphLine.append (jalview.util.Format.getHexString (row.getThreshold ().colour));\r
120 graphLine.append (this.newline);\r
121 }if (row.graphGroup > -1) {\r
122 graphGroupSeen.set (row.graphGroup);\r
123 var key =  new Integer (row.graphGroup);\r
124 if (graphGroup.containsKey (key)) {\r
125 graphGroup.put (key, graphGroup.get (key) + "\t" + row.label);\r
126 } else {\r
127 graphGroup_refs.put (key,  Clazz.newArray (-1, [refSeq, refGroup]));\r
128 graphGroup.put (key, row.label);\r
129 }}}this.text.append (row.label + "\t");\r
130 if (row.description != null) {\r
131 this.text.append (row.description + "\t");\r
132 }for (var j = 0; row.annotations != null && j < row.annotations.length; j++) {\r
133 if (refSeq != null && jalview.util.Comparison.isGap (refSeq.getCharAt (j))) {\r
134 continue;\r
135 }if (row.annotations[j] != null) {\r
136 comma = "";\r
137 if (hasGlyphs) {\r
138 this.text.append (comma);\r
139 if (row.annotations[j].secondaryStructure != ' ') {\r
140 this.text.append (row.annotations[j].secondaryStructure);\r
141 }comma = ",";\r
142 }if (hasValues) {\r
143 if (!Float.isNaN (row.annotations[j].value)) {\r
144 this.text.append (comma + row.annotations[j].value);\r
145 } else {\r
146 System.err.println ("Skipping NaN - not valid value.");\r
147 this.text.append (comma + 0);\r
148 }comma = ",";\r
149 }if (hasLabels) {\r
150 if (row.annotations[j].displayCharacter != null && row.annotations[j].displayCharacter.length > 0 && !row.annotations[j].displayCharacter.equals (" ")) {\r
151 this.text.append (comma + row.annotations[j].displayCharacter);\r
152 comma = ",";\r
153 }}if (hasText) {\r
154 if (row.annotations[j].description != null && row.annotations[j].description.length > 0 && !row.annotations[j].description.equals (row.annotations[j].displayCharacter)) {\r
155 this.text.append (comma + row.annotations[j].description);\r
156 comma = ",";\r
157 }}if (color != null && !color.equals (row.annotations[j].colour)) {\r
158 oneColour = false;\r
159 }color = row.annotations[j].colour;\r
160 if (row.annotations[j].colour != null && row.annotations[j].colour !== java.awt.Color.black) {\r
161 this.text.append (comma + "[" + jalview.util.Format.getHexString (row.annotations[j].colour) + "]");\r
162 comma = ",";\r
163 }}this.text.append ("|");\r
164 }\r
165 if (row.hasScore ()) {\r
166 this.text.append ("\t" + row.score);\r
167 }this.text.append (this.newline);\r
168 if (color != null && color !== java.awt.Color.black && oneColour) {\r
169 colours.append ("COLOUR\t");\r
170 colours.append (row.label);\r
171 colours.append ("\t");\r
172 colours.append (jalview.util.Format.getHexString (color));\r
173 colours.append (this.newline);\r
174 }if (row.scaleColLabel || row.showAllColLabels || row.centreColLabels) {\r
175 rowprops.append ("ROWPROPERTIES\t");\r
176 rowprops.append (row.label);\r
177 rowprops.append ("\tscaletofit=");\r
178 rowprops.append (row.scaleColLabel);\r
179 rowprops.append ("\tshowalllabs=");\r
180 rowprops.append (row.showAllColLabels);\r
181 rowprops.append ("\tcentrelabs=");\r
182 rowprops.append (row.centreColLabels);\r
183 rowprops.append (this.newline);\r
184 }if (graphLine.length () > 0) {\r
185 this.text.append (graphLine.toString ());\r
186 graphLine.setLength (0);\r
187 }}\r
188 this.text.append (this.newline);\r
189 this.text.append (colours.toString ());\r
190 if (graphGroup.size () > 0) {\r
191 var oldRefSeq = refSeq;\r
192 var oldRefGroup = refGroup;\r
193 for (var combine_statement, $combine_statement = graphGroup.entrySet ().iterator (); $combine_statement.hasNext () && ((combine_statement = $combine_statement.next ()) || true);) {\r
194 var seqRefAndGroup = graphGroup_refs.get (combine_statement.getKey ());\r
195 this.writeSequence_Ref (refSeq, seqRefAndGroup[0]);\r
196 refSeq = seqRefAndGroup[0];\r
197 this.writeGroup_Ref (refGroup, seqRefAndGroup[1]);\r
198 refGroup = seqRefAndGroup[1];\r
199 this.text.append ("COMBINE\t");\r
200 this.text.append (combine_statement.getValue ());\r
201 this.text.append (this.newline);\r
202 }\r
203 this.writeSequence_Ref (refSeq, oldRefSeq);\r
204 refSeq = oldRefSeq;\r
205 this.writeGroup_Ref (refGroup, oldRefGroup);\r
206 refGroup = oldRefGroup;\r
207 }this.text.append (rowprops.toString ());\r
208 }if (list != null) {\r
209 this.printGroups (list);\r
210 }if (properties != null) {\r
211 this.text.append (this.newline);\r
212 this.text.append (this.newline);\r
213 this.text.append ("ALIGNMENT");\r
214 var en = properties.keys ();\r
215 while (en.hasMoreElements ()) {\r
216 var key = en.nextElement ().toString ();\r
217 this.text.append ("\t");\r
218 this.text.append (key);\r
219 this.text.append ("=");\r
220 this.text.append (properties.get (key));\r
221 }\r
222 }return this.text.toString ();\r
223 }, "~A,java.util.List,java.util.Hashtable,jalview.datamodel.ColumnSelection,jalview.datamodel.AlignmentI,jalview.io.AnnotationFile.ViewDef");\r
224 Clazz.defineMethod (c$, "writeGroup_Ref", \r
225  function (refGroup, next_refGroup) {\r
226 if (next_refGroup == null) {\r
227 if (refGroup != null) {\r
228 this.text.append (this.newline);\r
229 this.text.append ("GROUP_REF\t");\r
230 this.text.append ("ALIGNMENT");\r
231 this.text.append (this.newline);\r
232 }return true;\r
233 } else {\r
234 if (refGroup == null || refGroup !== next_refGroup) {\r
235 this.text.append (this.newline);\r
236 this.text.append ("GROUP_REF\t");\r
237 this.text.append (next_refGroup.getName ());\r
238 this.text.append (this.newline);\r
239 return true;\r
240 }}return false;\r
241 }, "jalview.datamodel.SequenceGroup,jalview.datamodel.SequenceGroup");\r
242 Clazz.defineMethod (c$, "writeSequence_Ref", \r
243  function (refSeq, next_refSeq) {\r
244 if (next_refSeq == null) {\r
245 if (refSeq != null) {\r
246 this.text.append (this.newline);\r
247 this.text.append ("SEQUENCE_REF\t");\r
248 this.text.append ("ALIGNMENT");\r
249 this.text.append (this.newline);\r
250 return true;\r
251 }} else {\r
252 if (refSeq == null || refSeq !== next_refSeq) {\r
253 this.text.append (this.newline);\r
254 this.text.append ("SEQUENCE_REF\t");\r
255 this.text.append (next_refSeq.getName ());\r
256 this.text.append (this.newline);\r
257 return true;\r
258 }}return false;\r
259 }, "jalview.datamodel.SequenceI,jalview.datamodel.SequenceI");\r
260 Clazz.defineMethod (c$, "printGroups", \r
261 function (list) {\r
262 var seqrep = null;\r
263 for (var sg, $sg = list.iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {\r
264 if (!sg.hasSeqrep ()) {\r
265 this.text.append ("SEQUENCE_GROUP\t" + sg.getName () + "\t" + (sg.getStartRes () + 1) + "\t" + (sg.getEndRes () + 1) + "\t" + "-1\t");\r
266 seqrep = null;\r
267 } else {\r
268 seqrep = sg.getSeqrep ();\r
269 this.text.append ("SEQUENCE_REF\t");\r
270 this.text.append (seqrep.getName ());\r
271 this.text.append (this.newline);\r
272 this.text.append ("SEQUENCE_GROUP\t");\r
273 this.text.append (sg.getName ());\r
274 this.text.append ("\t");\r
275 this.text.append ((seqrep.findPosition (sg.getStartRes ())));\r
276 this.text.append ("\t");\r
277 this.text.append ((seqrep.findPosition (sg.getEndRes ())));\r
278 this.text.append ("\t");\r
279 this.text.append ("-1\t");\r
280 }for (var s = 0; s < sg.getSize (); s++) {\r
281 this.text.append (sg.getSequenceAt (s).getName ());\r
282 this.text.append ("\t");\r
283 }\r
284 this.text.append (this.newline);\r
285 this.text.append ("PROPERTIES\t");\r
286 this.text.append (sg.getName ());\r
287 this.text.append ("\t");\r
288 if (sg.getDescription () != null) {\r
289 this.text.append ("description=");\r
290 this.text.append (sg.getDescription ());\r
291 this.text.append ("\t");\r
292 }if (sg.cs != null) {\r
293 this.text.append ("colour=");\r
294 this.text.append (jalview.schemes.ColourSchemeProperty.getColourName (sg.cs));\r
295 this.text.append ("\t");\r
296 if (sg.cs.getThreshold () != 0) {\r
297 this.text.append ("pidThreshold=");\r
298 this.text.append (sg.cs.getThreshold ());\r
299 }if (sg.cs.conservationApplied ()) {\r
300 this.text.append ("consThreshold=");\r
301 this.text.append (sg.cs.getConservationInc ());\r
302 this.text.append ("\t");\r
303 }}this.text.append ("outlineColour=");\r
304 this.text.append (jalview.util.Format.getHexString (sg.getOutlineColour ()));\r
305 this.text.append ("\t");\r
306 this.text.append ("displayBoxes=");\r
307 this.text.append (sg.getDisplayBoxes ());\r
308 this.text.append ("\t");\r
309 this.text.append ("displayText=");\r
310 this.text.append (sg.getDisplayText ());\r
311 this.text.append ("\t");\r
312 this.text.append ("colourText=");\r
313 this.text.append (sg.getColourText ());\r
314 this.text.append ("\t");\r
315 this.text.append ("showUnconserved=");\r
316 this.text.append (sg.getShowNonconserved ());\r
317 this.text.append ("\t");\r
318 if (sg.textColour !== java.awt.Color.black) {\r
319 this.text.append ("textCol1=");\r
320 this.text.append (jalview.util.Format.getHexString (sg.textColour));\r
321 this.text.append ("\t");\r
322 }if (sg.textColour2 !== java.awt.Color.white) {\r
323 this.text.append ("textCol2=");\r
324 this.text.append (jalview.util.Format.getHexString (sg.textColour2));\r
325 this.text.append ("\t");\r
326 }if (sg.thresholdTextColour != 0) {\r
327 this.text.append ("textColThreshold=");\r
328 this.text.append (sg.thresholdTextColour);\r
329 this.text.append ("\t");\r
330 }if (sg.idColour != null) {\r
331 this.text.append ("idColour=");\r
332 this.text.append (jalview.util.Format.getHexString (sg.idColour));\r
333 this.text.append ("\t");\r
334 }if (sg.isHidereps ()) {\r
335 this.text.append ("hide=true\t");\r
336 }if (sg.isHideCols ()) {\r
337 this.text.append ("hidecols=true\t");\r
338 }if (seqrep != null) {\r
339 this.text.append (this.newline);\r
340 this.text.append ("SEQUENCE_REF");\r
341 }this.text.append (this.newline);\r
342 this.text.append (this.newline);\r
343 }\r
344 }, "java.util.List");\r
345 Clazz.defineMethod (c$, "annotateAlignmentView", \r
346 function (viewport, file, protocol) {\r
347 var colSel = viewport.getColumnSelection ();\r
348 if (colSel == null) {\r
349 colSel =  new jalview.datamodel.ColumnSelection ();\r
350 }var rslt = this.readAnnotationFile (viewport.getAlignment (), colSel, file, protocol);\r
351 if (rslt && (colSel.hasSelectedColumns () || colSel.hasHiddenColumns ())) {\r
352 viewport.setColumnSelection (colSel);\r
353 }return rslt;\r
354 }, "jalview.api.AlignViewportI,~S,~S");\r
355 Clazz.defineMethod (c$, "readAnnotationFile", \r
356 function (al, file, protocol) {\r
357 return this.readAnnotationFile (al, null, file, protocol);\r
358 }, "jalview.datamodel.AlignmentI,~S,~S");\r
359 Clazz.defineMethod (c$, "readAnnotationFile", \r
360 function (al, colSel, file, protocol) {\r
361 var $in = null;\r
362 try {\r
363 if (protocol.equals (jalview.io.AppletFormatAdapter.FILE)) {\r
364 $in = jalview.jsdev.GenericFileAdapter.getReader (file, false);\r
365 } else if (protocol.equals (jalview.io.AppletFormatAdapter.URL)) {\r
366 $in = jalview.jsdev.GenericFileAdapter.getReader (file, true);\r
367 } else if (protocol.equals (jalview.io.AppletFormatAdapter.PASTE)) {\r
368 $in =  new java.io.BufferedReader ( new java.io.StringReader (file));\r
369 } else if (protocol.equals (jalview.io.AppletFormatAdapter.CLASSLOADER)) {\r
370 var is = this.getClass ().getResourceAsStream ("/" + file);\r
371 if (is != null) {\r
372 $in =  new java.io.BufferedReader ( new java.io.InputStreamReader (is));\r
373 }}if ($in != null) {\r
374 return this.parseAnnotationFrom (al, colSel, $in);\r
375 }} catch (ex) {\r
376 if (Clazz.exceptionOf (ex, Exception)) {\r
377 ex.printStackTrace ();\r
378 System.out.println ("Problem reading annotation file: " + ex);\r
379 if (this.nlinesread > 0) {\r
380 System.out.println ("Last read line " + this.nlinesread + ": '" + this.lastread + "' (first 80 chars) ...");\r
381 }return false;\r
382 } else {\r
383 throw ex;\r
384 }\r
385 }\r
386 return false;\r
387 }, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,~S,~S");\r
388 Clazz.defineMethod (c$, "parseAnnotationFrom", \r
389 function (al, colSel, $in) {\r
390 this.nlinesread = 0;\r
391 var combineAnnotation_calls =  new java.util.ArrayList ();\r
392 var deferredAnnotation_calls =  new java.util.ArrayList ();\r
393 var modified = false;\r
394 var groupRef = null;\r
395 var groupRefRows =  new java.util.Hashtable ();\r
396 var autoAnnots =  new java.util.Hashtable ();\r
397 {\r
398 var line;\r
399 var label;\r
400 var description;\r
401 var token;\r
402 var graphStyle;\r
403 var index;\r
404 var refSeqIndex = 1;\r
405 var existingAnnotations = 0;\r
406 var overrideAutoAnnot = false;\r
407 if (al.getAlignmentAnnotation () != null) {\r
408 existingAnnotations = al.getAlignmentAnnotation ().length;\r
409 if (existingAnnotations > 0) {\r
410 var aa = al.getAlignmentAnnotation ();\r
411 for (var aai = 0; aai < aa.length; aai++) {\r
412 if (aa[aai].autoCalculated) {\r
413 autoAnnots.put (this.autoAnnotsKey (aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName ())),  new Integer (1));\r
414 }}\r
415 }}var alWidth = al.getWidth ();\r
416 var st;\r
417 var annotations;\r
418 var annotation = null;\r
419 var jvAnnotationFile = false;\r
420 while ((line = $in.readLine ()) != null) {\r
421 this.nlinesread++;\r
422 this.lastread =  String.instantialize (line);\r
423 if (line.indexOf ("#") == 0) {\r
424 continue;\r
425 }if (line.indexOf ("JALVIEW_ANNOTATION") > -1) {\r
426 jvAnnotationFile = true;\r
427 break;\r
428 }}\r
429 if (!jvAnnotationFile) {\r
430 $in.close ();\r
431 return false;\r
432 }while ((line = $in.readLine ()) != null) {\r
433 this.nlinesread++;\r
434 this.lastread =  String.instantialize (line);\r
435 if (line.indexOf ("#") == 0 || line.indexOf ("JALVIEW_ANNOTATION") > -1 || line.length == 0) {\r
436 continue;\r
437 }st =  new java.util.StringTokenizer (line, "\t");\r
438 token = st.nextToken ();\r
439 if (token.equalsIgnoreCase ("COLOUR")) {\r
440 this.colourAnnotations (al, st.nextToken (), st.nextToken ());\r
441 modified = true;\r
442 continue;\r
443 } else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.COMBINE)) {\r
444 combineAnnotation_calls.add ( Clazz.newArray (-1, [st, this.refSeq, groupRef]));\r
445 modified = true;\r
446 continue;\r
447 } else if (token.equalsIgnoreCase ("ROWPROPERTIES")) {\r
448 this.addRowProperties (al, st);\r
449 modified = true;\r
450 continue;\r
451 } else if (token.equalsIgnoreCase (jalview.io.AnnotationFile.GRAPHLINE)) {\r
452 deferredAnnotation_calls.add ( Clazz.newArray (-1, [jalview.io.AnnotationFile.GRAPHLINE, st, this.refSeq, groupRef]));\r
453 modified = true;\r
454 continue;\r
455 } else if (token.equalsIgnoreCase ("SEQUENCE_REF")) {\r
456 if (st.hasMoreTokens ()) {\r
457 this.refSeq = al.findName (this.refSeqId = st.nextToken ());\r
458 if (this.refSeq == null) {\r
459 this.refSeqId = null;\r
460 }try {\r
461 refSeqIndex = Integer.parseInt (st.nextToken ());\r
462 if (refSeqIndex < 1) {\r
463 refSeqIndex = 1;\r
464 System.out.println ("WARNING: SEQUENCE_REF index must be > 0 in AnnotationFile");\r
465 }} catch (ex) {\r
466 if (Clazz.exceptionOf (ex, Exception)) {\r
467 refSeqIndex = 1;\r
468 } else {\r
469 throw ex;\r
470 }\r
471 }\r
472 } else {\r
473 this.refSeq = null;\r
474 this.refSeqId = null;\r
475 }continue;\r
476 } else if (token.equalsIgnoreCase ("GROUP_REF")) {\r
477 groupRef = null;\r
478 if (st.hasMoreTokens ()) {\r
479 groupRef = st.nextToken ();\r
480 if (groupRef.length < 1) {\r
481 groupRef = null;\r
482 } else {\r
483 if (groupRefRows.get (groupRef) == null) {\r
484 groupRefRows.put (groupRef,  new java.util.Vector ());\r
485 }}}continue;\r
486 } else if (token.equalsIgnoreCase ("SEQUENCE_GROUP")) {\r
487 this.addGroup (al, st);\r
488 modified = true;\r
489 continue;\r
490 } else if (token.equalsIgnoreCase ("PROPERTIES")) {\r
491 this.addProperties (al, st);\r
492 modified = true;\r
493 continue;\r
494 } else if (token.equalsIgnoreCase ("BELOW_ALIGNMENT")) {\r
495 this.setBelowAlignment (al, st);\r
496 modified = true;\r
497 continue;\r
498 } else if (token.equalsIgnoreCase ("ALIGNMENT")) {\r
499 this.addAlignmentDetails (al, st);\r
500 modified = true;\r
501 continue;\r
502 } else if (token.equalsIgnoreCase ("VIEW_SETREF")) {\r
503 if (this.refSeq != null) {\r
504 al.setSeqrep (this.refSeq);\r
505 }modified = true;\r
506 continue;\r
507 } else if (token.equalsIgnoreCase ("VIEW_HIDECOLS")) {\r
508 if (st.hasMoreTokens ()) {\r
509 if (colSel == null) {\r
510 colSel =  new jalview.datamodel.ColumnSelection ();\r
511 }this.parseHideCols (colSel, st.nextToken ());\r
512 }modified = true;\r
513 continue;\r
514 } else if (token.equalsIgnoreCase ("HIDE_INSERTIONS")) {\r
515 var sr = this.refSeq == null ? al.getSeqrep () : this.refSeq;\r
516 if (sr == null) {\r
517 sr = al.getSequenceAt (0);\r
518 }if (sr != null) {\r
519 if (colSel == null) {\r
520 System.err.println ("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: " + line);\r
521 } else {\r
522 colSel.hideInsertionsFor (sr);\r
523 }}modified = true;\r
524 continue;\r
525 }graphStyle = jalview.datamodel.AlignmentAnnotation.getGraphValueFromString (token);\r
526 label = st.nextToken ();\r
527 index = 0;\r
528 annotations =  new Array (alWidth);\r
529 description = null;\r
530 var score = NaN;\r
531 if (st.hasMoreTokens ()) {\r
532 line = st.nextToken ();\r
533 if (line.indexOf ("|") == -1) {\r
534 description = line;\r
535 if (st.hasMoreTokens ()) {\r
536 line = st.nextToken ();\r
537 }}if (st.hasMoreTokens ()) {\r
538 score = Float.$valueOf (st.nextToken ()).floatValue ();\r
539 }st =  new java.util.StringTokenizer (line, "|", true);\r
540 var emptyColumn = true;\r
541 var onlyOneElement = (st.countTokens () == 1);\r
542 while (st.hasMoreElements () && index < alWidth) {\r
543 token = st.nextToken ().trim ();\r
544 if (onlyOneElement) {\r
545 try {\r
546 score = Float.$valueOf (token).floatValue ();\r
547 break;\r
548 } catch (ex) {\r
549 if (Clazz.exceptionOf (ex, NumberFormatException)) {\r
550 } else {\r
551 throw ex;\r
552 }\r
553 }\r
554 }if (token.equals ("|")) {\r
555 if (emptyColumn) {\r
556 index++;\r
557 }emptyColumn = true;\r
558 } else {\r
559 annotations[index++] = this.parseAnnotation (token, graphStyle);\r
560 emptyColumn = false;\r
561 }}\r
562 }annotation =  new jalview.datamodel.AlignmentAnnotation (label, description, (index == 0) ? null : annotations, 0, 0, graphStyle);\r
563 annotation.score = score;\r
564 if (!overrideAutoAnnot && autoAnnots.containsKey (this.autoAnnotsKey (annotation, this.refSeq, groupRef))) {\r
565 continue;\r
566 }if (this.refSeq != null) {\r
567 annotation.belowAlignment = false;\r
568 var referedSeq = this.refSeq;\r
569 do {\r
570 var ann =  new jalview.datamodel.AlignmentAnnotation (annotation);\r
571 annotation.createSequenceMapping (referedSeq, refSeqIndex, false);\r
572 annotation.adjustForAlignment ();\r
573 referedSeq.addAlignmentAnnotation (annotation);\r
574 al.addAnnotation (annotation);\r
575 al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);\r
576 if (groupRef != null) {\r
577 (groupRefRows.get (groupRef)).addElement (annotation);\r
578 }annotation = ann;\r
579 } while (this.refSeqId != null && (referedSeq = al.findName (referedSeq, this.refSeqId, true)) != null);\r
580 } else {\r
581 al.addAnnotation (annotation);\r
582 al.setAnnotationIndex (annotation, al.getAlignmentAnnotation ().length - existingAnnotations - 1);\r
583 if (groupRef != null) {\r
584 (groupRefRows.get (groupRef)).addElement (annotation);\r
585 }}modified = true;\r
586 }\r
587 var groupRefLookup =  new java.util.Hashtable ();\r
588 var en = groupRefRows.keys ();\r
589 while (en.hasMoreElements ()) {\r
590 groupRef = en.nextElement ();\r
591 var matched = false;\r
592 for (var theGroup, $theGroup = al.getGroups ().iterator (); $theGroup.hasNext () && ((theGroup = $theGroup.next ()) || true);) {\r
593 if (theGroup.getName ().equals (groupRef)) {\r
594 if (matched) {\r
595 System.err.println ("Ignoring 1:many group reference mappings for group name '" + groupRef + "'");\r
596 } else {\r
597 matched = true;\r
598 var rowset = groupRefRows.get (groupRef);\r
599 groupRefLookup.put (groupRef, theGroup);\r
600 if (rowset != null && rowset.size () > 0) {\r
601 var alan = null;\r
602 for (var elm = 0, elmSize = rowset.size (); elm < elmSize; elm++) {\r
603 alan = rowset.elementAt (elm);\r
604 alan.groupRef = theGroup;\r
605 }\r
606 }}}}\r
607 (groupRefRows.get (groupRef)).removeAllElements ();\r
608 }\r
609 for (var _deferred_args, $_deferred_args = deferredAnnotation_calls.iterator (); $_deferred_args.hasNext () && ((_deferred_args = $_deferred_args.next ()) || true);) {\r
610 if (_deferred_args[0] === jalview.io.AnnotationFile.GRAPHLINE) {\r
611 this.addLine (al, _deferred_args[1], _deferred_args[2], (_deferred_args[3] == null) ? null : groupRefLookup.get (_deferred_args[3]));\r
612 }}\r
613 var combinecount = 0;\r
614 for (var _combine_args, $_combine_args = combineAnnotation_calls.iterator (); $_combine_args.hasNext () && ((_combine_args = $_combine_args.next ()) || true);) {\r
615 this.combineAnnotations (al, ++combinecount, _combine_args[0], _combine_args[1], (_combine_args[2] == null) ? null : groupRefLookup.get (_combine_args[2]));\r
616 }\r
617 }return modified;\r
618 }, "jalview.datamodel.AlignmentI,jalview.datamodel.ColumnSelection,java.io.BufferedReader");\r
619 Clazz.defineMethod (c$, "parseHideCols", \r
620  function (colSel, nextToken) {\r
621 var inval =  new java.util.StringTokenizer (nextToken, ",");\r
622 while (inval.hasMoreTokens ()) {\r
623 var range = inval.nextToken ().trim ();\r
624 var from;\r
625 var to = range.indexOf ("-");\r
626 if (to == -1) {\r
627 from = to = Integer.parseInt (range);\r
628 if (from >= 0) {\r
629 colSel.hideColumns (from, to);\r
630 }} else {\r
631 from = Integer.parseInt (range.substring (0, to));\r
632 if (to < range.length - 1) {\r
633 to = Integer.parseInt (range.substring (to + 1));\r
634 } else {\r
635 to = from;\r
636 }if (from > 0 && to >= from) {\r
637 colSel.hideColumns (from, to);\r
638 }}}\r
639 }, "jalview.datamodel.ColumnSelection,~S");\r
640 Clazz.defineMethod (c$, "autoAnnotsKey", \r
641  function (annotation, refSeq, groupRef) {\r
642 return annotation.graph + "\t" + annotation.label + "\t" + annotation.description + "\t" + (refSeq != null ? refSeq.getDisplayId (true) : "");\r
643 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.SequenceI,~S");\r
644 Clazz.defineMethod (c$, "parseAnnotation", \r
645 function (string, graphStyle) {\r
646 var hasSymbols = (graphStyle == 0);\r
647 var desc = null;\r
648 var displayChar = null;\r
649 var ss = ' ';\r
650 var value = 0;\r
651 var parsedValue = false;\r
652 var dcset = false;\r
653 var colour = null;\r
654 var i = string.indexOf ("[");\r
655 var j = string.indexOf ("]");\r
656 if (i > -1 && j > -1) {\r
657 var ucs =  new jalview.schemes.UserColourScheme ();\r
658 colour = ucs.getColourFromString (string.substring (i + 1, j));\r
659 if (i > 0 && string.charAt (i - 1) == ',') {\r
660 i--;\r
661 }string = string.substring (0, i) + string.substring (j + 1);\r
662 }var st =  new java.util.StringTokenizer (string, ",", true);\r
663 var token;\r
664 var seenContent = false;\r
665 var pass = 0;\r
666 while (st.hasMoreTokens ()) {\r
667 pass++;\r
668 token = st.nextToken ().trim ();\r
669 if (token.equals (",")) {\r
670 if (!seenContent && parsedValue && !dcset) {\r
671 dcset = true;\r
672 displayChar = " ";\r
673 }seenContent = false;\r
674 continue;\r
675 } else {\r
676 seenContent = true;\r
677 }if (!parsedValue) {\r
678 try {\r
679 displayChar = token;\r
680 value =  new Float (token).floatValue ();\r
681 parsedValue = true;\r
682 continue;\r
683 } catch (ex) {\r
684 if (Clazz.exceptionOf (ex, NumberFormatException)) {\r
685 } else {\r
686 throw ex;\r
687 }\r
688 }\r
689 } else {\r
690 if (token.length == 1) {\r
691 displayChar = token;\r
692 }}if (hasSymbols && (token.equals ("H") || token.equals ("E") || token.equals ("S") || token.equals (" "))) {\r
693 ss = token.charAt (0);\r
694 if (displayChar.equals (token.substring (0, 1))) {\r
695 displayChar = "";\r
696 }} else if (desc == null || (parsedValue && pass > 2)) {\r
697 desc = token;\r
698 }}\r
699 if (displayChar != null && desc != null && desc.length == 1) {\r
700 if (displayChar.length > 1) {\r
701 var tmp = displayChar;\r
702 displayChar = desc;\r
703 desc = tmp;\r
704 } else {\r
705 if (displayChar.equals (desc)) {\r
706 desc = null;\r
707 }}}var anot =  new jalview.datamodel.Annotation (displayChar, desc, ss, value);\r
708 anot.colour = colour;\r
709 return anot;\r
710 }, "~S,~N");\r
711 Clazz.defineMethod (c$, "colourAnnotations", \r
712 function (al, label, colour) {\r
713 var ucs =  new jalview.schemes.UserColourScheme (colour);\r
714 var annotations;\r
715 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
716 if (al.getAlignmentAnnotation ()[i].label.equalsIgnoreCase (label)) {\r
717 annotations = al.getAlignmentAnnotation ()[i].annotations;\r
718 for (var j = 0; j < annotations.length; j++) {\r
719 if (annotations[j] != null) {\r
720 annotations[j].colour = ucs.findColour ('A');\r
721 }}\r
722 }}\r
723 }, "jalview.datamodel.AlignmentI,~S,~S");\r
724 Clazz.defineMethod (c$, "combineAnnotations", \r
725 function (al, combineCount, st, seqRef, groupRef) {\r
726 var group = st.nextToken ();\r
727 var graphGroup = 0;\r
728 if (al.getAlignmentAnnotation () != null) {\r
729 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
730 var aa = al.getAlignmentAnnotation ()[i];\r
731 if (aa.graphGroup > graphGroup) {\r
732 graphGroup = aa.graphGroup + 1;\r
733 }if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {\r
734 if (aa.graphGroup > -1) {\r
735 graphGroup = aa.graphGroup;\r
736 } else {\r
737 if (graphGroup <= combineCount) {\r
738 graphGroup = combineCount + 1;\r
739 }aa.graphGroup = graphGroup;\r
740 }break;\r
741 }}\r
742 while (st.hasMoreTokens ()) {\r
743 group = st.nextToken ();\r
744 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
745 var aa = al.getAlignmentAnnotation ()[i];\r
746 if (aa.sequenceRef === seqRef && aa.groupRef === groupRef && aa.label.equalsIgnoreCase (group)) {\r
747 aa.graphGroup = graphGroup;\r
748 break;\r
749 }}\r
750 }\r
751 } else {\r
752 System.err.println ("Couldn't combine annotations. None are added to alignment yet!");\r
753 }}, "jalview.datamodel.AlignmentI,~N,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");\r
754 Clazz.defineMethod (c$, "addLine", \r
755 function (al, st, seqRef, groupRef) {\r
756 var group = st.nextToken ();\r
757 var annotation = null;\r
758 var alannot = al.getAlignmentAnnotation ();\r
759 var value =  new Float (st.nextToken ()).floatValue ();\r
760 var label = st.hasMoreTokens () ? st.nextToken () : null;\r
761 var colour = null;\r
762 if (st.hasMoreTokens ()) {\r
763 var ucs =  new jalview.schemes.UserColourScheme (st.nextToken ());\r
764 colour = ucs.findColour ('A');\r
765 }if (alannot != null) {\r
766 for (var i = 0; i < alannot.length; i++) {\r
767 if (alannot[i].label.equalsIgnoreCase (group) && (seqRef == null || alannot[i].sequenceRef === seqRef) && (groupRef == null || alannot[i].groupRef === groupRef)) {\r
768 alannot[i].setThreshold ( new jalview.datamodel.GraphLine (value, label, colour));\r
769 }}\r
770 }if (annotation == null) {\r
771 return;\r
772 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer,jalview.datamodel.SequenceI,jalview.datamodel.SequenceGroup");\r
773 Clazz.defineMethod (c$, "addGroup", \r
774 function (al, st) {\r
775 var sg =  new jalview.datamodel.SequenceGroup ();\r
776 sg.setName (st.nextToken ());\r
777 var rng = "";\r
778 try {\r
779 rng = st.nextToken ();\r
780 if (rng.length > 0 && !rng.startsWith ("*")) {\r
781 sg.setStartRes (Integer.parseInt (rng) - 1);\r
782 } else {\r
783 sg.setStartRes (0);\r
784 }rng = st.nextToken ();\r
785 if (rng.length > 0 && !rng.startsWith ("*")) {\r
786 sg.setEndRes (Integer.parseInt (rng) - 1);\r
787 } else {\r
788 sg.setEndRes (al.getWidth () - 1);\r
789 }} catch (e) {\r
790 if (Clazz.exceptionOf (e, Exception)) {\r
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.");\r
792 sg.setStartRes (0);\r
793 sg.setEndRes (al.getWidth () - 1);\r
794 } else {\r
795 throw e;\r
796 }\r
797 }\r
798 var index = st.nextToken ();\r
799 if (index.equals ("-1")) {\r
800 while (st.hasMoreElements ()) {\r
801 sg.addSequence (al.findName (st.nextToken ()), false);\r
802 }\r
803 } else {\r
804 var st2 =  new java.util.StringTokenizer (index, ",");\r
805 while (st2.hasMoreTokens ()) {\r
806 var tmp = st2.nextToken ();\r
807 if (tmp.equals ("*")) {\r
808 for (var i = 0; i < al.getHeight (); i++) {\r
809 sg.addSequence (al.getSequenceAt (i), false);\r
810 }\r
811 } else if (tmp.indexOf ("-") >= 0) {\r
812 var st3 =  new java.util.StringTokenizer (tmp, "-");\r
813 var start = (Integer.parseInt (st3.nextToken ()));\r
814 var end = (Integer.parseInt (st3.nextToken ()));\r
815 if (end > start) {\r
816 for (var i = start; i <= end; i++) {\r
817 sg.addSequence (al.getSequenceAt (i - 1), false);\r
818 }\r
819 }} else {\r
820 sg.addSequence (al.getSequenceAt (Integer.parseInt (tmp) - 1), false);\r
821 }}\r
822 }if (this.refSeq != null) {\r
823 sg.setStartRes (this.refSeq.findIndex (sg.getStartRes () + 1) - 1);\r
824 sg.setEndRes (this.refSeq.findIndex (sg.getEndRes () + 1) - 1);\r
825 sg.setSeqrep (this.refSeq);\r
826 }if (sg.getSize () > 0) {\r
827 al.addGroup (sg);\r
828 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
829 Clazz.defineMethod (c$, "addRowProperties", \r
830 function (al, st) {\r
831 var label = st.nextToken ();\r
832 var keyValue;\r
833 var key;\r
834 var value;\r
835 var scaletofit = false;\r
836 var centerlab = false;\r
837 var showalllabs = false;\r
838 while (st.hasMoreTokens ()) {\r
839 keyValue = st.nextToken ();\r
840 key = keyValue.substring (0, keyValue.indexOf ("="));\r
841 value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
842 if (key.equalsIgnoreCase ("scaletofit")) {\r
843 scaletofit = Boolean.$valueOf (value).booleanValue ();\r
844 }if (key.equalsIgnoreCase ("showalllabs")) {\r
845 showalllabs = Boolean.$valueOf (value).booleanValue ();\r
846 }if (key.equalsIgnoreCase ("centrelabs")) {\r
847 centerlab = Boolean.$valueOf (value).booleanValue ();\r
848 }var alr = al.getAlignmentAnnotation ();\r
849 if (alr != null) {\r
850 for (var i = 0; i < alr.length; i++) {\r
851 if (alr[i].label.equalsIgnoreCase (label)) {\r
852 alr[i].centreColLabels = centerlab;\r
853 alr[i].scaleColLabel = scaletofit;\r
854 alr[i].showAllColLabels = showalllabs;\r
855 }}\r
856 }}\r
857 }, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
858 Clazz.defineMethod (c$, "addProperties", \r
859 function (al, st) {\r
860 if (al.getGroups () == null) {\r
861 return;\r
862 }var name = st.nextToken ();\r
863 var sg = null;\r
864 for (var _sg, $_sg = al.getGroups ().iterator (); $_sg.hasNext () && ((_sg = $_sg.next ()) || true);) {\r
865 if ((sg = _sg).getName ().equals (name)) {\r
866 break;\r
867 } else {\r
868 sg = null;\r
869 }}\r
870 if (sg != null) {\r
871 var keyValue;\r
872 var key;\r
873 var value;\r
874 var def = sg.cs;\r
875 sg.cs = null;\r
876 while (st.hasMoreTokens ()) {\r
877 keyValue = st.nextToken ();\r
878 key = keyValue.substring (0, keyValue.indexOf ("="));\r
879 value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
880 if (key.equalsIgnoreCase ("description")) {\r
881 sg.setDescription (value);\r
882 } else if (key.equalsIgnoreCase ("colour")) {\r
883 sg.cs = jalview.schemes.ColourSchemeProperty.getColour (al, value);\r
884 } else if (key.equalsIgnoreCase ("pidThreshold")) {\r
885 sg.cs.setThreshold (Integer.parseInt (value), true);\r
886 } else if (key.equalsIgnoreCase ("consThreshold")) {\r
887 sg.cs.setConservationInc (Integer.parseInt (value));\r
888 var c =  new jalview.analysis.Conservation ("Group", jalview.schemes.ResidueProperties.propHash, 3, sg.getSequences (null), sg.getStartRes (), sg.getEndRes () + 1);\r
889 c.calculate ();\r
890 c.verdict (false, 25);\r
891 sg.cs.setConservation (c);\r
892 } else if (key.equalsIgnoreCase ("outlineColour")) {\r
893 sg.setOutlineColour ( new jalview.schemes.UserColourScheme (value).findColour ('A'));\r
894 } else if (key.equalsIgnoreCase ("displayBoxes")) {\r
895 sg.setDisplayBoxes (Boolean.$valueOf (value).booleanValue ());\r
896 } else if (key.equalsIgnoreCase ("showUnconserved")) {\r
897 sg.setShowNonconserved (Boolean.$valueOf (value).booleanValue ());\r
898 } else if (key.equalsIgnoreCase ("displayText")) {\r
899 sg.setDisplayText (Boolean.$valueOf (value).booleanValue ());\r
900 } else if (key.equalsIgnoreCase ("colourText")) {\r
901 sg.setColourText (Boolean.$valueOf (value).booleanValue ());\r
902 } else if (key.equalsIgnoreCase ("textCol1")) {\r
903 sg.textColour =  new jalview.schemes.UserColourScheme (value).findColour ('A');\r
904 } else if (key.equalsIgnoreCase ("textCol2")) {\r
905 sg.textColour2 =  new jalview.schemes.UserColourScheme (value).findColour ('A');\r
906 } else if (key.equalsIgnoreCase ("textColThreshold")) {\r
907 sg.thresholdTextColour = Integer.parseInt (value);\r
908 } else if (key.equalsIgnoreCase ("idColour")) {\r
909 sg.setIdColour ((def =  new jalview.schemes.UserColourScheme (value)).findColour ('A'));\r
910 } else if (key.equalsIgnoreCase ("hide")) {\r
911 sg.setHidereps (true);\r
912 } else if (key.equalsIgnoreCase ("hidecols")) {\r
913 sg.setHideCols (true);\r
914 }sg.recalcConservation ();\r
915 }\r
916 if (sg.cs == null) {\r
917 sg.cs = def;\r
918 }}}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
919 Clazz.defineMethod (c$, "setBelowAlignment", \r
920 function (al, st) {\r
921 var token;\r
922 var aa;\r
923 var ala = al.getAlignmentAnnotation ();\r
924 if (ala == null) {\r
925 System.err.print ("Warning - no annotation to set below for sequence associated annotation:");\r
926 }while (st.hasMoreTokens ()) {\r
927 token = st.nextToken ();\r
928 if (ala == null) {\r
929 System.err.print (" " + token);\r
930 } else {\r
931 for (var i = 0; i < al.getAlignmentAnnotation ().length; i++) {\r
932 aa = al.getAlignmentAnnotation ()[i];\r
933 if (aa.sequenceRef === this.refSeq && aa.label.equals (token)) {\r
934 aa.belowAlignment = true;\r
935 }}\r
936 }}\r
937 if (ala == null) {\r
938 System.err.print ("\n");\r
939 }}, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
940 Clazz.defineMethod (c$, "addAlignmentDetails", \r
941 function (al, st) {\r
942 var keyValue;\r
943 var key;\r
944 var value;\r
945 while (st.hasMoreTokens ()) {\r
946 keyValue = st.nextToken ();\r
947 key = keyValue.substring (0, keyValue.indexOf ("="));\r
948 value = keyValue.substring (keyValue.indexOf ("=") + 1);\r
949 al.setProperty (key, value);\r
950 }\r
951 }, "jalview.datamodel.AlignmentI,java.util.StringTokenizer");\r
952 Clazz.defineMethod (c$, "printCSVAnnotations", \r
953 function (annotations) {\r
954 var sp =  new StringBuffer ();\r
955 for (var i = 0; i < annotations.length; i++) {\r
956 var atos = annotations[i].toString ();\r
957 var p = 0;\r
958 do {\r
959 var cp = atos.indexOf ("\n", p);\r
960 sp.append (annotations[i].label);\r
961 sp.append (",");\r
962 if (cp > p) {\r
963 sp.append (atos.substring (p, cp + 1));\r
964 } else {\r
965 sp.append (atos.substring (p));\r
966 sp.append (this.newline);\r
967 }p = cp + 1;\r
968 } while (p > 0);\r
969 }\r
970 return sp.toString ();\r
971 }, "~A");\r
972 Clazz.defineMethod (c$, "printAnnotationsForView", \r
973 function (viewport) {\r
974 return this.printAnnotations (viewport.isShowAnnotation () ? viewport.getAlignment ().getAlignmentAnnotation () : null, viewport.getAlignment ().getGroups (), viewport.getAlignment ().getProperties (), viewport.getColumnSelection (), viewport.getAlignment (), null);\r
975 }, "jalview.api.AlignViewportI");\r
976 Clazz.defineMethod (c$, "printAnnotationsForAlignment", \r
977 function (al) {\r
978 return this.printAnnotations (al.getAlignmentAnnotation (), al.getGroups (), al.getProperties (), null, al, null);\r
979 }, "jalview.datamodel.AlignmentI");\r
980 c$.$AnnotationFile$ViewDef$ = function () {\r
981 Clazz.pu$h(self.c$);\r
982 c$ = Clazz.decorateAsClass (function () {\r
983 Clazz.prepareCallback (this, arguments);\r
984 this.viewname = null;\r
985 this.hidseqs = null;\r
986 this.hiddencols = null;\r
987 this.visibleGroups = null;\r
988 this.hiddenRepSeqs = null;\r
989 Clazz.instantialize (this, arguments);\r
990 }, jalview.io.AnnotationFile, "ViewDef");\r
991 Clazz.makeConstructor (c$, \r
992 function (a, b, c, d) {\r
993 this.viewname = a;\r
994 this.hidseqs = b;\r
995 this.hiddencols = c;\r
996 this.hiddenRepSeqs = d;\r
997 }, "~S,jalview.datamodel.HiddenSequences,jalview.datamodel.ColumnSelection,java.util.Hashtable");\r
998 c$ = Clazz.p0p ();\r
999 };\r
1000 Clazz.defineStatics (c$,\r
1001 "GRAPHLINE", "GRAPHLINE",\r
1002 "COMBINE", "COMBINE");\r
1003 });\r