1 Clazz.declarePackage ("jalview.schemes");
2 Clazz.load (["jalview.schemes.ColourSchemeI"], "jalview.schemes.ResidueColourScheme", ["jalview.util.Comparison", "$.MessageManager", "java.awt.Color", "java.lang.Error"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.symbolIndex = null;
5 this.conservationColouring = false;
10 this.conservation = null;
11 this.conservationLength = 0;
13 Clazz.instantialize (this, arguments);
14 }, jalview.schemes, "ResidueColourScheme", null, jalview.schemes.ColourSchemeI);
15 Clazz.makeConstructor (c$,
16 function (aaOrnaIndex, colours, threshold) {
17 this.symbolIndex = aaOrnaIndex;
18 this.colors = colours;
19 this.threshold = threshold;
21 Clazz.makeConstructor (c$,
22 function (aaOrNaIndex) {
23 this.symbolIndex = aaOrNaIndex;
25 Clazz.makeConstructor (c$,
27 this.symbolIndex = null;
29 Clazz.overrideMethod (c$, "findColour",
31 return this.colors == null ? java.awt.Color.white : this.colors[this.symbolIndex[c.charCodeAt (0)]];
33 Clazz.overrideMethod (c$, "findColourSeq",
34 function (c, j, seq) {
36 if (this.colors != null && this.symbolIndex != null && (this.threshold == 0) || this.aboveThreshold (c, j)) {
37 currentColour = this.colors[this.symbolIndex[c.charCodeAt (0)]];
39 currentColour = java.awt.Color.white;
40 }if (this.conservationColouring) {
41 currentColour = this.applyConservation (currentColour, j);
42 }return currentColour;
43 }, "~S,~N,jalview.datamodel.SequenceI");
44 Clazz.overrideMethod (c$, "getThreshold",
46 return this.threshold;
48 Clazz.overrideMethod (c$, "setThreshold",
49 function (ct, ignoreGaps) {
52 this.ignoreGaps = "N";
54 this.ignoreGaps = "G";
56 Clazz.defineMethod (c$, "aboveThreshold",
58 if ('a' <= c && c <= 'z') {
59 c = String.fromCharCode (c.charCodeAt (0) - (32));
60 }if (this.consensus == null || this.consensus.length < j || this.consensus[j] == null) {
62 }if (((this.consensus[j].get ("C")).intValue () != -1) && this.consensus[j].contains (String.valueOf (c))) {
63 if ((this.consensus[j].get (this.ignoreGaps)).floatValue () >= this.threshold) {
67 Clazz.overrideMethod (c$, "conservationApplied",
69 return this.conservationColouring;
71 Clazz.overrideMethod (c$, "setConservationApplied",
72 function (conservationApplied) {
73 this.conservationColouring = conservationApplied;
75 Clazz.overrideMethod (c$, "setConservationInc",
79 Clazz.overrideMethod (c$, "getConservationInc",
83 Clazz.overrideMethod (c$, "setConsensus",
84 function (consensus) {
85 if (consensus == null) {
87 }this.consensus = consensus;
89 Clazz.overrideMethod (c$, "setConservation",
92 this.conservationColouring = false;
93 this.conservation = null;
95 this.conservationColouring = true;
97 var iSize = cons.getConsSequence ().getLength ();
98 this.conservation = Clazz.newCharArray (iSize, '\0');
99 for (i = 0; i < iSize; i++) {
100 this.conservation[i] = cons.getConsSequence ().getCharAt (i);
102 this.conservationLength = this.conservation.length;
103 }}, "jalview.analysis.Conservation");
104 Clazz.defineMethod (c$, "applyConservation",
105 function (currentColour, i) {
106 if ((this.conservationLength > i) && (this.conservation[i] != '*') && (this.conservation[i] != '+')) {
107 if (jalview.util.Comparison.isGap (this.conservation[i])) {
108 currentColour = java.awt.Color.white;
110 var t = 11 - ((this.conservation[i]).charCodeAt (0) - 48);
112 return java.awt.Color.white;
113 }var red = currentColour.getRed ();
114 var green = currentColour.getGreen ();
115 var blue = currentColour.getBlue ();
117 var dg = 255 - green;
122 red += (this.inc / 20) * dr;
123 green += (this.inc / 20) * dg;
124 blue += (this.inc / 20) * db;
125 if (red > 255 || green > 255 || blue > 255) {
126 currentColour = java.awt.Color.white;
128 currentColour = new java.awt.Color (red, green, blue);
129 }}}return currentColour;
130 }, "java.awt.Color,~N");
131 Clazz.overrideMethod (c$, "alignmentChanged",
132 function (alignment, hiddenReps) {
133 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
134 Clazz.overrideMethod (c$, "applyTo",
135 function (sg, hiddenRepSequences) {
137 return this.getClass ().newInstance ();
139 if (Clazz.exceptionOf (q, Exception)) {
140 throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_cannot_duplicate_colour_scheme", Clazz.newArray (-1, [this.getClass ().getName ()])), q);
145 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");