2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemes;
\r
25 import jalview.datamodel.*;
\r
27 public class ClustalxColourScheme
\r
28 extends ResidueColourScheme
\r
30 public static Hashtable colhash = new Hashtable();
\r
33 ConsensusColour[] colours;
\r
34 ConsensusColour[] ResidueColour;
\r
36 Consensus[] conses = new Consensus[32];
\r
37 Vector colourTable = new Vector();
\r
40 colhash.put("RED", new Color( (float) 0.9, (float) 0.2, (float) 0.1));
\r
41 colhash.put("BLUE", new Color( (float) 0.5, (float) 0.7, (float) 0.9));
\r
42 colhash.put("GREEN", new Color( (float) 0.1, (float) 0.8, (float) 0.1));
\r
43 colhash.put("ORANGE", new Color( (float) 0.9, (float) 0.6, (float) 0.3));
\r
44 colhash.put("CYAN", new Color( (float) 0.1, (float) 0.7, (float) 0.7));
\r
45 colhash.put("PINK", new Color( (float) 0.9, (float) 0.5, (float) 0.5));
\r
46 colhash.put("MAGENTA", new Color( (float) 0.8, (float) 0.3, (float) 0.8));
\r
47 colhash.put("YELLOW", new Color( (float) 0.8, (float) 0.8, (float) 0.0));
\r
50 public ClustalxColourScheme(Vector seqs, int maxWidth)
\r
52 resetClustalX(seqs, maxWidth);
\r
55 public void resetClustalX(Vector seqs, int maxWidth)
\r
57 cons2 = new int[maxWidth][24];
\r
61 // Initialize the array
\r
62 for (int j = 0; j < 24; j++)
\r
64 for (int i = 0; i < maxWidth; i++)
\r
75 while (j < seqs.size())
\r
77 seq = ( (SequenceI) seqs.elementAt(j)).getSequence();
\r
79 int end_j = seq.length() - 1;
\r
81 for (i = start; i <= end_j; i++)
\r
83 if ( (seq.length() - 1) < i)
\r
89 res = ( (Integer) ResidueProperties.aaHash.get(seq.charAt(i) +
\r
99 this.size = seqs.size();
\r
103 public void makeColours()
\r
105 conses[0] = new Consensus("WLVIMAFCYHP", 60);
\r
106 conses[1] = new Consensus("WLVIMAFCYHP", 80);
\r
107 conses[2] = new Consensus("ED", 50);
\r
108 conses[3] = new Consensus("KR", 60);
\r
109 conses[4] = new Consensus("G", 50);
\r
110 conses[5] = new Consensus("N", 50);
\r
111 conses[6] = new Consensus("QE", 50);
\r
112 conses[7] = new Consensus("P", 50);
\r
113 conses[8] = new Consensus("TS", 50);
\r
115 conses[26] = new Consensus("A", 85);
\r
116 conses[27] = new Consensus("C", 85);
\r
117 conses[10] = new Consensus("E", 85);
\r
118 conses[11] = new Consensus("F", 85);
\r
119 conses[12] = new Consensus("G", 85);
\r
120 conses[13] = new Consensus("H", 85);
\r
121 conses[14] = new Consensus("I", 85);
\r
122 conses[15] = new Consensus("L", 85);
\r
123 conses[16] = new Consensus("M", 85);
\r
124 conses[17] = new Consensus("N", 85);
\r
125 conses[18] = new Consensus("P", 85);
\r
126 conses[19] = new Consensus("Q", 85);
\r
127 conses[20] = new Consensus("R", 85);
\r
128 conses[21] = new Consensus("S", 85);
\r
129 conses[22] = new Consensus("T", 85);
\r
130 conses[23] = new Consensus("V", 85);
\r
131 conses[24] = new Consensus("W", 85);
\r
132 conses[25] = new Consensus("Y", 85);
\r
133 conses[28] = new Consensus("K", 85);
\r
134 conses[29] = new Consensus("D", 85);
\r
136 conses[30] = new Consensus("G", 0);
\r
137 conses[31] = new Consensus("P", 0);
\r
139 // We now construct the colours
\r
140 colours = new ConsensusColour[11];
\r
142 Consensus[] tmp8 = new Consensus[1];
\r
143 tmp8[0] = conses[30]; //G
\r
144 colours[7] = new ConsensusColour( (Color) colhash.get("ORANGE"), tmp8);
\r
146 Consensus[] tmp9 = new Consensus[1];
\r
147 tmp9[0] = conses[31]; //P
\r
148 colours[8] = new ConsensusColour( (Color) colhash.get("YELLOW"), tmp9);
\r
150 Consensus[] tmp10 = new Consensus[1];
\r
151 tmp10[0] = conses[27]; //C
\r
152 colours[9] = new ConsensusColour( (Color) colhash.get("PINK"), tmp8);
\r
154 Consensus[] tmp1 = new Consensus[14];
\r
155 tmp1[0] = conses[0]; //%
\r
156 tmp1[1] = conses[1]; //#
\r
157 tmp1[2] = conses[26]; //A
\r
158 tmp1[3] = conses[27]; //C
\r
159 tmp1[4] = conses[11]; //F
\r
160 tmp1[5] = conses[13]; //H
\r
161 tmp1[6] = conses[14]; //I
\r
162 tmp1[7] = conses[15]; //L
\r
163 tmp1[8] = conses[16]; //M
\r
164 tmp1[9] = conses[23]; //V
\r
165 tmp1[10] = conses[24]; //W
\r
166 tmp1[11] = conses[25]; //Y
\r
167 tmp1[12] = conses[18]; //P
\r
168 tmp1[13] = conses[19]; //p
\r
169 colours[0] = new ConsensusColour( (Color) colhash.get("BLUE"), tmp1);
\r
171 colours[10] = new ConsensusColour( (Color) colhash.get("CYAN"), tmp1);
\r
173 Consensus[] tmp2 = new Consensus[5];
\r
174 tmp2[0] = conses[8]; //t
\r
175 tmp2[1] = conses[21]; //S
\r
176 tmp2[2] = conses[22]; //T
\r
177 tmp2[3] = conses[0]; //%
\r
178 tmp2[4] = conses[1]; //#
\r
179 colours[1] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp2);
\r
181 Consensus[] tmp3 = new Consensus[3];
\r
183 tmp3[0] = conses[17]; //N
\r
184 tmp3[1] = conses[29]; //D
\r
185 tmp3[2] = conses[5]; //n
\r
186 colours[2] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp3);
\r
188 Consensus[] tmp4 = new Consensus[6];
\r
189 tmp4[0] = conses[6]; // q = QE
\r
190 tmp4[1] = conses[19]; //Q
\r
191 tmp4[2] = conses[22]; //E
\r
192 tmp4[3] = conses[3]; //+
\r
193 tmp4[4] = conses[28]; //K
\r
194 tmp4[5] = conses[20]; //R
\r
195 colours[3] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp4);
\r
197 Consensus[] tmp5 = new Consensus[4];
\r
198 tmp5[0] = conses[3]; //+
\r
199 tmp5[1] = conses[28]; //K
\r
200 tmp5[2] = conses[20]; //R
\r
201 tmp5[3] = conses[19]; //Q
\r
202 colours[4] = new ConsensusColour( (Color) colhash.get("RED"), tmp5);
\r
204 Consensus[] tmp6 = new Consensus[5];
\r
205 tmp6[0] = conses[3]; //-
\r
206 tmp6[1] = conses[29]; //D
\r
207 tmp6[2] = conses[10]; //E
\r
208 tmp6[3] = conses[6]; //q
\r
209 tmp6[4] = conses[19]; //Q
\r
210 colours[5] = new ConsensusColour( (Color) colhash.get("MAGENTA"), tmp6);
\r
212 Consensus[] tmp7 = new Consensus[5];
\r
213 tmp7[0] = conses[3]; //-
\r
214 tmp7[1] = conses[29]; //D
\r
215 tmp7[2] = conses[10]; //E
\r
216 tmp7[3] = conses[17]; //N
\r
217 tmp7[4] = conses[2]; //DE
\r
218 colours[6] = new ConsensusColour( (Color) colhash.get("MAGENTA"), tmp7);
\r
220 // Now attach the ConsensusColours to the residue letters
\r
221 ResidueColour = new ConsensusColour[20];
\r
222 ResidueColour[0] = colours[0]; // A
\r
223 ResidueColour[1] = colours[4]; // R
\r
224 ResidueColour[2] = colours[2]; // N
\r
225 ResidueColour[3] = colours[6]; // D
\r
226 ResidueColour[4] = colours[0]; // C
\r
227 ResidueColour[5] = colours[3]; // Q
\r
228 ResidueColour[6] = colours[5]; // E
\r
229 ResidueColour[7] = colours[7]; // G
\r
230 ResidueColour[8] = colours[10]; // H
\r
231 ResidueColour[9] = colours[0]; // I
\r
232 ResidueColour[10] = colours[0]; // L
\r
233 ResidueColour[11] = colours[4]; // K
\r
234 ResidueColour[12] = colours[0]; // M
\r
235 ResidueColour[13] = colours[0]; // F
\r
236 ResidueColour[14] = colours[8]; // P
\r
237 ResidueColour[15] = colours[1]; // S
\r
238 ResidueColour[16] = colours[1]; // T
\r
239 ResidueColour[17] = colours[0]; // W
\r
240 ResidueColour[18] = colours[10]; // Y
\r
241 ResidueColour[19] = colours[0]; // V
\r
244 public Color findColour(String s)
\r
249 public Color findColour(String s, int j)
\r
252 if(cons2.length<=j)
\r
253 return currentColour;
\r
256 if ( (threshold != 0) && !aboveThreshold(s, j))
\r
258 return Color.white;
\r
261 int i = ( (Integer) ResidueProperties.aaHash.get(s)).intValue();
\r
263 currentColour = Color.white;
\r
267 return currentColour;
\r
270 for (int k = 0; k < ResidueColour[i].conses.length; k++)
\r
272 if (ResidueColour[i].conses[k].isConserved(cons2, j, size))
\r
274 currentColour = ResidueColour[i].c;
\r
280 if (conses[27].isConserved(cons2, j, size))
\r
282 currentColour = (Color) colhash.get("PINK");
\r
286 if(conservationColouring)
\r
287 applyConservation(j);
\r
289 return currentColour;
\r
293 class ConsensusColour
\r
295 Consensus[] conses;
\r
298 public ConsensusColour(Color c, Consensus[] conses)
\r
300 this.conses = conses;
\r
302 // this.list = list;
\r