JAL-1807 test
[jalviewjs.git] / bin / jalview / schemes / ClustalxColourScheme.js
1 Clazz.declarePackage ("jalview.schemes");
2 Clazz.load (["jalview.schemes.ResidueColourScheme", "java.util.HashMap"], ["jalview.schemes.ConsensusColour", "$.ClustalxColourScheme"], ["jalview.schemes.Consensus", "$.ResidueProperties", "java.awt.Color"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.cons2 = null;
5 this.colours = null;
6 this.residueColour = null;
7 this.size = 0;
8 this.conses = null;
9 this.includeGaps = true;
10 Clazz.instantialize (this, arguments);
11 }, jalview.schemes, "ClustalxColourScheme", jalview.schemes.ResidueColourScheme);
12 Clazz.prepareFields (c$, function () {
13 this.conses =  new Array (32);
14 });
15 Clazz.makeConstructor (c$, 
16 function (alignment, hiddenReps) {
17 Clazz.superConstructor (this, jalview.schemes.ClustalxColourScheme, []);
18 this.alignmentChanged (alignment, hiddenReps);
19 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
20 Clazz.overrideMethod (c$, "alignmentChanged", 
21 function (alignment, hiddenReps) {
22 var maxWidth = alignment.getWidth ();
23 var seqs = alignment.getSequences (hiddenReps);
24 this.cons2 =  Clazz.newIntArray (maxWidth, 24, 0);
25 this.includeGaps = this.isIncludeGaps ();
26 var start = 0;
27 for (var j = 0; j < 24; j++) {
28 for (var i = 0; i < maxWidth; i++) {
29 this.cons2[i][j] = 0;
30 }
31 }
32 var res;
33 var i;
34 var j = 0;
35 var seq;
36 for (var sq, $sq = seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) {
37 seq = sq.getSequence ();
38 var end_j = seq.length - 1;
39 for (i = start; i <= end_j; i++) {
40 if ((seq.length - 1) < i) {
41 res = 23;
42 } else {
43 res = jalview.schemes.ResidueProperties.aaIndex[seq[i].charCodeAt (0)];
44 }this.cons2[i][res]++;
45 }
46 j++;
47 }
48 this.size = seqs.size ();
49 this.makeColours ();
50 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
51 Clazz.defineMethod (c$, "makeColours", 
52 function () {
53 this.conses[0] =  new jalview.schemes.Consensus ("WLVIMAFCYHP", 60);
54 this.conses[1] =  new jalview.schemes.Consensus ("WLVIMAFCYHP", 80);
55 this.conses[2] =  new jalview.schemes.Consensus ("ED", 50);
56 this.conses[3] =  new jalview.schemes.Consensus ("KR", 60);
57 this.conses[4] =  new jalview.schemes.Consensus ("G", 50);
58 this.conses[5] =  new jalview.schemes.Consensus ("N", 50);
59 this.conses[6] =  new jalview.schemes.Consensus ("QE", 50);
60 this.conses[7] =  new jalview.schemes.Consensus ("P", 50);
61 this.conses[8] =  new jalview.schemes.Consensus ("TS", 50);
62 this.conses[26] =  new jalview.schemes.Consensus ("A", 85);
63 this.conses[27] =  new jalview.schemes.Consensus ("C", 85);
64 this.conses[10] =  new jalview.schemes.Consensus ("E", 85);
65 this.conses[11] =  new jalview.schemes.Consensus ("F", 85);
66 this.conses[12] =  new jalview.schemes.Consensus ("G", 85);
67 this.conses[13] =  new jalview.schemes.Consensus ("H", 85);
68 this.conses[14] =  new jalview.schemes.Consensus ("I", 85);
69 this.conses[15] =  new jalview.schemes.Consensus ("L", 85);
70 this.conses[16] =  new jalview.schemes.Consensus ("M", 85);
71 this.conses[17] =  new jalview.schemes.Consensus ("N", 85);
72 this.conses[18] =  new jalview.schemes.Consensus ("P", 85);
73 this.conses[19] =  new jalview.schemes.Consensus ("Q", 85);
74 this.conses[20] =  new jalview.schemes.Consensus ("R", 85);
75 this.conses[21] =  new jalview.schemes.Consensus ("S", 85);
76 this.conses[22] =  new jalview.schemes.Consensus ("T", 85);
77 this.conses[23] =  new jalview.schemes.Consensus ("V", 85);
78 this.conses[24] =  new jalview.schemes.Consensus ("W", 85);
79 this.conses[25] =  new jalview.schemes.Consensus ("Y", 85);
80 this.conses[28] =  new jalview.schemes.Consensus ("K", 85);
81 this.conses[29] =  new jalview.schemes.Consensus ("D", 85);
82 this.conses[30] =  new jalview.schemes.Consensus ("G", 0);
83 this.conses[31] =  new jalview.schemes.Consensus ("P", 0);
84 this.colours =  new Array (11);
85 var tmp8 =  new Array (1);
86 tmp8[0] = this.conses[30];
87 this.colours[7] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.ORANGE), tmp8);
88 var tmp9 =  new Array (1);
89 tmp9[0] = this.conses[31];
90 this.colours[8] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.YELLOW), tmp9);
91 var tmp10 =  new Array (1);
92 tmp10[0] = this.conses[27];
93 this.colours[9] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK), tmp8);
94 var tmp1 =  new Array (14);
95 tmp1[0] = this.conses[0];
96 tmp1[1] = this.conses[1];
97 tmp1[2] = this.conses[26];
98 tmp1[3] = this.conses[27];
99 tmp1[4] = this.conses[11];
100 tmp1[5] = this.conses[13];
101 tmp1[6] = this.conses[14];
102 tmp1[7] = this.conses[15];
103 tmp1[8] = this.conses[16];
104 tmp1[9] = this.conses[23];
105 tmp1[10] = this.conses[24];
106 tmp1[11] = this.conses[25];
107 tmp1[12] = this.conses[18];
108 tmp1[13] = this.conses[19];
109 this.colours[0] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.BLUE), tmp1);
110 this.colours[10] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.CYAN), tmp1);
111 var tmp2 =  new Array (5);
112 tmp2[0] = this.conses[8];
113 tmp2[1] = this.conses[21];
114 tmp2[2] = this.conses[22];
115 tmp2[3] = this.conses[0];
116 tmp2[4] = this.conses[1];
117 this.colours[1] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp2);
118 var tmp3 =  new Array (3);
119 tmp3[0] = this.conses[17];
120 tmp3[1] = this.conses[29];
121 tmp3[2] = this.conses[5];
122 this.colours[2] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp3);
123 var tmp4 =  new Array (6);
124 tmp4[0] = this.conses[6];
125 tmp4[1] = this.conses[19];
126 tmp4[2] = this.conses[22];
127 tmp4[3] = this.conses[3];
128 tmp4[4] = this.conses[28];
129 tmp4[5] = this.conses[20];
130 this.colours[3] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.GREEN), tmp4);
131 var tmp5 =  new Array (4);
132 tmp5[0] = this.conses[3];
133 tmp5[1] = this.conses[28];
134 tmp5[2] = this.conses[20];
135 tmp5[3] = this.conses[19];
136 this.colours[4] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.RED), tmp5);
137 var tmp6 =  new Array (6);
138 tmp6[0] = this.conses[3];
139 tmp6[1] = this.conses[29];
140 tmp6[2] = this.conses[10];
141 tmp6[3] = this.conses[6];
142 tmp6[4] = this.conses[19];
143 tmp6[5] = this.conses[2];
144 this.colours[5] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp6);
145 var tmp7 =  new Array (5);
146 tmp7[0] = this.conses[3];
147 tmp7[1] = this.conses[29];
148 tmp7[2] = this.conses[10];
149 tmp7[3] = this.conses[17];
150 tmp7[4] = this.conses[2];
151 this.colours[6] =  new jalview.schemes.ConsensusColour (jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.MAGENTA), tmp7);
152 this.residueColour =  new Array (20);
153 this.residueColour[0] = this.colours[0];
154 this.residueColour[1] = this.colours[4];
155 this.residueColour[2] = this.colours[2];
156 this.residueColour[3] = this.colours[6];
157 this.residueColour[4] = this.colours[0];
158 this.residueColour[5] = this.colours[3];
159 this.residueColour[6] = this.colours[5];
160 this.residueColour[7] = this.colours[7];
161 this.residueColour[8] = this.colours[10];
162 this.residueColour[9] = this.colours[0];
163 this.residueColour[10] = this.colours[0];
164 this.residueColour[11] = this.colours[4];
165 this.residueColour[12] = this.colours[0];
166 this.residueColour[13] = this.colours[0];
167 this.residueColour[14] = this.colours[8];
168 this.residueColour[15] = this.colours[1];
169 this.residueColour[16] = this.colours[1];
170 this.residueColour[17] = this.colours[0];
171 this.residueColour[18] = this.colours[10];
172 this.residueColour[19] = this.colours[0];
173 });
174 Clazz.defineMethod (c$, "findColour", 
175 function (c) {
176 return java.awt.Color.pink;
177 }, "~S");
178 Clazz.defineMethod (c$, "findColour", 
179 function (c, j, seq) {
180 var currentColour;
181 if (this.cons2.length <= j || (this.includeGaps && this.threshold != 0 && !this.aboveThreshold (c, j))) {
182 return java.awt.Color.white;
183 }var i = jalview.schemes.ResidueProperties.aaIndex[c.charCodeAt (0)];
184 currentColour = java.awt.Color.white;
185 if (i > 19) {
186 return currentColour;
187 }for (var k = 0; k < this.residueColour[i].conses.length; k++) {
188 if (this.residueColour[i].conses[k].isConserved (this.cons2, j, this.size, this.includeGaps)) {
189 currentColour = this.residueColour[i].c;
190 }}
191 if (i == 4) {
192 if (this.conses[27].isConserved (this.cons2, j, this.size, this.includeGaps)) {
193 currentColour = jalview.schemes.ClustalxColourScheme.colhash.get (java.awt.Color.PINK);
194 }}if (this.conservationColouring) {
195 currentColour = this.applyConservation (currentColour, j);
196 }return currentColour;
197 }, "~S,~N,jalview.datamodel.SequenceI");
198 Clazz.defineMethod (c$, "isIncludeGaps", 
199 function () {
200 return this.includeGaps;
201 });
202 Clazz.defineMethod (c$, "setIncludeGaps", 
203 function (includeGaps) {
204 this.includeGaps = includeGaps;
205 }, "~B");
206 Clazz.overrideMethod (c$, "applyTo", 
207 function (sg, hiddenRepSequences) {
208 var css =  new jalview.schemes.ClustalxColourScheme (sg, hiddenRepSequences);
209 css.includeGaps = this.includeGaps;
210 return css;
211 }, "jalview.datamodel.AnnotatedCollectionI,java.util.Map");
212 Clazz.defineStatics (c$,
213 "EIGHTY_FIVE", 85,
214 "FIFTY", 50,
215 "EIGHTY", 80,
216 "SIXTY", 60);
217 c$.colhash = c$.prototype.colhash =  new java.util.HashMap ();
218 {
219 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.RED,  new java.awt.Color (0.9, 0.2, 0.1));
220 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.BLUE,  new java.awt.Color (0.5, 0.7, 0.9));
221 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.GREEN,  new java.awt.Color (0.1, 0.8, 0.1));
222 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.ORANGE,  new java.awt.Color (0.9, 0.6, 0.3));
223 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.CYAN,  new java.awt.Color (0.1, 0.7, 0.7));
224 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.PINK,  new java.awt.Color (0.9, 0.5, 0.5));
225 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.MAGENTA,  new java.awt.Color (0.8, 0.3, 0.8));
226 jalview.schemes.ClustalxColourScheme.colhash.put (java.awt.Color.YELLOW,  new java.awt.Color (0.8, 0.8, 0.0));
227 }c$ = Clazz.decorateAsClass (function () {
228 this.conses = null;
229 this.c = null;
230 Clazz.instantialize (this, arguments);
231 }, jalview.schemes, "ConsensusColour");
232 Clazz.makeConstructor (c$, 
233 function (c, conses) {
234 this.conses = conses;
235 this.c = c;
236 }, "java.awt.Color,~A");
237 });