JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / datamodel / Sequence.js
1 Clazz.declarePackage ("jalview.datamodel");\r
2 Clazz.load (["jalview.datamodel.ASequence", "$.SequenceI", "jalview.jsdev.RegExp"], "jalview.datamodel.Sequence", ["jalview.analysis.AlignSeq", "jalview.datamodel.AlignmentAnnotation", "$.DBRefEntry", "$.DBRefSource", "$.PDBEntry", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "$.StringUtils", "java.lang.StringBuffer", "java.util.ArrayList", "$.Vector"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.datasetSequence = null;\r
5 this.name = null;\r
6 this.sequence = null;\r
7 this.description = null;\r
8 this.start = 0;\r
9 this.end = 0;\r
10 this.pdbIds = null;\r
11 this.vamsasId = null;\r
12 this.dbrefs = null;\r
13 this.rna = null;\r
14 this.annotation = null;\r
15 this.index = -1;\r
16 this.sequenceFeatures = null;\r
17 this.limitrx = null;\r
18 this.endrx = null;\r
19 Clazz.instantialize (this, arguments);\r
20 }, jalview.datamodel, "Sequence", jalview.datamodel.ASequence, jalview.datamodel.SequenceI);\r
21 Clazz.prepareFields (c$, function () {\r
22 this.limitrx = jalview.jsdev.RegExp.newRegex (["[/][0-9]{1,}[-][0-9]{1,}$"]);\r
23 this.endrx = jalview.jsdev.RegExp.newRegex (["[0-9]{1,}$"]);\r
24 });\r
25 Clazz.makeConstructor (c$, \r
26 function (name, sequence, start, end) {\r
27 Clazz.superConstructor (this, jalview.datamodel.Sequence, []);\r
28 this.initSeqAndName (name, sequence.toCharArray (), start, end);\r
29 }, "~S,~S,~N,~N");\r
30 Clazz.makeConstructor (c$, \r
31 function (name, sequence, start, end) {\r
32 Clazz.superConstructor (this, jalview.datamodel.Sequence, []);\r
33 this.initSeqAndName (name, sequence, start, end);\r
34 }, "~S,~A,~N,~N");\r
35 Clazz.defineMethod (c$, "initSeqAndName", \r
36 function (name2, sequence2, start2, end2) {\r
37 this.name = name2;\r
38 this.sequence = sequence2;\r
39 this.start = start2;\r
40 this.end = end2;\r
41 this.parseId ();\r
42 this.checkValidRange ();\r
43 }, "~S,~A,~N,~N");\r
44 Clazz.defineMethod (c$, "parseId", \r
45 function () {\r
46 if (this.name == null) {\r
47 System.err.println ("POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor.");\r
48 this.name = "";\r
49 }if (this.limitrx.search (this.name)) {\r
50 this.name = this.limitrx.left ();\r
51 this.endrx.search (this.limitrx.stringMatched ());\r
52 this.setStart (Integer.parseInt (this.limitrx.stringMatched ().substring (1, this.endrx.matchedFrom () - 1)));\r
53 this.setEnd (Integer.parseInt (this.endrx.stringMatched ()));\r
54 }});\r
55 Clazz.defineMethod (c$, "checkValidRange", \r
56 function () {\r
57 {\r
58 var endRes = 0;\r
59 for (var j = 0; j < this.sequence.length; j++) {\r
60 if (!jalview.util.Comparison.isGap (this.sequence[j])) {\r
61 endRes++;\r
62 }}\r
63 if (endRes > 0) {\r
64 endRes += this.start - 1;\r
65 }if (this.end < endRes) {\r
66 this.end = endRes;\r
67 }}});\r
68 Clazz.makeConstructor (c$, \r
69 function (name, sequence) {\r
70 this.construct (name, sequence, 1, -1);\r
71 }, "~S,~S");\r
72 Clazz.makeConstructor (c$, \r
73 function (seq) {\r
74 this.construct (seq, seq.getAnnotation ());\r
75 }, "jalview.datamodel.SequenceI");\r
76 Clazz.makeConstructor (c$, \r
77 function (seq, alAnnotation) {\r
78 Clazz.superConstructor (this, jalview.datamodel.Sequence, []);\r
79 this.initSeqFrom (seq, alAnnotation);\r
80 }, "jalview.datamodel.SequenceI,~A");\r
81 Clazz.defineMethod (c$, "initSeqFrom", \r
82 function (seq, alAnnotation) {\r
83 this.initSeqAndName (seq.getName (), seq.getSequence (), seq.getStart (), seq.getEnd ());\r
84 this.description = seq.getDescription ();\r
85 if (seq.getSequenceFeatures () != null) {\r
86 var sf = seq.getSequenceFeatures ();\r
87 for (var i = 0; i < sf.length; i++) {\r
88 this.addSequenceFeature ( new jalview.datamodel.SequenceFeature (sf[i]));\r
89 }\r
90 }this.setDatasetSequence (seq.getDatasetSequence ());\r
91 if (this.datasetSequence == null && seq.getDBRef () != null) {\r
92 var dbr = seq.getDBRef ();\r
93 for (var i = 0; i < dbr.length; i++) {\r
94 this.addDBRef ( new jalview.datamodel.DBRefEntry (dbr[i]));\r
95 }\r
96 }if (seq.getAnnotation () != null) {\r
97 var sqann = seq.getAnnotation ();\r
98 for (var i = 0; i < sqann.length; i++) {\r
99 if (sqann[i] == null) {\r
100 continue;\r
101 }var found = (alAnnotation == null);\r
102 if (!found) {\r
103 for (var apos = 0; !found && apos < alAnnotation.length; apos++) {\r
104 found = (alAnnotation[apos] === sqann[i]);\r
105 }\r
106 }if (found) {\r
107 var newann =  new jalview.datamodel.AlignmentAnnotation (sqann[i]);\r
108 this.addAlignmentAnnotation (newann);\r
109 }}\r
110 }if (seq.getPDBId () != null) {\r
111 var ids = seq.getPDBId ();\r
112 var e = ids.elements ();\r
113 while (e.hasMoreElements ()) {\r
114 this.addPDBId ( new jalview.datamodel.PDBEntry (e.nextElement ()));\r
115 }\r
116 }}, "jalview.datamodel.SequenceI,~A");\r
117 Clazz.defineMethod (c$, "setSequenceFeatures", \r
118 function (features) {\r
119 this.sequenceFeatures = features;\r
120 }, "~A");\r
121 Clazz.overrideMethod (c$, "addSequenceFeature", \r
122 function (sf) {\r
123 if (this.sequenceFeatures == null) {\r
124 this.sequenceFeatures =  new Array (0);\r
125 }for (var i = 0; i < this.sequenceFeatures.length; i++) {\r
126 if (this.sequenceFeatures[i].equals (sf)) {\r
127 return;\r
128 }}\r
129 var temp =  new Array (this.sequenceFeatures.length + 1);\r
130 System.arraycopy (this.sequenceFeatures, 0, temp, 0, this.sequenceFeatures.length);\r
131 temp[this.sequenceFeatures.length] = sf;\r
132 this.sequenceFeatures = temp;\r
133 }, "jalview.datamodel.SequenceFeature");\r
134 Clazz.overrideMethod (c$, "deleteFeature", \r
135 function (sf) {\r
136 if (this.sequenceFeatures == null) {\r
137 return;\r
138 }var index = 0;\r
139 for (index = 0; index < this.sequenceFeatures.length; index++) {\r
140 if (this.sequenceFeatures[index].equals (sf)) {\r
141 break;\r
142 }}\r
143 if (index == this.sequenceFeatures.length) {\r
144 return;\r
145 }var sfLength = this.sequenceFeatures.length;\r
146 if (sfLength < 2) {\r
147 this.sequenceFeatures = null;\r
148 } else {\r
149 var temp =  new Array (sfLength - 1);\r
150 System.arraycopy (this.sequenceFeatures, 0, temp, 0, index);\r
151 if (index < sfLength) {\r
152 System.arraycopy (this.sequenceFeatures, index + 1, temp, index, this.sequenceFeatures.length - index - 1);\r
153 }this.sequenceFeatures = temp;\r
154 }}, "jalview.datamodel.SequenceFeature");\r
155 Clazz.defineMethod (c$, "getSequenceFeatures", \r
156 function () {\r
157 var features = this.sequenceFeatures;\r
158 var seq = this;\r
159 var count = 0;\r
160 while (features == null && seq.getDatasetSequence () != null && count++ < 10) {\r
161 seq = seq.getDatasetSequence ();\r
162 features = (seq).sequenceFeatures;\r
163 }\r
164 return features;\r
165 });\r
166 Clazz.overrideMethod (c$, "addPDBId", \r
167 function (entry) {\r
168 if (this.pdbIds == null) {\r
169 this.pdbIds =  new java.util.Vector ();\r
170 }if (this.pdbIds.contains (entry)) {\r
171 jalview.datamodel.Sequence.updatePDBEntry (this.pdbIds.get (this.pdbIds.indexOf (entry)), entry);\r
172 } else {\r
173 this.pdbIds.addElement (entry);\r
174 }}, "jalview.datamodel.PDBEntry");\r
175 c$.updatePDBEntry = Clazz.defineMethod (c$, "updatePDBEntry", \r
176 ($fz = function (oldEntry, newEntry) {\r
177 if (newEntry.getFile () != null) {\r
178 oldEntry.setFile (newEntry.getFile ());\r
179 }}, $fz.isPrivate = true, $fz), "jalview.datamodel.PDBEntry,jalview.datamodel.PDBEntry");\r
180 Clazz.defineMethod (c$, "setPDBId", \r
181 function (id) {\r
182 this.pdbIds = id;\r
183 }, "java.util.Vector");\r
184 Clazz.defineMethod (c$, "getPDBId", \r
185 function () {\r
186 return this.pdbIds;\r
187 });\r
188 Clazz.overrideMethod (c$, "getDisplayId", \r
189 function (jvsuffix) {\r
190 var result =  new StringBuffer (this.name);\r
191 if (jvsuffix) {\r
192 result.append ("/" + this.start + "-" + this.end);\r
193 }return result.toString ();\r
194 }, "~B");\r
195 Clazz.overrideMethod (c$, "setName", \r
196 function (name) {\r
197 this.name = name;\r
198 this.parseId ();\r
199 }, "~S");\r
200 Clazz.defineMethod (c$, "getName", \r
201 function () {\r
202 return this.name;\r
203 });\r
204 Clazz.overrideMethod (c$, "setStart", \r
205 function (start) {\r
206 this.start = start;\r
207 }, "~N");\r
208 Clazz.defineMethod (c$, "getStart", \r
209 function () {\r
210 return this.start;\r
211 });\r
212 Clazz.overrideMethod (c$, "setEnd", \r
213 function (end) {\r
214 this.end = end;\r
215 }, "~N");\r
216 Clazz.defineMethod (c$, "getEnd", \r
217 function () {\r
218 return this.end;\r
219 });\r
220 Clazz.overrideMethod (c$, "getLength", \r
221 function () {\r
222 return this.sequence.length;\r
223 });\r
224 Clazz.defineMethod (c$, "setSequence", \r
225 function (seq) {\r
226 this.sequence = seq.toCharArray ();\r
227 this.checkValidRange ();\r
228 }, "~S");\r
229 Clazz.defineMethod (c$, "getSequenceAsString", \r
230 function () {\r
231 return  String.instantialize (this.sequence);\r
232 });\r
233 Clazz.defineMethod (c$, "getSequenceAsString", \r
234 function (start, end) {\r
235 return  String.instantialize (this.getSequence (start, end));\r
236 }, "~N,~N");\r
237 Clazz.defineMethod (c$, "getSequence", \r
238 function () {\r
239 return this.sequence;\r
240 });\r
241 Clazz.defineMethod (c$, "getSequence", \r
242 function (start, end) {\r
243 if (start < 0) {\r
244 start = 0;\r
245 }if (start >= this.sequence.length) {\r
246 return  Clazz.newCharArray (0, '\0');\r
247 }if (end >= this.sequence.length) {\r
248 end = this.sequence.length;\r
249 }var reply =  Clazz.newCharArray (end - start, '\0');\r
250 System.arraycopy (this.sequence, start, reply, 0, end - start);\r
251 return reply;\r
252 }, "~N,~N");\r
253 Clazz.overrideMethod (c$, "getSubSequence", \r
254 function (start, end) {\r
255 if (start < 0) {\r
256 start = 0;\r
257 }var seq = this.getSequence (start, end);\r
258 if (seq.length == 0) {\r
259 return null;\r
260 }var nstart = this.findPosition (start);\r
261 var nend = this.findPosition (end) - 1;\r
262 var nseq =  new jalview.datamodel.Sequence (this.getName (), seq, nstart, nend);\r
263 nseq.setDescription (this.description);\r
264 if (this.datasetSequence != null) {\r
265 nseq.setDatasetSequence (this.datasetSequence);\r
266 } else {\r
267 nseq.setDatasetSequence (this);\r
268 }return nseq;\r
269 }, "~N,~N");\r
270 Clazz.overrideMethod (c$, "getCharAt", \r
271 function (i) {\r
272 if (i < this.sequence.length) {\r
273 return this.sequence[i];\r
274 } else {\r
275 return ' ';\r
276 }}, "~N");\r
277 Clazz.defineMethod (c$, "setDescription", \r
278 function (desc) {\r
279 this.description = desc;\r
280 }, "~S");\r
281 Clazz.defineMethod (c$, "getDescription", \r
282 function () {\r
283 return this.description;\r
284 });\r
285 Clazz.overrideMethod (c$, "findIndex", \r
286 function (pos) {\r
287 var j = this.start;\r
288 var i = 0;\r
289 while ((i < this.sequence.length) && (j <= this.end) && (j <= pos)) {\r
290 if (!jalview.util.Comparison.isGap (this.sequence[i])) {\r
291 j++;\r
292 }i++;\r
293 }\r
294 if ((j == this.end) && (j < pos)) {\r
295 return this.end + 1;\r
296 } else {\r
297 return i;\r
298 }}, "~N");\r
299 Clazz.overrideMethod (c$, "findPosition", \r
300 function (i) {\r
301 var j = 0;\r
302 var pos = this.start;\r
303 var seqlen = this.sequence.length;\r
304 while ((j < i) && (j < seqlen)) {\r
305 if (!jalview.util.Comparison.isGap (this.sequence[j])) {\r
306 pos++;\r
307 }j++;\r
308 }\r
309 return pos;\r
310 }, "~N");\r
311 Clazz.overrideMethod (c$, "gapMap", \r
312 function () {\r
313 var seq = jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars,  String.instantialize (this.sequence));\r
314 var map =  Clazz.newIntArray (seq.length, 0);\r
315 var j = 0;\r
316 var p = 0;\r
317 while (j < this.sequence.length) {\r
318 if (!jalview.util.Comparison.isGap (this.sequence[j])) {\r
319 map[p++] = j;\r
320 }j++;\r
321 }\r
322 return map;\r
323 });\r
324 Clazz.overrideMethod (c$, "findPositionMap", \r
325 function () {\r
326 var map =  Clazz.newIntArray (this.sequence.length, 0);\r
327 var j = 0;\r
328 var pos = this.start;\r
329 var seqlen = this.sequence.length;\r
330 while ((j < seqlen)) {\r
331 map[j] = pos;\r
332 if (!jalview.util.Comparison.isGap (this.sequence[j])) {\r
333 pos++;\r
334 }j++;\r
335 }\r
336 return map;\r
337 });\r
338 Clazz.overrideMethod (c$, "getInsertions", \r
339 function () {\r
340 var map =  new java.util.ArrayList ();\r
341 var lastj = -1;\r
342 var j = 0;\r
343 var pos = this.start;\r
344 var seqlen = this.sequence.length;\r
345 while ((j < seqlen)) {\r
346 if (jalview.util.Comparison.isGap (this.sequence[j])) {\r
347 if (lastj == -1) {\r
348 lastj = j;\r
349 }} else {\r
350 if (lastj != -1) {\r
351 map.add ( Clazz.newIntArray (-1, [lastj, j - 1]));\r
352 lastj = -1;\r
353 }}j++;\r
354 }\r
355 if (lastj != -1) {\r
356 map.add ( Clazz.newIntArray (-1, [lastj, j - 1]));\r
357 lastj = -1;\r
358 }return map;\r
359 });\r
360 Clazz.overrideMethod (c$, "deleteChars", \r
361 function (i, j) {\r
362 var newstart = this.start;\r
363 var newend = this.end;\r
364 if (i >= this.sequence.length || i < 0) {\r
365 return;\r
366 }var tmp = jalview.util.StringUtils.deleteChars (this.sequence, i, j);\r
367 var createNewDs = false;\r
368 var eindex = -1;\r
369 var sindex = -1;\r
370 var ecalc = false;\r
371 var scalc = false;\r
372 for (var s = i; s < j; s++) {\r
373 if (jalview.schemes.ResidueProperties.aaIndex[this.sequence[s].charCodeAt (0)] != 23) {\r
374 if (createNewDs) {\r
375 newend--;\r
376 } else {\r
377 if (!scalc) {\r
378 sindex = this.findIndex (this.start) - 1;\r
379 scalc = true;\r
380 }if (sindex == s) {\r
381 newstart = this.findPosition (j);\r
382 break;\r
383 } else {\r
384 if (!ecalc) {\r
385 eindex = this.findIndex (this.end) - 1;\r
386 ecalc = true;\r
387 }if (eindex < j) {\r
388 newend = this.findPosition (i - 1);\r
389 break;\r
390 } else {\r
391 createNewDs = true;\r
392 newend--;\r
393 }}}}}\r
394 if (createNewDs && this.datasetSequence != null) {\r
395 var ds =  new jalview.datamodel.Sequence (this.datasetSequence);\r
396 ds.deleteChars (i, j);\r
397 this.datasetSequence = ds;\r
398 }this.start = newstart;\r
399 this.end = newend;\r
400 this.sequence = tmp;\r
401 }, "~N,~N");\r
402 Clazz.defineMethod (c$, "insertCharAt", \r
403 function (i, length, c) {\r
404 var tmp =  Clazz.newCharArray (this.sequence.length + length, '\0');\r
405 if (i >= this.sequence.length) {\r
406 System.arraycopy (this.sequence, 0, tmp, 0, this.sequence.length);\r
407 i = this.sequence.length;\r
408 } else {\r
409 System.arraycopy (this.sequence, 0, tmp, 0, i);\r
410 }var index = i;\r
411 while (length > 0) {\r
412 tmp[index++] = c;\r
413 length--;\r
414 }\r
415 if (i < this.sequence.length) {\r
416 System.arraycopy (this.sequence, i, tmp, index, this.sequence.length - i);\r
417 }this.sequence = tmp;\r
418 }, "~N,~N,~S");\r
419 Clazz.defineMethod (c$, "insertCharAt", \r
420 function (i, c) {\r
421 this.insertCharAt (i, 1, c);\r
422 }, "~N,~S");\r
423 Clazz.overrideMethod (c$, "getVamsasId", \r
424 function () {\r
425 return this.vamsasId;\r
426 });\r
427 Clazz.overrideMethod (c$, "setVamsasId", \r
428 function (id) {\r
429 this.vamsasId = id;\r
430 }, "~S");\r
431 Clazz.defineMethod (c$, "setDBRef", \r
432 function (dbref) {\r
433 this.dbrefs = dbref;\r
434 }, "~A");\r
435 Clazz.defineMethod (c$, "getDBRef", \r
436 function () {\r
437 if (this.dbrefs == null && this.datasetSequence != null && this !== this.datasetSequence) {\r
438 return this.datasetSequence.getDBRef ();\r
439 }return this.dbrefs;\r
440 });\r
441 Clazz.overrideMethod (c$, "addDBRef", \r
442 function (entry) {\r
443 if (this.dbrefs == null) {\r
444 this.dbrefs =  new Array (0);\r
445 }var i;\r
446 var iSize = this.dbrefs.length;\r
447 for (i = 0; i < iSize; i++) {\r
448 if (this.dbrefs[i].equalRef (entry)) {\r
449 if (entry.getMap () != null) {\r
450 if (this.dbrefs[i].getMap () == null) {\r
451 this.dbrefs[i] = entry;\r
452 }}return;\r
453 }}\r
454 var temp =  new Array (iSize + 1);\r
455 System.arraycopy (this.dbrefs, 0, temp, 0, iSize);\r
456 temp[temp.length - 1] = entry;\r
457 this.dbrefs = temp;\r
458 }, "jalview.datamodel.DBRefEntry");\r
459 Clazz.defineMethod (c$, "setDatasetSequence", \r
460 function (seq) {\r
461 this.datasetSequence = seq;\r
462 }, "jalview.datamodel.SequenceI");\r
463 Clazz.defineMethod (c$, "getDatasetSequence", \r
464 function () {\r
465 return this.datasetSequence;\r
466 });\r
467 Clazz.defineMethod (c$, "getAnnotation", \r
468 function () {\r
469 return this.annotation == null ? null : this.annotation.toArray ( new Array (this.annotation.size ()));\r
470 });\r
471 Clazz.overrideMethod (c$, "hasAnnotation", \r
472 function (ann) {\r
473 return this.annotation == null ? false : this.annotation.contains (ann);\r
474 }, "jalview.datamodel.AlignmentAnnotation");\r
475 Clazz.defineMethod (c$, "addAlignmentAnnotation", \r
476 function (annotation) {\r
477 if (this.annotation == null) {\r
478 this.annotation =  new java.util.Vector ();\r
479 }if (!this.annotation.contains (annotation)) {\r
480 this.annotation.addElement (annotation);\r
481 }annotation.setSequenceRef (this);\r
482 }, "jalview.datamodel.AlignmentAnnotation");\r
483 Clazz.overrideMethod (c$, "removeAlignmentAnnotation", \r
484 function (annotation) {\r
485 if (this.annotation != null) {\r
486 this.annotation.removeElement (annotation);\r
487 if (this.annotation.size () == 0) {\r
488 this.annotation = null;\r
489 }}}, "jalview.datamodel.AlignmentAnnotation");\r
490 Clazz.defineMethod (c$, "isValidDatasetSequence", \r
491 ($fz = function () {\r
492 if (this.datasetSequence != null) {\r
493 return false;\r
494 }for (var i = 0; i < this.sequence.length; i++) {\r
495 if (jalview.util.Comparison.isGap (this.sequence[i])) {\r
496 return false;\r
497 }}\r
498 return true;\r
499 }, $fz.isPrivate = true, $fz));\r
500 Clazz.overrideMethod (c$, "deriveSequence", \r
501 function () {\r
502 var seq =  new jalview.datamodel.Sequence (this);\r
503 if (this.datasetSequence != null) {\r
504 seq.setDatasetSequence (this.datasetSequence);\r
505 } else {\r
506 if (this.isValidDatasetSequence ()) {\r
507 seq.setDatasetSequence (this);\r
508 } else {\r
509 var ds = seq;\r
510 ds.setSequence (jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars,  String.instantialize (this.sequence)));\r
511 this.setDatasetSequence (ds);\r
512 ds.setSequenceFeatures (this.getSequenceFeatures ());\r
513 seq = this;\r
514 }}return seq;\r
515 });\r
516 Clazz.overrideMethod (c$, "createDatasetSequence", \r
517 function () {\r
518 if (this.datasetSequence == null) {\r
519 this.datasetSequence =  new jalview.datamodel.Sequence (this.getName (), jalview.analysis.AlignSeq.extractGaps (jalview.util.Comparison.GapChars, this.getSequenceAsString ()), this.getStart (), this.getEnd ());\r
520 this.datasetSequence.setSequenceFeatures (this.getSequenceFeatures ());\r
521 this.datasetSequence.setDescription (this.getDescription ());\r
522 this.setSequenceFeatures (null);\r
523 this.datasetSequence.setDBRef (this.getDBRef ());\r
524 this.setDBRef (null);\r
525 this.datasetSequence.setPDBId (this.getPDBId ());\r
526 this.setPDBId (null);\r
527 this.datasetSequence.updatePDBIds ();\r
528 if (this.annotation != null) {\r
529 for (var aa, $aa = this.annotation.iterator (); $aa.hasNext () && ((aa = $aa.next ()) || true);) {\r
530 var _aa =  new jalview.datamodel.AlignmentAnnotation (aa);\r
531 _aa.sequenceRef = this.datasetSequence;\r
532 _aa.adjustForAlignment ();\r
533 this.datasetSequence.addAlignmentAnnotation (_aa);\r
534 }\r
535 }}return this.datasetSequence;\r
536 });\r
537 Clazz.overrideMethod (c$, "setAlignmentAnnotation", \r
538 function (annotations) {\r
539 if (this.annotation != null) {\r
540 this.annotation.removeAllElements ();\r
541 }if (annotations != null) {\r
542 for (var i = 0; i < annotations.length; i++) {\r
543 if (annotations[i] != null) {\r
544 this.addAlignmentAnnotation (annotations[i]);\r
545 }}\r
546 }}, "~A");\r
547 Clazz.defineMethod (c$, "getAnnotation", \r
548 function (label) {\r
549 if (this.annotation == null || this.annotation.size () == 0) {\r
550 return null;\r
551 }var subset =  new java.util.Vector ();\r
552 var e = this.annotation.elements ();\r
553 while (e.hasMoreElements ()) {\r
554 var ann = e.nextElement ();\r
555 if (ann.label != null && ann.label.equals (label)) {\r
556 subset.addElement (ann);\r
557 }}\r
558 if (subset.size () == 0) {\r
559 return null;\r
560 }var anns =  new Array (subset.size ());\r
561 var i = 0;\r
562 e = subset.elements ();\r
563 while (e.hasMoreElements ()) {\r
564 anns[i++] = e.nextElement ();\r
565 }\r
566 subset.removeAllElements ();\r
567 return anns;\r
568 }, "~S");\r
569 Clazz.defineMethod (c$, "updatePDBIds", \r
570 function () {\r
571 if (this.datasetSequence != null) {\r
572 return this.datasetSequence.updatePDBIds ();\r
573 }if (this.dbrefs == null || this.dbrefs.length == 0) {\r
574 return false;\r
575 }var newpdb =  new java.util.Vector ();\r
576 for (var i = 0; i < this.dbrefs.length; i++) {\r
577 if (jalview.datamodel.DBRefSource.PDB.equals (this.dbrefs[i].getSource ())) {\r
578 var pdbe =  new jalview.datamodel.PDBEntry ();\r
579 pdbe.setId (this.dbrefs[i].getAccessionId ());\r
580 if (this.pdbIds == null || this.pdbIds.size () == 0) {\r
581 newpdb.addElement (pdbe);\r
582 } else {\r
583 var en = this.pdbIds.elements ();\r
584 var matched = false;\r
585 while (!matched && en.hasMoreElements ()) {\r
586 var anentry = en.nextElement ();\r
587 if (anentry.getId ().equals (pdbe.getId ())) {\r
588 matched = true;\r
589 }}\r
590 if (!matched) {\r
591 newpdb.addElement (pdbe);\r
592 }}}}\r
593 if (newpdb.size () > 0) {\r
594 var en = newpdb.elements ();\r
595 while (en.hasMoreElements ()) {\r
596 this.addPDBId (en.nextElement ());\r
597 }\r
598 return true;\r
599 }return false;\r
600 });\r
601 Clazz.defineMethod (c$, "transferAnnotation", \r
602 function (entry, mp) {\r
603 if (this.datasetSequence != null) {\r
604 this.datasetSequence.transferAnnotation (entry, mp);\r
605 return;\r
606 }if (entry.getDatasetSequence () != null) {\r
607 this.transferAnnotation (entry.getDatasetSequence (), mp);\r
608 return;\r
609 }if (entry.getSequenceFeatures () != null) {\r
610 var sfs = entry.getSequenceFeatures ();\r
611 for (var si = 0; si < sfs.length; si++) {\r
612 var sf = (mp != null) ? mp.locateFeature (sfs[si]) :  Clazz.newArray (-1, [ new jalview.datamodel.SequenceFeature (sfs[si])]);\r
613 if (sf != null && sf.length > 0) {\r
614 for (var sfi = 0; sfi < sf.length; sfi++) {\r
615 this.addSequenceFeature (sf[sfi]);\r
616 }\r
617 }}\r
618 }if (entry.getPDBId () != null) {\r
619 var e = entry.getPDBId ().elements ();\r
620 while (e.hasMoreElements ()) {\r
621 var pdb = e.nextElement ();\r
622 this.addPDBId (pdb);\r
623 }\r
624 }var entryRefs = entry.getDBRef ();\r
625 if (entryRefs != null) {\r
626 for (var r = 0; r < entryRefs.length; r++) {\r
627 var newref =  new jalview.datamodel.DBRefEntry (entryRefs[r]);\r
628 if (newref.getMap () != null && mp != null) {\r
629 }this.addDBRef (newref);\r
630 }\r
631 }}, "jalview.datamodel.SequenceI,jalview.datamodel.Mapping");\r
632 Clazz.overrideMethod (c$, "getIndex", \r
633 function () {\r
634 return this.index;\r
635 });\r
636 Clazz.overrideMethod (c$, "setIndex", \r
637 function (value) {\r
638 this.index = value;\r
639 }, "~N");\r
640 Clazz.overrideMethod (c$, "setRNA", \r
641 function (r) {\r
642 this.rna = r;\r
643 }, "jalview.jsdev.api.VarnaRNA");\r
644 Clazz.overrideMethod (c$, "getRNA", \r
645 function () {\r
646 return this.rna;\r
647 });\r
648 Clazz.overrideMethod (c$, "getAlignmentAnnotations", \r
649 function (calcId, label) {\r
650 var result =  new java.util.ArrayList ();\r
651 if (this.annotation != null) {\r
652 for (var ann, $ann = this.annotation.iterator (); $ann.hasNext () && ((ann = $ann.next ()) || true);) {\r
653 if (ann.calcId != null && ann.calcId.equals (calcId) && ann.label != null && ann.label.equals (label)) {\r
654 result.add (ann);\r
655 }}\r
656 }return result;\r
657 }, "~S,~S");\r
658 });\r