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