JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / jalview / datamodel / AlignmentAnnotation.js
1 Clazz.declarePackage ("jalview.datamodel");\r
2 Clazz.load (["java.util.HashMap"], "jalview.datamodel.AlignmentAnnotation", ["jalview.analysis.Rna", "jalview.datamodel.Annotation", "$.GraphLine", "jalview.schemes.ResidueProperties", "java.lang.Double", "$.Error", "$.Long", "$.StringBuffer", "$.StringBuilder", "java.util.Collections"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.autoCalculated = false;\r
5 this.annotationId = null;\r
6 this.sequenceRef = null;\r
7 this.label = null;\r
8 this.description = null;\r
9 this.annotations = null;\r
10 this.bps = null;\r
11 this._rnasecstr = null;\r
12 this.invalidrnastruc = -2;\r
13 this.sequenceMapping = null;\r
14 this.graphMin = 0;\r
15 this.graphMax = 0;\r
16 this.score = NaN;\r
17 this.$hasScore = false;\r
18 this.threshold = null;\r
19 this.editable = false;\r
20 this.hasIcons = false;\r
21 this.hasText = false;\r
22 this.visible = true;\r
23 this.graphGroup = -1;\r
24 this.height = 0;\r
25 this.graph = 0;\r
26 this.graphHeight = 40;\r
27 this.padGaps = false;\r
28 this.belowAlignment = true;\r
29 this.groupRef = null;\r
30 this.showAllColLabels = false;\r
31 this.scaleColLabel = false;\r
32 this.centreColLabels = false;\r
33 this.isrna = false;\r
34 if (!Clazz.isClassDefined ("jalview.datamodel.AlignmentAnnotation.AnnotCharSequence")) {\r
35 jalview.datamodel.AlignmentAnnotation.$AlignmentAnnotation$AnnotCharSequence$ ();\r
36 }\r
37 this._lastrnaannot = -1;\r
38 this.calcId = "";\r
39 this.properties = null;\r
40 this._linecolour = null;\r
41 Clazz.instantialize (this, arguments);\r
42 }, jalview.datamodel, "AlignmentAnnotation");\r
43 Clazz.prepareFields (c$, function () {\r
44 this.properties =  new java.util.HashMap ();\r
45 });\r
46 Clazz.defineMethod (c$, "_updateRnaSecStr", \r
47  function (RNAannot) {\r
48 try {\r
49 this._rnasecstr = jalview.analysis.Rna.GetBasePairs (RNAannot);\r
50 this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot);\r
51 this.invalidrnastruc = -1;\r
52 } catch (px) {\r
53 if (Clazz.exceptionOf (px, jalview.analysis.WUSSParseException)) {\r
54 this.invalidrnastruc = px.getProblemPos ();\r
55 } else {\r
56 throw px;\r
57 }\r
58 }\r
59 if (this.invalidrnastruc > -1) {\r
60 return;\r
61 }jalview.analysis.Rna.HelixMap (this._rnasecstr);\r
62 if (this._rnasecstr != null && this._rnasecstr.length > 0) {\r
63 this.isrna = true;\r
64 this.showAllColLabels = true;\r
65 this.scaleColLabel = true;\r
66 this._markRnaHelices ();\r
67 }}, "CharSequence");\r
68 Clazz.defineMethod (c$, "_markRnaHelices", \r
69  function () {\r
70 var mxval = 0;\r
71 for (var x = 0; x < this._rnasecstr.length; x++) {\r
72 var val = 0;\r
73 try {\r
74 val = (Integer.$valueOf (this._rnasecstr[x].getFeatureGroup ())).intValue ();\r
75 if (mxval < val) {\r
76 mxval = val;\r
77 }} catch (q) {\r
78 if (Clazz.exceptionOf (q, NumberFormatException)) {\r
79 } else {\r
80 throw q;\r
81 }\r
82 }\r
83 ;this.annotations[this._rnasecstr[x].getBegin ()].value = val;\r
84 this.annotations[this._rnasecstr[x].getEnd ()].value = val;\r
85 }\r
86 this.setScore (mxval);\r
87 });\r
88 Clazz.defineMethod (c$, "finalize", \r
89 function () {\r
90 this.sequenceRef = null;\r
91 this.groupRef = null;\r
92 Clazz.superCall (this, jalview.datamodel.AlignmentAnnotation, "finalize", []);\r
93 });\r
94 c$.getGraphValueFromString = Clazz.defineMethod (c$, "getGraphValueFromString", \r
95 function (string) {\r
96 if (string.equalsIgnoreCase ("BAR_GRAPH")) {\r
97 return 1;\r
98 } else if (string.equalsIgnoreCase ("LINE_GRAPH")) {\r
99 return 2;\r
100 } else {\r
101 return 0;\r
102 }}, "~S");\r
103 Clazz.defineMethod (c$, "ConcenStru", \r
104 function (RNAannot) {\r
105 this.bps = jalview.analysis.Rna.GetModeleBP (RNAannot);\r
106 }, "CharSequence");\r
107 Clazz.makeConstructor (c$, \r
108 function (label, description, annotations) {\r
109 this.setAnnotationId ();\r
110 this.editable = true;\r
111 this.label = label;\r
112 this.description = description;\r
113 this.annotations = annotations;\r
114 this.validateRangeAndDisplay ();\r
115 }, "~S,~S,~A");\r
116 Clazz.defineMethod (c$, "areLabelsSecondaryStructure", \r
117 function () {\r
118 var nonSSLabel = false;\r
119 this.isrna = false;\r
120 var rnastring =  new StringBuffer ();\r
121 var firstChar = String.fromCharCode (0);\r
122 for (var i = 0; i < this.annotations.length; i++) {\r
123 if (this.annotations[i] == null) {\r
124 continue;\r
125 }if (this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'E') {\r
126 this.hasIcons = new Boolean (this.hasIcons | true).valueOf ();\r
127 } else {\r
128 if (this.annotations[i].secondaryStructure == '(' || this.annotations[i].secondaryStructure == '[' || this.annotations[i].secondaryStructure == '<' || this.annotations[i].secondaryStructure == '{' || this.annotations[i].secondaryStructure == 'A' || this.annotations[i].secondaryStructure == 'B' || this.annotations[i].secondaryStructure == 'C' || this.annotations[i].secondaryStructure == 'D' || this.annotations[i].secondaryStructure == 'E' || this.annotations[i].secondaryStructure == 'F' || this.annotations[i].secondaryStructure == 'G' || this.annotations[i].secondaryStructure == 'H' || this.annotations[i].secondaryStructure == 'I' || this.annotations[i].secondaryStructure == 'J' || this.annotations[i].secondaryStructure == 'K' || this.annotations[i].secondaryStructure == 'L' || this.annotations[i].secondaryStructure == 'M' || this.annotations[i].secondaryStructure == 'N' || this.annotations[i].secondaryStructure == 'O' || this.annotations[i].secondaryStructure == 'P' || this.annotations[i].secondaryStructure == 'Q' || this.annotations[i].secondaryStructure == 'R' || this.annotations[i].secondaryStructure == 'S' || this.annotations[i].secondaryStructure == 'T' || this.annotations[i].secondaryStructure == 'U' || this.annotations[i].secondaryStructure == 'V' || this.annotations[i].secondaryStructure == 'W' || this.annotations[i].secondaryStructure == 'X' || this.annotations[i].secondaryStructure == 'Y' || this.annotations[i].secondaryStructure == 'Z') {\r
129 this.hasIcons = new Boolean (this.hasIcons | true).valueOf ();\r
130 this.isrna = new Boolean (this.isrna | true).valueOf ();\r
131 }}if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.length == 0) {\r
132 rnastring.append ('.');\r
133 continue;\r
134 }if (this.annotations[i].displayCharacter.length == 1) {\r
135 firstChar = this.annotations[i].displayCharacter.charAt (0);\r
136 if (this.annotations[i].secondaryStructure != ' ' && !this.hasIcons && firstChar != ' ' && firstChar != '$' && firstChar.charCodeAt (0) != 0xCE && firstChar != '(' && firstChar != '[' && firstChar != '>' && firstChar != '{' && firstChar != 'A' && firstChar != 'B' && firstChar != 'C' && firstChar != 'D' && firstChar != 'E' && firstChar != 'F' && firstChar != 'G' && firstChar != 'H' && firstChar != 'I' && firstChar != 'J' && firstChar != 'K' && firstChar != 'L' && firstChar != 'M' && firstChar != 'N' && firstChar != 'O' && firstChar != 'P' && firstChar != 'Q' && firstChar != 'R' && firstChar != 'S' && firstChar != 'T' && firstChar != 'U' && firstChar != 'V' && firstChar != 'W' && firstChar != 'X' && firstChar != 'Y' && firstChar != 'Z' && firstChar != '-' && firstChar.charCodeAt (0) < jalview.schemes.ResidueProperties.aaIndex.length) {\r
137 if (jalview.schemes.ResidueProperties.aaIndex[firstChar.charCodeAt (0)] < 23) {\r
138 nonSSLabel = true;\r
139 }}} else {\r
140 rnastring.append (this.annotations[i].displayCharacter.charAt (1));\r
141 }if (this.annotations[i].displayCharacter.length > 0) {\r
142 this.hasText = true;\r
143 }}\r
144 if (nonSSLabel) {\r
145 this.hasIcons = false;\r
146 for (var j = 0; j < this.annotations.length; j++) {\r
147 if (this.annotations[j] != null && this.annotations[j].secondaryStructure != ' ') {\r
148 this.annotations[j].displayCharacter = String.valueOf (this.annotations[j].secondaryStructure);\r
149 this.annotations[j].secondaryStructure = ' ';\r
150 }}\r
151 } else {\r
152 if (this.isrna) {\r
153 this._updateRnaSecStr (Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null));\r
154 }}});\r
155 Clazz.defineMethod (c$, "getRNAStruc", \r
156 function () {\r
157 if (this.isrna) {\r
158 var rnastruc = Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null).toString ();\r
159 if (this._lastrnaannot != rnastruc.hashCode ()) {\r
160 this._lastrnaannot = rnastruc.hashCode ();\r
161 this._updateRnaSecStr (rnastruc);\r
162 }return rnastruc;\r
163 }return null;\r
164 });\r
165 Clazz.makeConstructor (c$, \r
166 function (label, description, annotations, min, max, graphType) {\r
167 this.setAnnotationId ();\r
168 this.editable = graphType == 0;\r
169 this.label = label;\r
170 this.description = description;\r
171 this.annotations = annotations;\r
172 this.graph = graphType;\r
173 this.graphMin = min;\r
174 this.graphMax = max;\r
175 this.validateRangeAndDisplay ();\r
176 }, "~S,~S,~A,~N,~N,~N");\r
177 Clazz.defineMethod (c$, "validateRangeAndDisplay", \r
178 function () {\r
179 if (this.annotations == null) {\r
180 this.visible = false;\r
181 return;\r
182 }var graphType = this.graph;\r
183 var min = this.graphMin;\r
184 var max = this.graphMax;\r
185 var drawValues = true;\r
186 this._linecolour = null;\r
187 if (min == max) {\r
188 min = 999999999;\r
189 for (var i = 0; i < this.annotations.length; i++) {\r
190 if (this.annotations[i] == null) {\r
191 continue;\r
192 }if (drawValues && this.annotations[i].displayCharacter != null && this.annotations[i].displayCharacter.length > 1) {\r
193 drawValues = false;\r
194 }if (this.annotations[i].value > max) {\r
195 max = this.annotations[i].value;\r
196 }if (this.annotations[i].value < min) {\r
197 min = this.annotations[i].value;\r
198 }if (this._linecolour == null && this.annotations[i].colour != null) {\r
199 this._linecolour = this.annotations[i].colour;\r
200 }}\r
201 if (min > 0) {\r
202 min = 0;\r
203 } else {\r
204 if (max < 0) {\r
205 max = 0;\r
206 }}}this.graphMin = min;\r
207 this.graphMax = max;\r
208 this.areLabelsSecondaryStructure ();\r
209 if (!drawValues && graphType != 0) {\r
210 for (var i = 0; i < this.annotations.length; i++) {\r
211 if (this.annotations[i] != null) {\r
212 this.annotations[i].displayCharacter = "";\r
213 }}\r
214 }});\r
215 Clazz.makeConstructor (c$, \r
216 function (annotation) {\r
217 this.setAnnotationId ();\r
218 this.label =  String.instantialize (annotation.label);\r
219 if (annotation.description != null) {\r
220 this.description =  String.instantialize (annotation.description);\r
221 }this.graphMin = annotation.graphMin;\r
222 this.graphMax = annotation.graphMax;\r
223 this.graph = annotation.graph;\r
224 this.graphHeight = annotation.graphHeight;\r
225 this.graphGroup = annotation.graphGroup;\r
226 this.groupRef = annotation.groupRef;\r
227 this.editable = annotation.editable;\r
228 this.autoCalculated = annotation.autoCalculated;\r
229 this.hasIcons = annotation.hasIcons;\r
230 this.hasText = annotation.hasText;\r
231 this.height = annotation.height;\r
232 this.label = annotation.label;\r
233 this.padGaps = annotation.padGaps;\r
234 this.visible = annotation.visible;\r
235 this.centreColLabels = annotation.centreColLabels;\r
236 this.scaleColLabel = annotation.scaleColLabel;\r
237 this.showAllColLabels = annotation.showAllColLabels;\r
238 this.calcId = annotation.calcId;\r
239 if (annotation.properties != null) {\r
240 this.properties =  new java.util.HashMap ();\r
241 for (var val, $val = annotation.properties.entrySet ().iterator (); $val.hasNext () && ((val = $val.next ()) || true);) {\r
242 this.properties.put (val.getKey (), val.getValue ());\r
243 }\r
244 }if (this.$hasScore = annotation.$hasScore) {\r
245 this.score = annotation.score;\r
246 }if (annotation.threshold != null) {\r
247 this.threshold =  new jalview.datamodel.GraphLine (annotation.threshold);\r
248 }var ann = annotation.annotations;\r
249 if (annotation.annotations != null) {\r
250 this.annotations =  new Array (ann.length);\r
251 for (var i = 0; i < ann.length; i++) {\r
252 if (ann[i] != null) {\r
253 this.annotations[i] =  new jalview.datamodel.Annotation (ann[i]);\r
254 if (this._linecolour != null) {\r
255 this._linecolour = this.annotations[i].colour;\r
256 }}}\r
257 }if (annotation.sequenceRef != null) {\r
258 this.sequenceRef = annotation.sequenceRef;\r
259 if (annotation.sequenceMapping != null) {\r
260 var p = null;\r
261 this.sequenceMapping =  new java.util.HashMap ();\r
262 var pos = annotation.sequenceMapping.keySet ().iterator ();\r
263 while (pos.hasNext ()) {\r
264 p = pos.next ();\r
265 var a = annotation.sequenceMapping.get (p);\r
266 if (a == null) {\r
267 continue;\r
268 }if (ann != null) {\r
269 for (var i = 0; i < ann.length; i++) {\r
270 if (ann[i] === a) {\r
271 this.sequenceMapping.put (p, this.annotations[i]);\r
272 }}\r
273 }}\r
274 } else {\r
275 this.sequenceMapping = null;\r
276 }}{\r
277 }this.validateRangeAndDisplay ();\r
278 }, "jalview.datamodel.AlignmentAnnotation");\r
279 Clazz.defineMethod (c$, "restrict", \r
280 function (startRes, endRes) {\r
281 if (this.annotations == null) {\r
282 return;\r
283 }if (startRes < 0) {\r
284 startRes = 0;\r
285 }if (startRes >= this.annotations.length) {\r
286 startRes = this.annotations.length - 1;\r
287 }if (endRes >= this.annotations.length) {\r
288 endRes = this.annotations.length - 1;\r
289 }if (this.annotations == null) {\r
290 return;\r
291 }var temp =  new Array (endRes - startRes + 1);\r
292 if (startRes < this.annotations.length) {\r
293 System.arraycopy (this.annotations, startRes, temp, 0, endRes - startRes + 1);\r
294 }if (this.sequenceRef != null) {\r
295 var spos = this.sequenceRef.findPosition (startRes);\r
296 var epos = this.sequenceRef.findPosition (endRes);\r
297 if (this.sequenceMapping != null) {\r
298 var newmapping =  new java.util.HashMap ();\r
299 var e = this.sequenceMapping.keySet ().iterator ();\r
300 while (e.hasNext ()) {\r
301 var pos = e.next ();\r
302 if (pos.intValue () >= spos && pos.intValue () <= epos) {\r
303 newmapping.put (pos, this.sequenceMapping.get (pos));\r
304 }}\r
305 this.sequenceMapping.clear ();\r
306 this.sequenceMapping = newmapping;\r
307 }}this.annotations = temp;\r
308 }, "~N,~N");\r
309 Clazz.defineMethod (c$, "padAnnotation", \r
310 function (length) {\r
311 if (this.annotations == null) {\r
312 return true;\r
313 }if (this.annotations.length < length) {\r
314 var na =  new Array (length);\r
315 System.arraycopy (this.annotations, 0, na, 0, this.annotations.length);\r
316 this.annotations = na;\r
317 return true;\r
318 }return this.annotations.length > length;\r
319 }, "~N");\r
320 Clazz.overrideMethod (c$, "toString", \r
321 function () {\r
322 var buffer =  new StringBuilder (256);\r
323 for (var i = 0; i < this.annotations.length; i++) {\r
324 if (this.annotations[i] != null) {\r
325 if (this.graph != 0) {\r
326 buffer.append (this.annotations[i].value);\r
327 } else if (this.hasIcons) {\r
328 buffer.append (this.annotations[i].secondaryStructure);\r
329 } else {\r
330 buffer.append (this.annotations[i].displayCharacter);\r
331 }}buffer.append (", ");\r
332 }\r
333 if (this.label.indexOf ("Consensus") == 0) {\r
334 buffer.append ("\n");\r
335 for (var i = 0; i < this.annotations.length; i++) {\r
336 if (this.annotations[i] != null) {\r
337 buffer.append (this.annotations[i].description);\r
338 }buffer.append (", ");\r
339 }\r
340 }return buffer.toString ();\r
341 });\r
342 Clazz.defineMethod (c$, "setThreshold", \r
343 function (line) {\r
344 this.threshold = line;\r
345 }, "jalview.datamodel.GraphLine");\r
346 Clazz.defineMethod (c$, "getThreshold", \r
347 function () {\r
348 return this.threshold;\r
349 });\r
350 Clazz.defineMethod (c$, "createSequenceMapping", \r
351 function (seqRef, startRes, alreadyMapped) {\r
352 if (seqRef == null) {\r
353 return;\r
354 }this.sequenceRef = seqRef;\r
355 if (this.annotations == null) {\r
356 return;\r
357 }this.sequenceMapping =  new java.util.HashMap ();\r
358 var seqPos;\r
359 for (var i = 0; i < this.annotations.length; i++) {\r
360 if (this.annotations[i] != null) {\r
361 if (alreadyMapped) {\r
362 seqPos = seqRef.findPosition (i);\r
363 } else {\r
364 seqPos = i + startRes;\r
365 }this.sequenceMapping.put ( new Integer (seqPos), this.annotations[i]);\r
366 }}\r
367 }, "jalview.datamodel.SequenceI,~N,~B");\r
368 Clazz.defineMethod (c$, "adjustForAlignment", \r
369 function () {\r
370 if (this.sequenceRef == null) {\r
371 return;\r
372 }if (this.annotations == null) {\r
373 return;\r
374 }var a = 0;\r
375 var aSize = this.sequenceRef.getLength ();\r
376 if (aSize == 0) {\r
377 return;\r
378 }var position;\r
379 var temp =  new Array (aSize);\r
380 var index;\r
381 for (a = this.sequenceRef.getStart (); a <= this.sequenceRef.getEnd (); a++) {\r
382 index =  new Integer (a);\r
383 if (this.sequenceMapping.containsKey (index)) {\r
384 position = this.sequenceRef.findIndex (a) - 1;\r
385 temp[position] = this.sequenceMapping.get (index);\r
386 }}\r
387 this.annotations = temp;\r
388 });\r
389 Clazz.defineMethod (c$, "compactAnnotationArray", \r
390 function () {\r
391 var i = 0;\r
392 var iSize = this.annotations.length;\r
393 while (i < iSize) {\r
394 if (this.annotations[i] == null) {\r
395 if (i + 1 < iSize) {\r
396 System.arraycopy (this.annotations, i + 1, this.annotations, i, iSize - i - 1);\r
397 }iSize--;\r
398 } else {\r
399 i++;\r
400 }}\r
401 var ann = this.annotations;\r
402 this.annotations =  new Array (i);\r
403 System.arraycopy (ann, 0, this.annotations, 0, i);\r
404 ann = null;\r
405 return iSize;\r
406 });\r
407 Clazz.defineMethod (c$, "setSequenceRef", \r
408 function (sequenceI) {\r
409 if (sequenceI != null) {\r
410 if (this.sequenceRef != null) {\r
411 var rIsDs = this.sequenceRef.getDatasetSequence () == null;\r
412 var tIsDs = sequenceI.getDatasetSequence () == null;\r
413 if (this.sequenceRef !== sequenceI && (rIsDs && !tIsDs && this.sequenceRef !== sequenceI.getDatasetSequence ()) && (!rIsDs && tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI) && (!rIsDs && !tIsDs && this.sequenceRef.getDatasetSequence () !== sequenceI.getDatasetSequence ()) && !this.sequenceRef.equals (sequenceI)) {\r
414 this.sequenceRef = null;\r
415 if (this.sequenceMapping != null) {\r
416 this.sequenceMapping = null;\r
417 }this.createSequenceMapping (sequenceI, 1, true);\r
418 this.adjustForAlignment ();\r
419 } else {\r
420 this.sequenceRef = sequenceI;\r
421 }} else {\r
422 this.createSequenceMapping (sequenceI, 1, true);\r
423 this.adjustForAlignment ();\r
424 }} else {\r
425 this.sequenceMapping = null;\r
426 this.sequenceRef = null;\r
427 }}, "jalview.datamodel.SequenceI");\r
428 Clazz.defineMethod (c$, "getScore", \r
429 function () {\r
430 return this.score;\r
431 });\r
432 Clazz.defineMethod (c$, "setScore", \r
433 function (score) {\r
434 this.$hasScore = true;\r
435 this.score = score;\r
436 }, "~N");\r
437 Clazz.defineMethod (c$, "hasScore", \r
438 function () {\r
439 return this.$hasScore || !Double.isNaN (this.score);\r
440 });\r
441 Clazz.makeConstructor (c$, \r
442 function (label, description, score) {\r
443 this.construct (label, description, null);\r
444 this.setScore (score);\r
445 }, "~S,~S,~N");\r
446 Clazz.makeConstructor (c$, \r
447 function (alignmentAnnotation, colSel) {\r
448 this.construct (alignmentAnnotation);\r
449 if (this.annotations == null) {\r
450 return;\r
451 }colSel.makeVisibleAnnotation (this);\r
452 }, "jalview.datamodel.AlignmentAnnotation,jalview.datamodel.ColumnSelection");\r
453 Clazz.defineMethod (c$, "setPadGaps", \r
454 function (padgaps, gapchar) {\r
455 this.padGaps = padgaps;\r
456 if (padgaps) {\r
457 this.hasText = true;\r
458 for (var i = 0; i < this.annotations.length; i++) {\r
459 if (this.annotations[i] == null) {\r
460 this.annotations[i] =  new jalview.datamodel.Annotation (String.valueOf (gapchar), null, ' ', 0, null);\r
461 } else if (this.annotations[i].displayCharacter == null || this.annotations[i].displayCharacter.equals (" ")) {\r
462 this.annotations[i].displayCharacter = String.valueOf (gapchar);\r
463 }}\r
464 }}, "~B,~S");\r
465 Clazz.defineMethod (c$, "getDescription", \r
466 function (seqname) {\r
467 if (seqname && this.sequenceRef != null) {\r
468 var i = this.description.toLowerCase ().indexOf ("<html>");\r
469 if (i > -1) {\r
470 return "<html>" + this.sequenceRef.getName () + " : " + this.description.substring (i + 6);\r
471 }return this.sequenceRef.getName () + " : " + this.description;\r
472 }return this.description;\r
473 }, "~B");\r
474 Clazz.defineMethod (c$, "isValidStruc", \r
475 function () {\r
476 return this.invalidrnastruc == -1;\r
477 });\r
478 Clazz.defineMethod (c$, "getInvalidStrucPos", \r
479 function () {\r
480 return this.invalidrnastruc;\r
481 });\r
482 Clazz.defineMethod (c$, "getCalcId", \r
483 function () {\r
484 return this.calcId;\r
485 });\r
486 Clazz.defineMethod (c$, "setCalcId", \r
487 function (calcId) {\r
488 this.calcId = calcId;\r
489 }, "~S");\r
490 Clazz.defineMethod (c$, "isRNA", \r
491 function () {\r
492 return this.isrna;\r
493 });\r
494 Clazz.defineMethod (c$, "liftOver", \r
495 function (sq, sp2sq) {\r
496 if (sp2sq.getMappedWidth () != sp2sq.getWidth ()) {\r
497 throw  new Error ("liftOver currently not implemented for transfer of annotation between different types of seqeunce");\r
498 }var mapIsTo = (sp2sq != null) ? (sp2sq.getTo () === sq || sp2sq.getTo () === sq.getDatasetSequence ()) : false;\r
499 var mapForsq =  new java.util.HashMap ();\r
500 if (this.sequenceMapping != null) {\r
501 if (sp2sq != null) {\r
502 for (var ie, $ie = this.sequenceMapping.entrySet ().iterator (); $ie.hasNext () && ((ie = $ie.next ()) || true);) {\r
503 var mpos = Integer.$valueOf (mapIsTo ? sp2sq.getMappedPosition ((ie.getKey ()).intValue ()) : sp2sq.getPosition ((ie.getKey ()).intValue ()));\r
504 if ((mpos).intValue () >= sq.getStart () && (mpos).intValue () <= sq.getEnd ()) {\r
505 mapForsq.put (mpos, ie.getValue ());\r
506 }}\r
507 this.sequenceMapping = mapForsq;\r
508 this.sequenceRef = sq;\r
509 this.adjustForAlignment ();\r
510 } else {\r
511 }}}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping");\r
512 Clazz.defineMethod (c$, "remap", \r
513 function (newref, mapping, from, to, idxoffset) {\r
514 if (mapping != null) {\r
515 var old = this.sequenceMapping;\r
516 var remap =  new java.util.HashMap ();\r
517 var index = -1;\r
518 for (var mp, $mp = 0, $$mp = mapping; $mp < $$mp.length && ((mp = $$mp[$mp]) || true); $mp++) {\r
519 if (index++ < 0) {\r
520 continue;\r
521 }var ann = null;\r
522 if (from == -1) {\r
523 ann = this.sequenceMapping.get (Integer.$valueOf (idxoffset + index));\r
524 } else {\r
525 if (mp != null && mp.length > from) {\r
526 ann = this.sequenceMapping.get (Integer.$valueOf (mp[from]));\r
527 }}if (ann != null) {\r
528 if (to == -1) {\r
529 remap.put (Integer.$valueOf (idxoffset + index), ann);\r
530 } else {\r
531 if (to > -1 && to < mp.length) {\r
532 remap.put (Integer.$valueOf (mp[to]), ann);\r
533 }}}}\r
534 this.sequenceMapping = remap;\r
535 old.clear ();\r
536 if (newref != null) {\r
537 this.sequenceRef = newref;\r
538 }this.adjustForAlignment ();\r
539 }}, "jalview.datamodel.SequenceI,~A,~N,~N,~N");\r
540 Clazz.defineMethod (c$, "getProperty", \r
541 function (property) {\r
542 if (this.properties == null) {\r
543 return null;\r
544 }return this.properties.get (property);\r
545 }, "~S");\r
546 Clazz.defineMethod (c$, "setProperty", \r
547 function (property, value) {\r
548 if (this.properties == null) {\r
549 this.properties =  new java.util.HashMap ();\r
550 }this.properties.put (property, value);\r
551 }, "~S,~S");\r
552 Clazz.defineMethod (c$, "hasProperties", \r
553 function () {\r
554 return this.properties != null && this.properties.size () > 0;\r
555 });\r
556 Clazz.defineMethod (c$, "getProperties", \r
557 function () {\r
558 if (this.properties == null) {\r
559 return java.util.Collections.emptyList ();\r
560 }return this.properties.keySet ();\r
561 });\r
562 Clazz.defineMethod (c$, "getAnnotationForPosition", \r
563 function (position) {\r
564 return this.sequenceMapping == null ? null : this.sequenceMapping.get (new Integer (position));\r
565 }, "~N");\r
566 Clazz.defineMethod (c$, "setAnnotationId", \r
567 function () {\r
568 this.annotationId = "ann" + Long.toString (jalview.datamodel.AlignmentAnnotation.nextId ());\r
569 });\r
570 c$.nextId = Clazz.defineMethod (c$, "nextId", \r
571 function () {\r
572 return jalview.datamodel.AlignmentAnnotation.counter++;\r
573 });\r
574 c$.$AlignmentAnnotation$AnnotCharSequence$ = function () {\r
575 Clazz.pu$h(self.c$);\r
576 c$ = Clazz.decorateAsClass (function () {\r
577 Clazz.prepareCallback (this, arguments);\r
578 this.offset = 0;\r
579 this.max = 0;\r
580 Clazz.instantialize (this, arguments);\r
581 }, jalview.datamodel.AlignmentAnnotation, "AnnotCharSequence", null, CharSequence);\r
582 Clazz.makeConstructor (c$, \r
583 function () {\r
584 this.construct (0, this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length);\r
585 });\r
586 Clazz.makeConstructor (c$, \r
587 function (a, b) {\r
588 this.offset = a;\r
589 this.max = b;\r
590 }, "~N,~N");\r
591 Clazz.overrideMethod (c$, "subSequence", \r
592 function (a, b) {\r
593 return Clazz.innerTypeInstance (jalview.datamodel.AlignmentAnnotation.AnnotCharSequence, this, null, this.offset + a, this.offset + b);\r
594 }, "~N,~N");\r
595 Clazz.overrideMethod (c$, "length", \r
596 function () {\r
597 return this.max - this.offset;\r
598 });\r
599 Clazz.overrideMethod (c$, "charAt", \r
600 function (a) {\r
601 return ((a + this.offset < 0) || (a + this.offset) >= this.max || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset] == null || (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure <= ' ') ? ' ' : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[a + this.offset].displayCharacter.charAt (0));\r
602 }, "~N");\r
603 Clazz.overrideMethod (c$, "toString", \r
604 function () {\r
605 var a =  Clazz.newCharArray (this.max - this.offset, '\0');\r
606 var b = this.b$["jalview.datamodel.AlignmentAnnotation"].annotations.length;\r
607 for (var c = this.offset; c < b; c++) {\r
608 a[c] = (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c] == null || ((this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure).charCodeAt (0) <= 32)) ? ' ' : (this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter == null || this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.length == 0 ? this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].secondaryStructure : this.b$["jalview.datamodel.AlignmentAnnotation"].annotations[c].displayCharacter.charAt (0));\r
609 }\r
610 return  String.instantialize (a);\r
611 });\r
612 c$ = Clazz.p0p ();\r
613 };\r
614 Clazz.defineStatics (c$,\r
615 "ANNOTATION_ID_PREFIX", "ann",\r
616 "SEQUENCE_PROFILE", 0,\r
617 "STRUCTURE_PROFILE", 1,\r
618 "CDNA_PROFILE", 2,\r
619 "counter", 0,\r
620 "NO_GRAPH", 0,\r
621 "BAR_GRAPH", 1,\r
622 "LINE_GRAPH", 2);\r
623 });\r