1 Clazz.declarePackage ("jalview.datamodel");
\r
2 Clazz.load (["jalview.datamodel.AnnotatedCollectionI", "java.awt.Color", "java.util.ArrayList"], "jalview.datamodel.SequenceGroup", ["jalview.analysis.AAFrequency", "$.Conservation", "jalview.datamodel.AlignmentAnnotation", "$.Sequence", "jalview.schemes.ResidueProperties", "jalview.util.Comparison", "java.lang.StringBuffer"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.groupName = null;
\r
5 this.description = null;
\r
6 this.conserve = null;
\r
7 this.aaFrequency = null;
\r
8 this.displayBoxes = true;
\r
9 this.displayText = true;
\r
10 this.colourText = false;
\r
11 this.showNonconserved = false;
\r
12 this.sequences = null;
\r
18 this.outlineColour = null;
\r
19 this.idColour = null;
\r
20 this.thresholdTextColour = 0;
\r
21 this.textColour = null;
\r
22 this.textColour2 = null;
\r
23 this.ignoreGapsInConsensus = true;
\r
24 this.showSequenceLogo = false;
\r
25 this.normaliseSequenceLogo = false;
\r
26 this.consPercGaps = 25;
\r
27 this.consensusData = null;
\r
28 this.hidereps = false;
\r
29 this.hidecols = false;
\r
30 this.consensus = null;
\r
31 this.conservation = null;
\r
32 this.showConsensusHistogram = false;
\r
33 this.context = null;
\r
34 Clazz.instantialize (this, arguments);
\r
35 }, jalview.datamodel, "SequenceGroup", null, jalview.datamodel.AnnotatedCollectionI);
\r
36 Clazz.prepareFields (c$, function () {
\r
37 this.sequences = new java.util.ArrayList ();
\r
38 this.outlineColour = java.awt.Color.black;
\r
39 this.textColour = java.awt.Color.black;
\r
40 this.textColour2 = java.awt.Color.white;
\r
42 Clazz.defineMethod (c$, "isShowSequenceLogo",
\r
44 return this.showSequenceLogo;
\r
46 Clazz.makeConstructor (c$,
\r
48 this.groupName = "JGroup:" + this.hashCode ();
\r
50 Clazz.makeConstructor (c$,
\r
51 function (sequences, groupName, scheme, displayBoxes, displayText, colourText, start, end) {
\r
52 this.sequences = sequences;
\r
53 this.groupName = groupName;
\r
54 this.displayBoxes = displayBoxes;
\r
55 this.displayText = displayText;
\r
56 this.colourText = colourText;
\r
58 this.startRes = start;
\r
60 this.recalcConservation ();
\r
61 }, "java.util.List,~S,jalview.schemes.ColourSchemeI,~B,~B,~B,~N,~N");
\r
62 Clazz.makeConstructor (c$,
\r
64 if (seqsel != null) {
\r
65 this.sequences = new java.util.ArrayList ();
\r
66 this.sequences.addAll (seqsel.sequences);
\r
67 if (seqsel.groupName != null) {
\r
68 this.groupName = String.instantialize (seqsel.groupName);
\r
69 }this.displayBoxes = seqsel.displayBoxes;
\r
70 this.displayText = seqsel.displayText;
\r
71 this.colourText = seqsel.colourText;
\r
72 this.startRes = seqsel.startRes;
\r
73 this.endRes = seqsel.endRes;
\r
74 this.cs = seqsel.cs;
\r
75 if (seqsel.description != null) {
\r
76 this.description = String.instantialize (seqsel.description);
\r
77 }this.hidecols = seqsel.hidecols;
\r
78 this.hidereps = seqsel.hidereps;
\r
79 this.idColour = seqsel.idColour;
\r
80 this.outlineColour = seqsel.outlineColour;
\r
81 this.seqrep = seqsel.seqrep;
\r
82 this.textColour = seqsel.textColour;
\r
83 this.textColour2 = seqsel.textColour2;
\r
84 this.thresholdTextColour = seqsel.thresholdTextColour;
\r
85 this.width = seqsel.width;
\r
86 this.ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
\r
87 if (seqsel.conserve != null) {
\r
88 this.recalcConservation ();
\r
89 }}}, "jalview.datamodel.SequenceGroup");
\r
90 Clazz.defineMethod (c$, "getSelectionAsNewSequences",
\r
92 var iSize = this.sequences.size ();
\r
93 var seqs = new Array (iSize);
\r
94 var inorder = this.getSequencesInOrder (align);
\r
95 for (var i = 0, ipos = 0; i < inorder.length; i++) {
\r
96 var seq = inorder[i];
\r
97 seqs[ipos] = seq.getSubSequence (this.startRes, this.endRes + 1);
\r
98 if (seqs[ipos] != null) {
\r
99 seqs[ipos].setDescription (seq.getDescription ());
\r
100 seqs[ipos].setDBRef (seq.getDBRef ());
\r
101 seqs[ipos].setSequenceFeatures (seq.getSequenceFeatures ());
\r
102 if (seq.getDatasetSequence () != null) {
\r
103 seqs[ipos].setDatasetSequence (seq.getDatasetSequence ());
\r
104 }if (seq.getAnnotation () != null) {
\r
105 var alann = align.getAlignmentAnnotation ();
\r
106 for (var a = 0; a < seq.getAnnotation ().length; a++) {
\r
107 var tocopy = seq.getAnnotation ()[a];
\r
108 if (alann != null) {
\r
110 for (var pos = 0; pos < alann.length; pos++) {
\r
111 if (alann[pos] === tocopy) {
\r
117 }}var newannot = new jalview.datamodel.AlignmentAnnotation (seq.getAnnotation ()[a]);
\r
118 newannot.restrict (this.startRes, this.endRes);
\r
119 newannot.setSequenceRef (seqs[ipos]);
\r
120 newannot.adjustForAlignment ();
\r
121 seqs[ipos].addAlignmentAnnotation (newannot);
\r
127 if (iSize != inorder.length) {
\r
128 var nseqs = new Array (iSize);
\r
129 System.arraycopy (seqs, 0, nseqs, 0, iSize);
\r
132 }, "jalview.datamodel.AlignmentI");
\r
133 Clazz.defineMethod (c$, "findEndRes",
\r
137 for (var j = 0; j < this.endRes + 1 && j < seq.getLength (); j++) {
\r
138 ch = seq.getCharAt (j);
\r
139 if (!jalview.util.Comparison.isGap ((ch))) {
\r
143 eres += seq.getStart () - 1;
\r
145 }, "jalview.datamodel.SequenceI");
\r
146 Clazz.defineMethod (c$, "getSequences",
\r
148 return this.sequences;
\r
150 Clazz.defineMethod (c$, "getSequences",
\r
151 function (hiddenReps) {
\r
152 if (hiddenReps == null) {
\r
153 return this.sequences;
\r
155 var allSequences = new java.util.ArrayList ();
\r
156 for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
\r
157 allSequences.add (seq);
\r
158 if (hiddenReps.containsKey (seq)) {
\r
159 var hsg = hiddenReps.get (seq);
\r
160 for (var seq2, $seq2 = hsg.getSequences ().iterator (); $seq2.hasNext () && ((seq2 = $seq2.next ()) || true);) {
\r
161 if (seq2 !== seq && !allSequences.contains (seq2)) {
\r
162 allSequences.add (seq2);
\r
165 return allSequences;
\r
166 }}, "java.util.Map");
\r
167 Clazz.defineMethod (c$, "getSequencesAsArray",
\r
169 var tmp = this.getSequences (map);
\r
172 }return tmp.toArray ( new Array (tmp.size ()));
\r
173 }, "java.util.Map");
\r
174 Clazz.defineMethod (c$, "adjustForRemoveLeft",
\r
176 if (this.startRes >= col) {
\r
177 this.startRes = this.startRes - col;
\r
178 }if (this.endRes >= col) {
\r
179 this.endRes = this.endRes - col;
\r
180 if (this.startRes > this.endRes) {
\r
186 Clazz.defineMethod (c$, "adjustForRemoveRight",
\r
188 if (this.startRes > col) {
\r
190 }if (this.endRes >= col) {
\r
194 Clazz.defineMethod (c$, "getName",
\r
196 return this.groupName;
\r
198 Clazz.defineMethod (c$, "getDescription",
\r
200 return this.description;
\r
202 Clazz.defineMethod (c$, "setName",
\r
204 this.groupName = name;
\r
206 Clazz.defineMethod (c$, "setDescription",
\r
208 this.description = desc;
\r
210 Clazz.defineMethod (c$, "getConservation",
\r
212 return this.conserve;
\r
214 Clazz.defineMethod (c$, "setConservation",
\r
217 }, "jalview.analysis.Conservation");
\r
218 Clazz.defineMethod (c$, "addSequence",
\r
219 function (s, recalc) {
\r
221 if (s != null && !this.sequences.contains (s)) {
\r
222 this.sequences.add (s);
\r
224 this.recalcConservation ();
\r
225 }}}, "jalview.datamodel.SequenceI,~B");
\r
226 Clazz.defineMethod (c$, "getConsPercGaps",
\r
228 return this.consPercGaps;
\r
230 Clazz.defineMethod (c$, "setConsPercGaps",
\r
231 function (consPercGaps) {
\r
232 this.consPercGaps = consPercGaps;
\r
234 Clazz.defineMethod (c$, "recalcConservation",
\r
236 if (this.cs == null && this.consensus == null && this.conservation == null) {
\r
239 var cnsns = jalview.analysis.AAFrequency.calculate (this.sequences, this.startRes, this.endRes + 1, this.showSequenceLogo);
\r
240 if (this.consensus != null) {
\r
241 this._updateConsensusRow (cnsns, this.sequences.size ());
\r
242 }if (this.cs != null) {
\r
243 this.cs.setConsensus (cnsns);
\r
244 }if ((this.conservation != null) || (this.cs != null && this.cs.conservationApplied ())) {
\r
245 var c = new jalview.analysis.Conservation (this.groupName, jalview.schemes.ResidueProperties.propHash, 3, this.sequences, this.startRes, this.endRes + 1);
\r
247 c.verdict (false, this.consPercGaps);
\r
248 if (this.conservation != null) {
\r
249 this._updateConservationRow (c);
\r
250 }if (this.cs != null) {
\r
251 if (this.cs.conservationApplied ()) {
\r
252 this.cs.setConservation (c);
\r
253 }}}if (this.cs != null) {
\r
254 this.cs.alignmentChanged (this.context != null ? this.context : this, null);
\r
256 if (Clazz.exceptionOf (err, OutOfMemoryError)) {
\r
257 System.out.println ("Out of memory loading groups: " + err);
\r
263 Clazz.defineMethod (c$, "_updateConservationRow",
\r
264 ($fz = function (c) {
\r
265 if (this.conservation == null) {
\r
266 this.getConservation ();
\r
267 }this.conservation.label = "Conservation for " + this.getName ();
\r
268 this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps";
\r
269 var aWidth = (this.conservation.annotations != null) ? (this.endRes < this.conservation.annotations.length ? this.conservation.annotations.length : this.endRes + 1) : this.endRes + 1;
\r
270 this.conservation.annotations = null;
\r
271 this.conservation.annotations = new Array (aWidth);
\r
272 c.completeAnnotations (this.conservation, null, this.startRes, this.endRes + 1);
\r
273 }, $fz.isPrivate = true, $fz), "jalview.analysis.Conservation");
\r
274 Clazz.defineMethod (c$, "_updateConsensusRow",
\r
275 ($fz = function (cnsns, nseq) {
\r
276 if (this.consensus == null) {
\r
277 this.getConsensus ();
\r
278 }this.consensus.label = "Consensus for " + this.getName ();
\r
279 this.consensus.description = "Percent Identity";
\r
280 this.consensusData = cnsns;
\r
281 var aWidth = (this.consensus.annotations != null) ? (this.endRes < this.consensus.annotations.length ? this.consensus.annotations.length : this.endRes + 1) : this.endRes + 1;
\r
282 this.consensus.annotations = null;
\r
283 this.consensus.annotations = new Array (aWidth);
\r
284 jalview.analysis.AAFrequency.completeConsensus (this.consensus, cnsns, this.startRes, this.endRes + 1, this.ignoreGapsInConsensus, this.showSequenceLogo, nseq);
\r
285 }, $fz.isPrivate = true, $fz), "~A,~N");
\r
286 Clazz.defineMethod (c$, "addOrRemove",
\r
287 function (s, recalc) {
\r
289 if (this.sequences.contains (s)) {
\r
290 this.deleteSequence (s, recalc);
\r
292 this.addSequence (s, recalc);
\r
293 }}}, "jalview.datamodel.SequenceI,~B");
\r
294 Clazz.defineMethod (c$, "deleteSequence",
\r
295 function (s, recalc) {
\r
297 this.sequences.remove (s);
\r
299 this.recalcConservation ();
\r
300 }}}, "jalview.datamodel.SequenceI,~B");
\r
301 Clazz.overrideMethod (c$, "getStartRes",
\r
303 return this.startRes;
\r
305 Clazz.overrideMethod (c$, "getEndRes",
\r
307 return this.endRes;
\r
309 Clazz.defineMethod (c$, "setStartRes",
\r
313 Clazz.defineMethod (c$, "setEndRes",
\r
317 Clazz.defineMethod (c$, "getSize",
\r
319 return this.sequences.size ();
\r
321 Clazz.defineMethod (c$, "getSequenceAt",
\r
323 return this.sequences.get (i);
\r
325 Clazz.defineMethod (c$, "setColourText",
\r
327 this.colourText = state;
\r
329 Clazz.defineMethod (c$, "getColourText",
\r
331 return this.colourText;
\r
333 Clazz.defineMethod (c$, "setDisplayText",
\r
335 this.displayText = state;
\r
337 Clazz.defineMethod (c$, "getDisplayText",
\r
339 return this.displayText;
\r
341 Clazz.defineMethod (c$, "setDisplayBoxes",
\r
343 this.displayBoxes = state;
\r
345 Clazz.defineMethod (c$, "getDisplayBoxes",
\r
347 return this.displayBoxes;
\r
349 Clazz.overrideMethod (c$, "getWidth",
\r
353 for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
\r
354 if (first || seq.getLength () > this.width) {
\r
355 this.width = seq.getLength ();
\r
360 Clazz.defineMethod (c$, "setOutlineColour",
\r
362 this.outlineColour = c;
\r
363 }, "java.awt.Color");
\r
364 Clazz.defineMethod (c$, "getOutlineColour",
\r
366 return this.outlineColour;
\r
368 Clazz.defineMethod (c$, "getSequencesInOrder",
\r
370 return this.getSequencesInOrder (al, true);
\r
371 }, "jalview.datamodel.AlignmentI");
\r
372 Clazz.defineMethod (c$, "getSequencesInOrder",
\r
373 function (al, trim) {
\r
375 var sSize = this.sequences.size ();
\r
376 var alHeight = al.getHeight ();
\r
377 var seqs = new Array ((trim) ? sSize : alHeight);
\r
379 for (var i = 0; i < alHeight && index < sSize; i++) {
\r
380 if (this.sequences.contains (al.getSequenceAt (i))) {
\r
381 seqs[(trim) ? index : i] = al.getSequenceAt (i);
\r
388 }if (index < seqs.length) {
\r
390 seqs = new Array (index);
\r
391 while (--index >= 0) {
\r
392 seqs[index] = dummy[index];
\r
393 dummy[index] = null;
\r
396 }}, "jalview.datamodel.AlignmentI,~B");
\r
397 Clazz.defineMethod (c$, "getIdColour",
\r
399 return this.idColour;
\r
401 Clazz.defineMethod (c$, "setIdColour",
\r
402 function (idColour) {
\r
403 this.idColour = idColour;
\r
404 }, "java.awt.Color");
\r
405 Clazz.overrideMethod (c$, "getSeqrep",
\r
407 return this.seqrep;
\r
409 Clazz.overrideMethod (c$, "setSeqrep",
\r
410 function (seqrep) {
\r
411 this.seqrep = seqrep;
\r
412 }, "jalview.datamodel.SequenceI");
\r
413 Clazz.overrideMethod (c$, "hasSeqrep",
\r
415 return this.seqrep != null;
\r
417 Clazz.defineMethod (c$, "setHidereps",
\r
418 function (visibility) {
\r
419 this.hidereps = visibility;
\r
421 Clazz.defineMethod (c$, "isHidereps",
\r
423 return this.hidereps;
\r
425 Clazz.defineMethod (c$, "setHideCols",
\r
426 function (visibility) {
\r
427 this.hidecols = visibility;
\r
429 Clazz.defineMethod (c$, "isHideCols",
\r
431 return this.hidecols;
\r
433 Clazz.defineMethod (c$, "intersect",
\r
434 function (alignment, map) {
\r
435 var sgroup = new jalview.datamodel.SequenceGroup (this);
\r
436 var insect = this.getSequencesInOrder (alignment);
\r
437 sgroup.sequences = new java.util.ArrayList ();
\r
438 for (var s = 0; insect != null && s < insect.length; s++) {
\r
439 if (map == null || map.containsKey (insect[s])) {
\r
440 sgroup.sequences.add (insect[s]);
\r
443 }, "jalview.datamodel.AlignmentI,java.util.Map");
\r
444 Clazz.defineMethod (c$, "getShowNonconserved",
\r
446 return this.showNonconserved;
\r
448 Clazz.defineMethod (c$, "setShowNonconserved",
\r
449 function (displayNonconserved) {
\r
450 this.showNonconserved = displayNonconserved;
\r
452 Clazz.defineMethod (c$, "setConsensus",
\r
454 if (this.consensus == null) {
\r
455 this.consensus = aan;
\r
456 }}, "jalview.datamodel.AlignmentAnnotation");
\r
457 Clazz.defineMethod (c$, "getConsensus",
\r
459 var aWidth = this.getWidth ();
\r
462 }if (this.consensus == null) {
\r
463 this.consensus = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 100, 1);
\r
464 this.consensus.hasText = true;
\r
465 this.consensus.autoCalculated = true;
\r
466 this.consensus.groupRef = this;
\r
467 this.consensus.label = "Consensus for " + this.getName ();
\r
468 this.consensus.description = "Percent Identity";
\r
469 }return this.consensus;
\r
471 Clazz.defineMethod (c$, "setConservationRow",
\r
473 if (this.conservation == null) {
\r
474 this.conservation = aan;
\r
475 }}, "jalview.datamodel.AlignmentAnnotation");
\r
476 Clazz.defineMethod (c$, "getConservationRow",
\r
478 if (this.conservation == null) {
\r
479 this.conservation = new jalview.datamodel.AlignmentAnnotation ("", "", new Array (1), 0, 11, 1);
\r
480 }this.conservation.hasText = true;
\r
481 this.conservation.autoCalculated = true;
\r
482 this.conservation.groupRef = this;
\r
483 this.conservation.label = "Conservation for " + this.getName ();
\r
484 this.conservation.description = "Conservation for group " + this.getName () + " less than " + this.consPercGaps + "% gaps";
\r
485 return this.conservation;
\r
487 Clazz.defineMethod (c$, "hasAnnotationRows",
\r
489 return this.consensus != null || this.conservation != null;
\r
491 Clazz.defineMethod (c$, "getConsensusSeq",
\r
493 this.getConsensus ();
\r
494 var seqs = new StringBuffer ();
\r
495 for (var i = 0; i < this.consensus.annotations.length; i++) {
\r
496 if (this.consensus.annotations[i] != null) {
\r
497 if (this.consensus.annotations[i].description.charAt (0) == '[') {
\r
498 seqs.append (this.consensus.annotations[i].description.charAt (1));
\r
500 seqs.append (this.consensus.annotations[i].displayCharacter);
\r
502 var sq = new jalview.datamodel.Sequence ("Group" + this.getName () + " Consensus", seqs.toString ());
\r
503 sq.setDescription ("Percentage Identity Consensus " + ((this.ignoreGapsInConsensus) ? " without gaps" : ""));
\r
506 Clazz.defineMethod (c$, "setIgnoreGapsConsensus",
\r
508 if (this.ignoreGapsInConsensus != state && this.consensus != null) {
\r
509 this.ignoreGapsInConsensus = state;
\r
510 this.recalcConservation ();
\r
511 }this.ignoreGapsInConsensus = state;
\r
513 Clazz.defineMethod (c$, "getIgnoreGapsConsensus",
\r
515 return this.ignoreGapsInConsensus;
\r
517 Clazz.defineMethod (c$, "setshowSequenceLogo",
\r
518 function (showSequenceLogo) {
\r
519 if (this.showSequenceLogo != showSequenceLogo && this.consensus != null) {
\r
520 this.showSequenceLogo = showSequenceLogo;
\r
521 this.recalcConservation ();
\r
522 }this.showSequenceLogo = showSequenceLogo;
\r
524 Clazz.defineMethod (c$, "setShowConsensusHistogram",
\r
525 function (showConsHist) {
\r
526 if (this.showConsensusHistogram != showConsHist && this.consensus != null) {
\r
527 this.showConsensusHistogram = showConsHist;
\r
528 this.recalcConservation ();
\r
529 }this.showConsensusHistogram = showConsHist;
\r
531 Clazz.defineMethod (c$, "isShowConsensusHistogram",
\r
533 return this.showConsensusHistogram;
\r
535 Clazz.defineMethod (c$, "setNormaliseSequenceLogo",
\r
537 this.normaliseSequenceLogo = norm;
\r
539 Clazz.defineMethod (c$, "isNormaliseSequenceLogo",
\r
541 return this.normaliseSequenceLogo;
\r
543 Clazz.overrideMethod (c$, "getAlignmentAnnotation",
\r
545 var annot = new java.util.ArrayList ();
\r
547 for (var seq, $seq = this.sequences.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
\r
548 var aa = seq.getAnnotation ();
\r
550 for (var al, $al = 0, $$al = aa; $al < $$al.length && ((al = $$al[$al]) || true); $al++) {
\r
551 if (al.groupRef === this) {
\r
555 if (this.consensus != null) {
\r
556 annot.add (this.consensus);
\r
557 }if (this.conservation != null) {
\r
558 annot.add (this.conservation);
\r
559 }}return annot.toArray ( new Array (0));
\r
561 Clazz.overrideMethod (c$, "findAnnotation",
\r
562 function (calcId) {
\r
563 var aa = new java.util.ArrayList ();
\r
564 for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) {
\r
565 if (a.getCalcId () === calcId) {
\r
570 Clazz.overrideMethod (c$, "findAnnotations",
\r
571 function (seq, calcId, label) {
\r
572 var aa = new java.util.ArrayList ();
\r
573 for (var ann, $ann = 0, $$ann = this.getAlignmentAnnotation (); $ann < $$ann.length && ((ann = $$ann[$ann]) || true); $ann++) {
\r
574 if (ann.getCalcId () != null && ann.getCalcId ().equals (calcId) && ann.sequenceRef != null && ann.sequenceRef === seq && ann.label != null && ann.label.equals (label)) {
\r
578 }, "jalview.datamodel.SequenceI,~S,~S");
\r
579 Clazz.defineMethod (c$, "hasAnnotation",
\r
580 function (calcId) {
\r
581 if (calcId != null && !"".equals (calcId)) {
\r
582 for (var a, $a = 0, $$a = this.getAlignmentAnnotation (); $a < $$a.length && ((a = $$a[$a]) || true); $a++) {
\r
583 if (a.getCalcId () === calcId) {
\r
588 Clazz.defineMethod (c$, "clear",
\r
591 this.sequences.clear ();
\r
593 Clazz.defineMethod (c$, "setContext",
\r
594 function (context) {
\r
595 this.context = context;
\r
596 }, "jalview.datamodel.AnnotatedCollectionI");
\r
597 Clazz.overrideMethod (c$, "getContext",
\r
599 return this.context;
\r