updated to jalview 2.1 and begun ArchiveClient/VamsasClient/VamsasStore updates.
[jalview.git] / src / jalview / schemes / ResidueProperties.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer
3  * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.schemes;
20
21 import java.util.*;
22
23 import java.awt.*;
24
25 public class ResidueProperties
26 {
27   //Stores residue codes/names and colours and other things
28   public static final Hashtable aaHash = new Hashtable(); // stores the number value of the aa
29   public static final Hashtable aa3Hash = new Hashtable();
30   public static final Hashtable aa2Triplet = new Hashtable();
31   public static final Hashtable nucleotideHash = new Hashtable();
32   public static final Hashtable nucleotideName = new Hashtable();
33
34   static
35   {
36     aaHash.put("A", new Integer(0));
37     aaHash.put("R", new Integer(1));
38     aaHash.put("N", new Integer(2));
39     aaHash.put("D", new Integer(3));
40     aaHash.put("C", new Integer(4));
41     aaHash.put("Q", new Integer(5));
42     aaHash.put("E", new Integer(6));
43     aaHash.put("G", new Integer(7));
44     aaHash.put("H", new Integer(8));
45     aaHash.put("I", new Integer(9));
46     aaHash.put("L", new Integer(10));
47     aaHash.put("K", new Integer(11));
48     aaHash.put("M", new Integer(12));
49     aaHash.put("F", new Integer(13));
50     aaHash.put("P", new Integer(14));
51     aaHash.put("S", new Integer(15));
52     aaHash.put("T", new Integer(16));
53     aaHash.put("W", new Integer(17));
54     aaHash.put("Y", new Integer(18));
55     aaHash.put("V", new Integer(19));
56     aaHash.put("B", new Integer(20));
57     aaHash.put("Z", new Integer(21));
58     aaHash.put("X", new Integer(22));
59     aaHash.put("U", new Integer(22));
60     aaHash.put("a", new Integer(0));
61     aaHash.put("r", new Integer(1));
62     aaHash.put("n", new Integer(2));
63     aaHash.put("d", new Integer(3));
64     aaHash.put("c", new Integer(4));
65     aaHash.put("q", new Integer(5));
66     aaHash.put("e", new Integer(6));
67     aaHash.put("g", new Integer(7));
68     aaHash.put("h", new Integer(8));
69     aaHash.put("i", new Integer(9));
70     aaHash.put("l", new Integer(10));
71     aaHash.put("k", new Integer(11));
72     aaHash.put("m", new Integer(12));
73     aaHash.put("f", new Integer(13));
74     aaHash.put("p", new Integer(14));
75     aaHash.put("s", new Integer(15));
76     aaHash.put("t", new Integer(16));
77     aaHash.put("w", new Integer(17));
78     aaHash.put("y", new Integer(18));
79     aaHash.put("v", new Integer(19));
80     aaHash.put("b", new Integer(20));
81     aaHash.put("z", new Integer(21));
82     aaHash.put("x", new Integer(22));
83     aaHash.put("u", new Integer(22));
84     aaHash.put("-", new Integer(23));
85     aaHash.put("*", new Integer(23));
86     aaHash.put(".", new Integer(23));
87     aaHash.put(" ", new Integer(23));
88   }
89
90   static
91   {
92     nucleotideHash.put("A", new Integer(0));
93     nucleotideHash.put("a", new Integer(0));
94     nucleotideHash.put("C", new Integer(1));
95     nucleotideHash.put("c", new Integer(1));
96     nucleotideHash.put("G", new Integer(2));
97     nucleotideHash.put("g", new Integer(2));
98     nucleotideHash.put("T", new Integer(3));
99     nucleotideHash.put("t", new Integer(3));
100     nucleotideHash.put("U", new Integer(4));
101     nucleotideHash.put("u", new Integer(4));
102     nucleotideHash.put("I", new Integer(5));
103     nucleotideHash.put("i", new Integer(5));
104     nucleotideHash.put("X", new Integer(6));
105     nucleotideHash.put("x", new Integer(6));
106     nucleotideHash.put("R", new Integer(7));
107     nucleotideHash.put("r", new Integer(7));
108     nucleotideHash.put("Y", new Integer(8));
109     nucleotideHash.put("y", new Integer(8));
110     nucleotideHash.put("N", new Integer(9));
111     nucleotideHash.put("n", new Integer(9));
112
113
114     nucleotideName.put("A", "Adenine");
115     nucleotideName.put("a", "Adenine");
116     nucleotideName.put("G", "Guanine");
117     nucleotideName.put("g", "Guanine");
118     nucleotideName.put("C", "Cytosine");
119     nucleotideName.put("c", "Cytosine");
120     nucleotideName.put("T", "Thymine");
121     nucleotideName.put("t", "Thymine");
122     nucleotideName.put("U", "Uracil");
123     nucleotideName.put("u", "Uracil");
124     nucleotideName.put("I", "Inosine");
125     nucleotideName.put("i", "Inosine");
126     nucleotideName.put("X", "Xanthine");
127     nucleotideName.put("x", "Xanthine");
128     nucleotideName.put("R", "Unknown Purine");
129     nucleotideName.put("r", "Unknown Purine");
130     nucleotideName.put("Y", "Unknown Pyrimidine");
131     nucleotideName.put("y", "Unknown Pyrimidine");
132     nucleotideName.put("N", "Unknown");
133     nucleotideName.put("n", "Unknown");
134   }
135
136
137   static
138   {
139     aa3Hash.put("ALA", new Integer(0));
140     aa3Hash.put("ARG", new Integer(1));
141     aa3Hash.put("ASN", new Integer(2));
142     aa3Hash.put("ASP", new Integer(3)); //D
143     aa3Hash.put("CYS", new Integer(4));
144     aa3Hash.put("GLN", new Integer(5)); //Q
145     aa3Hash.put("GLU", new Integer(6)); // E
146     aa3Hash.put("GLY", new Integer(7));
147     aa3Hash.put("HIS", new Integer(8));
148     aa3Hash.put("ILE", new Integer(9));
149     aa3Hash.put("LEU", new Integer(10));
150     aa3Hash.put("LYS", new Integer(11));
151     aa3Hash.put("MET", new Integer(12));
152     aa3Hash.put("PHE", new Integer(13));
153     aa3Hash.put("PRO", new Integer(14));
154     aa3Hash.put("SER", new Integer(15));
155     aa3Hash.put("THR", new Integer(16));
156     aa3Hash.put("TRP", new Integer(17));
157     aa3Hash.put("TYR", new Integer(18));
158     aa3Hash.put("VAL", new Integer(19));
159     // IUB Nomenclature for ambiguous peptides
160     aa3Hash.put("ASX", new Integer(20)); // "B";
161     aa3Hash.put("GLX", new Integer(21)); // X
162     aa3Hash.put("XAA", new Integer(22));// X unknown
163     aa3Hash.put("-", new Integer(23));
164     aa3Hash.put("*", new Integer(23));
165     aa3Hash.put(".", new Integer(23));
166     aa3Hash.put(" ", new Integer(23));
167     aa3Hash.put("Gap", new Integer(23));
168   }
169
170   static
171   {
172     aa2Triplet.put("A", "ALA");
173     aa2Triplet.put("a", "ALA");
174     aa2Triplet.put("R", "ARG");
175     aa2Triplet.put("r", "ARG");
176     aa2Triplet.put("N", "ASN");
177     aa2Triplet.put("n", "ASN");
178     aa2Triplet.put("D", "ASP");
179     aa2Triplet.put("d", "ASP");
180     aa2Triplet.put("C", "CYS");
181     aa2Triplet.put("c", "CYS");
182     aa2Triplet.put("Q", "GLN");
183     aa2Triplet.put("q", "GLN");
184     aa2Triplet.put("E", "GLU");
185     aa2Triplet.put("e", "GLU");
186     aa2Triplet.put("G", "GLY");
187     aa2Triplet.put("g", "GLY");
188     aa2Triplet.put("H", "HIS");
189     aa2Triplet.put("h", "HIS");
190     aa2Triplet.put("I", "ILE");
191     aa2Triplet.put("i", "ILE");
192     aa2Triplet.put("L", "LEU");
193     aa2Triplet.put("l", "LEU");
194     aa2Triplet.put("K", "LYS");
195     aa2Triplet.put("k", "LYS");
196     aa2Triplet.put("M", "MET");
197     aa2Triplet.put("m", "MET");
198     aa2Triplet.put("F", "PHE");
199     aa2Triplet.put("f", "PHE");
200     aa2Triplet.put("P", "PRO");
201     aa2Triplet.put("p", "PRO");
202     aa2Triplet.put("S", "SER");
203     aa2Triplet.put("s", "SER");
204     aa2Triplet.put("T", "THR");
205     aa2Triplet.put("t", "THR");
206     aa2Triplet.put("W", "TRP");
207     aa2Triplet.put("w", "TRP");
208     aa2Triplet.put("Y", "TYR");
209     aa2Triplet.put("y", "TYR");
210     aa2Triplet.put("V", "VAL");
211     aa2Triplet.put("v", "VAL");
212   }
213
214   public static final String[] aa =
215       {
216       "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
217       "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " "
218   };
219   public static final Color midBlue = new Color(100, 100, 255);
220   public static final Vector scaleColours = new Vector();
221
222   static
223   {
224     scaleColours.addElement(new Color(114, 0, 147));
225     scaleColours.addElement(new Color(156, 0, 98));
226     scaleColours.addElement(new Color(190, 0, 0));
227     scaleColours.addElement(Color.red);
228     scaleColours.addElement(new Color(255, 125, 0));
229     scaleColours.addElement(Color.orange);
230     scaleColours.addElement(new Color(255, 194, 85));
231     scaleColours.addElement(Color.yellow);
232     scaleColours.addElement(new Color(255, 255, 181));
233     scaleColours.addElement(Color.white);
234   }
235
236   public static final Color[] taylor =
237       {
238       new Color(204, 255, 0), // A  Greenish-yellowy-yellow
239       new Color(0, 0, 255), // R  Blueish-bluey-blue
240       new Color(204, 0, 255), // N  Blueish-reddy-blue
241       new Color(255, 0, 0), // D  Reddish-reddy-red
242       new Color(255, 255, 0), // C  Yellowish-yellowy-yellow
243       new Color(255, 0, 204), // Q  Reddish-bluey-red
244       new Color(255, 0, 102), // E  Blueish-reddy-red
245       new Color(255, 153, 0), // G  Yellowy-reddy-yellow
246       new Color(0, 102, 255), // H  Greenish-bluey-blue
247       new Color(102, 255, 0), // I  Greenish-yellowy-green
248       new Color(51, 255, 0), // L  Yellowish-greeny-green
249       new Color(102, 0, 255), // K  Reddish-bluey-blue
250       new Color(0, 255, 0), // M  Greenish-greeny-green
251       new Color(0, 255, 102), // F  Blueish-greeny-green
252       new Color(255, 204, 0), // P  Reddish-yellowy-yellow
253       new Color(255, 51, 0), // S  Yellowish-reddy-red
254       new Color(255, 102, 0), // T  Reddish-yellowy-red
255       new Color(0, 204, 255), // W  Blueish-greeny-green
256       new Color(0, 255, 204), // Y  Greenish-bluey-green
257       new Color(153, 255, 0), // V  Yellowish-greeny-yellow
258       Color.white, // B
259       Color.white, // Z
260       Color.white, // X
261       Color.white, // -
262       Color.white, // *
263       Color.white // .
264   };
265   public static final Color[] nucleotide =
266       {
267       new Color(100, 247, 63), // A
268       new Color(255, 179, 64), // C
269       new Color(235, 65, 60), // G
270       new Color(60, 136, 238), // T
271       new Color(60, 136, 238) // U
272   };
273   public static final Color[] color =
274       {
275       Color.pink, // A
276       midBlue, // R
277       Color.green, // N
278       Color.red, // D
279       Color.yellow, // C
280       Color.green, // Q
281       Color.red, // E
282       Color.magenta, // G
283       Color.red, // H
284       Color.pink, // I
285       Color.pink, // L
286       midBlue, // K
287       Color.pink, // M
288       Color.orange, // F
289       Color.magenta, // P
290       Color.green, // S
291       Color.green, // T
292       Color.orange, // W
293       Color.orange, // Y
294       Color.pink, // V
295       Color.white, // B
296       Color.white, // Z
297       Color.white, // X
298       Color.white, // -
299       Color.white, // *
300       Color.white, // .
301       Color.white // ' '
302   };
303
304   // Dunno where I got these numbers from
305   public static final double[] hyd2 =
306       {
307       0.62, //A
308       0.29, //R
309       -0.90, //N
310       -0.74, //D
311       1.19, //C
312       0.48, //Q
313       -0.40, //E
314       1.38, //G
315       -1.50, //H
316       1.06, //I
317       0.64, //L
318       -0.78, //K
319       0.12, //M
320       -0.85, //F
321       -2.53, //P
322       -0.18, //S
323       -0.05, //T
324       1.08, //W
325       0.81, //Y
326       0.0, //V
327       0.26, //B
328       0.0, //Z
329       0.0 //X
330   };
331   public static final double[] helix =
332       {
333       1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
334       1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0
335   };
336   public static final double helixmin = 0.57;
337   public static final double helixmax = 1.51;
338   public static final double[] strand =
339       {
340       0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
341       1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0
342   };
343   public static final double strandmin = 0.37;
344   public static final double strandmax = 1.7;
345   public static final double[] turn =
346       {
347       0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
348       0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0
349   };
350   public static final double turnmin = 0.47;
351   public static final double turnmax = 1.56;
352   public static final double[] buried =
353       {
354       1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2,
355       0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00
356   };
357   public static final double buriedmin = 0.05;
358   public static final double buriedmax = 4.6;
359
360   // This is hydropathy index
361   // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
362   // 1157, 105-132, 1982
363   public static final double[] hyd =
364       {
365       1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9,
366       2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0
367   };
368   public static final double hydmax = 4.5;
369   public static final double hydmin = -3.9;
370
371   //public static final double hydmax = 1.38;
372   //public static final double hydmin = -2.53;
373   static final int[][] BLOSUM62 =
374       {
375       {
376       4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
377       -2, 0, -2, -1, 0, -4
378   },
379       {
380       -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2,
381       -3, -1, 0, -1, -4
382   },
383       {
384       -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3,
385       3, 0, -1, -4
386   },
387       {
388       -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
389       -3, -3, 4, 1, -1, -4
390   },
391       {
392       0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2,
393       -2, -1, -3, -3, -2, -4
394   },
395       {
396       -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
397       -2, 0, 3, -1, -4
398   },
399       {
400       -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
401       -2, 1, 4, -1, -4
402   },
403       {
404       0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
405       -3, -3, -1, -2, -1, -4
406   },
407       {
408       -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2,
409       -3, 0, 0, -1, -4
410   },
411       {
412       -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
413       -1, 3, -3, -3, -1, -4
414   },
415       {
416       -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
417       -1, 1, -4, -3, -1, -4
418   },
419       {
420       -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2,
421       -2, 0, 1, -1, -4
422   },
423       {
424       -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
425       -1, 1, -3, -1, -1, -4
426   },
427       {
428       -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3,
429       -1, -3, -3, -1, -4
430   },
431       {
432       -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
433       -4, -3, -2, -2, -1, -2, -4
434   },
435       {
436       1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
437       -2, 0, 0, 0, -4
438   },
439       {
440       0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
441       -2, 0, -1, -1, 0, -4
442   },
443       {
444       -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
445       11, 2, -3, -4, -3, -2, -4
446   },
447       {
448       -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2,
449       7, -1, -3, -2, -1, -4
450   },
451       {
452       0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
453       -1, 4, -3, -2, -1, -4
454   },
455       {
456       -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3,
457       -3, 4, 1, -1, -4
458   },
459       {
460       -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
461       -2, 1, 4, -1, -4
462   },
463       {
464       0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2,
465       -1, -1, -1, -1, -1, -4
466   },
467       {
468       -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
469       -4, -4, -4, -4, -4, -4, 1
470   },
471   };
472   static final int[][] PAM250 =
473       {
474       {
475       2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, 0,
476       0, 0, 0, -8
477   },
478       {
479       -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
480       -2, -1, 0, -1, -8
481   },
482       {
483       0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
484       2, 1, 0, -8
485   },
486       {
487       0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, -2,
488       3, 3, -1, -8
489   },
490       {
491       -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
492       -8, 0, -2, -4, -5, -3, -8
493   },
494       {
495       0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
496       -2, 1, 3, -1, -8
497   },
498       {
499       0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, -2,
500       3, 3, -1, -8
501   },
502       {
503       1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
504       -1, 0, 0, -1, -8
505   },
506       {
507       -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
508       -2, 1, 2, -1, -8
509   },
510       {
511       -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
512       -1, 4, -2, -2, -1, -8
513   },
514       {
515       -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
516       -1, 2, -3, -3, -1, -8
517   },
518       {
519       -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, -2,
520       1, 0, -1, -8
521   },
522       {
523       -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, -2,
524       2, -2, -2, -1, -8
525   },
526       {
527       -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, 7,
528       -1, -4, -5, -2, -8
529   },
530       {
531       1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
532       -1, -1, 0, -1, -8
533   },
534       {
535       1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, -1,
536       0, 0, 0, -8
537   },
538       {
539       1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, 0,
540       0, -1, 0, -8
541   },
542       {
543       -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, 17,
544       0, -6, -5, -6, -4, -8
545   },
546       {
547       -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
548       10, -2, -3, -4, -2, -8
549   },
550       {
551       0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
552       -2, 4, -2, -2, -1, -8
553   },
554       {
555       0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, -2,
556       3, 2, -1, -8
557   },
558       {
559       0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, -2,
560       2, 3, -1, -8
561   },
562       {
563       0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
564       -2, -1, -1, -1, -1, -8
565   },
566       {
567       -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
568       -8, -8, -8, -8, -8, -8, 1
569   },
570   };
571   public static final Hashtable ssHash = new Hashtable(); // stores the number value of the aa
572
573   static
574   {
575     ssHash.put("H", Color.magenta);
576     ssHash.put("E", Color.yellow);
577     ssHash.put("-", Color.white);
578     ssHash.put(".", Color.white);
579     ssHash.put("S", Color.cyan);
580     ssHash.put("T", Color.blue);
581     ssHash.put("G", Color.pink);
582     ssHash.put("I", Color.pink);
583     ssHash.put("B", Color.yellow);
584   }
585
586   static final int[][] DNA =
587       {
588       {
589       5, -4, -4, -4, 1}, // C
590       {
591       -4, 5, -4, -4, 1}, // T
592       {
593       -4, -4, 5, -4, 1}, // A
594       {
595       -4, -4, -4, 5, 1}, // G
596       {
597       1, 1, 1, 1, 1}, // -
598   };
599   public static final Color[] pidColours =
600       {
601       midBlue, new Color(153, 153, 255),
602       //    Color.lightGray,
603       new Color(204, 204, 255),
604   };
605   public static final float[] pidThresholds =
606       {
607       80, 60, 40, };
608   public static Hashtable codonHash = new Hashtable();
609   public static Vector Lys = new Vector();
610   public static Vector Asn = new Vector();
611   public static Vector Gln = new Vector();
612   public static Vector His = new Vector();
613   public static Vector Glu = new Vector();
614   public static Vector Asp = new Vector();
615   public static Vector Tyr = new Vector();
616   public static Vector Thr = new Vector();
617   public static Vector Pro = new Vector();
618   public static Vector Ala = new Vector();
619   public static Vector Ser = new Vector();
620   public static Vector Arg = new Vector();
621   public static Vector Gly = new Vector();
622   public static Vector Trp = new Vector();
623   public static Vector Cys = new Vector();
624   public static Vector Ile = new Vector();
625   public static Vector Met = new Vector();
626   public static Vector Leu = new Vector();
627   public static Vector Val = new Vector();
628   public static Vector Phe = new Vector();
629   public static Vector STOP = new Vector();
630
631   static
632   {
633     codonHash.put("K", Lys);
634     codonHash.put("N", Asn);
635     codonHash.put("Q", Gln);
636     codonHash.put("H", His);
637     codonHash.put("E", Glu);
638     codonHash.put("D", Asp);
639     codonHash.put("Y", Tyr);
640     codonHash.put("T", Thr);
641     codonHash.put("P", Pro);
642     codonHash.put("A", Ala);
643     codonHash.put("S", Ser);
644     codonHash.put("R", Arg);
645     codonHash.put("G", Gly);
646     codonHash.put("W", Trp);
647     codonHash.put("C", Cys);
648     codonHash.put("I", Ile);
649     codonHash.put("M", Met);
650     codonHash.put("L", Leu);
651     codonHash.put("V", Val);
652     codonHash.put("F", Phe);
653     codonHash.put("STOP", STOP);
654   }
655
656   public static Hashtable codonHash2 = new Hashtable();
657
658   static
659   {
660     codonHash2.put("AAA", "K");
661     codonHash2.put("AAG", "K");
662     codonHash2.put("AAC", "N");
663     codonHash2.put("AAT", "N");
664
665     codonHash2.put("CAA", "E");
666     codonHash2.put("CAG", "E");
667     codonHash2.put("CAC", "H");
668     codonHash2.put("CAT", "H");
669
670     codonHash2.put("GAA", "Q");
671     codonHash2.put("GAG", "Q");
672     codonHash2.put("GAC", "D");
673     codonHash2.put("GAT", "D");
674
675     codonHash2.put("TAC", "Y");
676     codonHash2.put("TAT", "Y");
677
678     codonHash2.put("ACA", "T");
679     codonHash2.put("AAG", "T");
680     codonHash2.put("ACC", "T");
681     codonHash2.put("ACT", "T");
682
683     codonHash2.put("CCA", "P");
684     codonHash2.put("CCG", "P");
685     codonHash2.put("CCC", "P");
686     codonHash2.put("CCT", "P");
687
688     codonHash2.put("GCA", "A");
689     codonHash2.put("GCG", "A");
690     codonHash2.put("GCC", "A");
691     codonHash2.put("GCT", "A");
692
693     codonHash2.put("TCA", "S");
694     codonHash2.put("TCG", "S");
695     codonHash2.put("TCC", "S");
696     codonHash2.put("TCT", "S");
697     codonHash2.put("AGC", "S");
698     codonHash2.put("AGT", "S");
699
700     codonHash2.put("AGA", "R");
701     codonHash2.put("AGG", "R");
702     codonHash2.put("CGA", "R");
703     codonHash2.put("CGG", "R");
704     codonHash2.put("CGC", "R");
705     codonHash2.put("CGT", "R");
706
707     codonHash2.put("GGA", "G");
708     codonHash2.put("GGG", "G");
709     codonHash2.put("GGC", "G");
710     codonHash2.put("GGT", "G");
711
712     codonHash2.put("TGA", "*");
713     codonHash2.put("TAA", "*");
714     codonHash2.put("TAG", "*");
715
716     codonHash2.put("TGG", "W");
717
718     codonHash2.put("TGC", "C");
719     codonHash2.put("TGT", "C");
720
721     codonHash2.put("ATA", "I");
722     codonHash2.put("ATC", "I");
723     codonHash2.put("ATT", "I");
724
725     codonHash2.put("ATG", "M");
726
727     codonHash2.put("CTA", "L");
728     codonHash2.put("CTG", "L");
729     codonHash2.put("CTC", "L");
730     codonHash2.put("CTT", "L");
731     codonHash2.put("TTA", "L");
732     codonHash2.put("TTG", "L");
733
734     codonHash2.put("GTA", "V");
735     codonHash2.put("GTG", "V");
736     codonHash2.put("GTC", "V");
737     codonHash2.put("GTT", "V");
738
739     codonHash2.put("TTC", "F");
740     codonHash2.put("TTT", "F");
741   }
742
743   static
744   {
745     Lys.addElement("AAA");
746     Lys.addElement("AAG");
747     Asn.addElement("AAC");
748     Asn.addElement("AAT");
749
750     Gln.addElement("CAA");
751     Gln.addElement("CAG");
752     His.addElement("CAC");
753     His.addElement("CAT");
754
755     Glu.addElement("GAA");
756     Glu.addElement("GAG");
757     Asp.addElement("GAC");
758     Asp.addElement("GAT");
759
760     Tyr.addElement("TAC");
761     Tyr.addElement("TAT");
762
763     Thr.addElement("ACA");
764     Thr.addElement("ACG");
765     Thr.addElement("ACC");
766     Thr.addElement("ACT");
767
768     Pro.addElement("CCA");
769     Pro.addElement("CCG");
770     Pro.addElement("CCC");
771     Pro.addElement("CCT");
772
773     Ala.addElement("GCA");
774     Ala.addElement("GCG");
775     Ala.addElement("GCC");
776     Ala.addElement("GCT");
777
778     Ser.addElement("TCA");
779     Ser.addElement("TCG");
780     Ser.addElement("TCC");
781     Ser.addElement("TCT");
782     Ser.addElement("AGC");
783     Ser.addElement("AGT");
784
785     Arg.addElement("AGA");
786     Arg.addElement("AGG");
787     Arg.addElement("CGA");
788     Arg.addElement("CGG");
789     Arg.addElement("CGC");
790     Arg.addElement("CGT");
791
792     Gly.addElement("GGA");
793     Gly.addElement("GGG");
794     Gly.addElement("GGC");
795     Gly.addElement("GGT");
796
797     STOP.addElement("TGA");
798     STOP.addElement("TAA");
799     STOP.addElement("TAG");
800
801     Trp.addElement("TGG");
802
803     Cys.addElement("TGC");
804     Cys.addElement("TGT");
805
806     Ile.addElement("ATA");
807     Ile.addElement("ATC");
808     Ile.addElement("ATT");
809
810     Met.addElement("ATG");
811
812     Leu.addElement("CTA");
813     Leu.addElement("CTG");
814     Leu.addElement("CTC");
815     Leu.addElement("CTT");
816     Leu.addElement("TTA");
817     Leu.addElement("TTG");
818
819     Val.addElement("GTA");
820     Val.addElement("GTG");
821     Val.addElement("GTC");
822     Val.addElement("GTT");
823
824     Phe.addElement("TTC");
825     Phe.addElement("TTT");
826   }
827
828
829   //Stores residue codes/names and colours and other things
830   public static Hashtable propHash = new Hashtable();
831   public static Hashtable hydrophobic = new Hashtable();
832   public static Hashtable polar = new Hashtable();
833   public static Hashtable small = new Hashtable();
834   public static Hashtable positive = new Hashtable();
835   public static Hashtable negative = new Hashtable();
836   public static Hashtable charged = new Hashtable();
837   public static Hashtable aromatic = new Hashtable();
838   public static Hashtable aliphatic = new Hashtable();
839   public static Hashtable tiny = new Hashtable();
840   public static Hashtable proline = new Hashtable();
841
842   static
843   {
844     hydrophobic.put("I", new Integer(1));
845     hydrophobic.put("L", new Integer(1));
846     hydrophobic.put("V", new Integer(1));
847     hydrophobic.put("C", new Integer(1));
848     hydrophobic.put("A", new Integer(1));
849     hydrophobic.put("G", new Integer(1));
850     hydrophobic.put("M", new Integer(1));
851     hydrophobic.put("F", new Integer(1));
852     hydrophobic.put("Y", new Integer(1));
853     hydrophobic.put("W", new Integer(1));
854     hydrophobic.put("H", new Integer(1));
855     hydrophobic.put("K", new Integer(1));
856     hydrophobic.put("X", new Integer(1));
857     hydrophobic.put("-", new Integer(1));
858     hydrophobic.put("*", new Integer(1));
859     hydrophobic.put("R", new Integer(0));
860     hydrophobic.put("E", new Integer(0));
861     hydrophobic.put("Q", new Integer(0));
862     hydrophobic.put("D", new Integer(0));
863     hydrophobic.put("N", new Integer(0));
864     hydrophobic.put("S", new Integer(0));
865     hydrophobic.put("T", new Integer(0));
866     hydrophobic.put("P", new Integer(0));
867   }
868
869   static
870   {
871     polar.put("Y", new Integer(1));
872     polar.put("W", new Integer(1));
873     polar.put("H", new Integer(1));
874     polar.put("K", new Integer(1));
875     polar.put("R", new Integer(1));
876     polar.put("E", new Integer(1));
877     polar.put("Q", new Integer(1));
878     polar.put("D", new Integer(1));
879     polar.put("N", new Integer(1));
880     polar.put("S", new Integer(1));
881     polar.put("T", new Integer(1));
882     polar.put("X", new Integer(1));
883     polar.put("-", new Integer(1));
884     polar.put("*", new Integer(1));
885     polar.put("I", new Integer(0));
886     polar.put("L", new Integer(0));
887     polar.put("V", new Integer(0));
888     polar.put("C", new Integer(0));
889     polar.put("A", new Integer(0));
890     polar.put("G", new Integer(0));
891     polar.put("M", new Integer(0));
892     polar.put("F", new Integer(0));
893     polar.put("P", new Integer(0));
894   }
895
896   static
897   {
898     small.put("I", new Integer(0));
899     small.put("L", new Integer(0));
900     small.put("V", new Integer(1));
901     small.put("C", new Integer(1));
902     small.put("A", new Integer(1));
903     small.put("G", new Integer(1));
904     small.put("M", new Integer(0));
905     small.put("F", new Integer(0));
906     small.put("Y", new Integer(0));
907     small.put("W", new Integer(0));
908     small.put("H", new Integer(0));
909     small.put("K", new Integer(0));
910     small.put("R", new Integer(0));
911     small.put("E", new Integer(0));
912     small.put("Q", new Integer(0));
913     small.put("D", new Integer(1));
914     small.put("N", new Integer(1));
915     small.put("S", new Integer(1));
916     small.put("T", new Integer(1));
917     small.put("P", new Integer(1));
918     small.put("-", new Integer(1));
919     small.put("*", new Integer(1));
920   }
921
922   static
923   {
924     positive.put("I", new Integer(0));
925     positive.put("L", new Integer(0));
926     positive.put("V", new Integer(0));
927     positive.put("C", new Integer(0));
928     positive.put("A", new Integer(0));
929     positive.put("G", new Integer(0));
930     positive.put("M", new Integer(0));
931     positive.put("F", new Integer(0));
932     positive.put("Y", new Integer(0));
933     positive.put("W", new Integer(0));
934     positive.put("H", new Integer(1));
935     positive.put("K", new Integer(1));
936     positive.put("R", new Integer(1));
937     positive.put("E", new Integer(0));
938     positive.put("Q", new Integer(0));
939     positive.put("D", new Integer(0));
940     positive.put("N", new Integer(0));
941     positive.put("S", new Integer(0));
942     positive.put("T", new Integer(0));
943     positive.put("P", new Integer(0));
944     positive.put("-", new Integer(1));
945     positive.put("*", new Integer(1));
946   }
947
948   static
949   {
950     negative.put("I", new Integer(0));
951     negative.put("L", new Integer(0));
952     negative.put("V", new Integer(0));
953     negative.put("C", new Integer(0));
954     negative.put("A", new Integer(0));
955     negative.put("G", new Integer(0));
956     negative.put("M", new Integer(0));
957     negative.put("F", new Integer(0));
958     negative.put("Y", new Integer(0));
959     negative.put("W", new Integer(0));
960     negative.put("H", new Integer(0));
961     negative.put("K", new Integer(0));
962     negative.put("R", new Integer(0));
963     negative.put("E", new Integer(1));
964     negative.put("Q", new Integer(0));
965     negative.put("D", new Integer(1));
966     negative.put("N", new Integer(0));
967     negative.put("S", new Integer(0));
968     negative.put("T", new Integer(0));
969     negative.put("P", new Integer(0));
970     negative.put("-", new Integer(1));
971     negative.put("*", new Integer(1));
972   }
973
974   static
975   {
976     charged.put("I", new Integer(0));
977     charged.put("L", new Integer(0));
978     charged.put("V", new Integer(0));
979     charged.put("C", new Integer(0));
980     charged.put("A", new Integer(0));
981     charged.put("G", new Integer(0));
982     charged.put("M", new Integer(0));
983     charged.put("F", new Integer(0));
984     charged.put("Y", new Integer(0));
985     charged.put("W", new Integer(0));
986     charged.put("H", new Integer(1));
987     charged.put("K", new Integer(1));
988     charged.put("R", new Integer(1));
989     charged.put("E", new Integer(1));
990     charged.put("Q", new Integer(0));
991     charged.put("D", new Integer(1));
992     charged.put("N", new Integer(1));
993     charged.put("S", new Integer(0));
994     charged.put("T", new Integer(0));
995     charged.put("P", new Integer(0));
996     charged.put("-", new Integer(1));
997     charged.put("*", new Integer(1));
998   }
999
1000   static
1001   {
1002     aromatic.put("I", new Integer(0));
1003     aromatic.put("L", new Integer(0));
1004     aromatic.put("V", new Integer(0));
1005     aromatic.put("C", new Integer(0));
1006     aromatic.put("A", new Integer(0));
1007     aromatic.put("G", new Integer(0));
1008     aromatic.put("M", new Integer(0));
1009     aromatic.put("F", new Integer(1));
1010     aromatic.put("Y", new Integer(1));
1011     aromatic.put("W", new Integer(1));
1012     aromatic.put("H", new Integer(1));
1013     aromatic.put("K", new Integer(0));
1014     aromatic.put("R", new Integer(0));
1015     aromatic.put("E", new Integer(0));
1016     aromatic.put("Q", new Integer(0));
1017     aromatic.put("D", new Integer(0));
1018     aromatic.put("N", new Integer(0));
1019     aromatic.put("S", new Integer(0));
1020     aromatic.put("T", new Integer(0));
1021     aromatic.put("P", new Integer(0));
1022     aromatic.put("-", new Integer(1));
1023     aromatic.put("*", new Integer(1));
1024   }
1025
1026   static
1027   {
1028     aliphatic.put("I", new Integer(1));
1029     aliphatic.put("L", new Integer(1));
1030     aliphatic.put("V", new Integer(1));
1031     aliphatic.put("C", new Integer(0));
1032     aliphatic.put("A", new Integer(0));
1033     aliphatic.put("G", new Integer(0));
1034     aliphatic.put("M", new Integer(0));
1035     aliphatic.put("F", new Integer(0));
1036     aliphatic.put("Y", new Integer(0));
1037     aliphatic.put("W", new Integer(0));
1038     aliphatic.put("H", new Integer(0));
1039     aliphatic.put("K", new Integer(0));
1040     aliphatic.put("R", new Integer(0));
1041     aliphatic.put("E", new Integer(0));
1042     aliphatic.put("Q", new Integer(0));
1043     aliphatic.put("D", new Integer(0));
1044     aliphatic.put("N", new Integer(0));
1045     aliphatic.put("S", new Integer(0));
1046     aliphatic.put("T", new Integer(0));
1047     aliphatic.put("P", new Integer(0));
1048     aliphatic.put("-", new Integer(1));
1049     aliphatic.put("*", new Integer(1));
1050   }
1051
1052   static
1053   {
1054     tiny.put("I", new Integer(0));
1055     tiny.put("L", new Integer(0));
1056     tiny.put("V", new Integer(0));
1057     tiny.put("C", new Integer(0));
1058     tiny.put("A", new Integer(1));
1059     tiny.put("G", new Integer(1));
1060     tiny.put("M", new Integer(0));
1061     tiny.put("F", new Integer(0));
1062     tiny.put("Y", new Integer(0));
1063     tiny.put("W", new Integer(0));
1064     tiny.put("H", new Integer(0));
1065     tiny.put("K", new Integer(0));
1066     tiny.put("R", new Integer(0));
1067     tiny.put("E", new Integer(0));
1068     tiny.put("Q", new Integer(0));
1069     tiny.put("D", new Integer(0));
1070     tiny.put("N", new Integer(0));
1071     tiny.put("S", new Integer(1));
1072     tiny.put("T", new Integer(0));
1073     tiny.put("P", new Integer(0));
1074     tiny.put("-", new Integer(1));
1075     tiny.put("*", new Integer(1));
1076   }
1077
1078   static
1079   {
1080     proline.put("I", new Integer(0));
1081     proline.put("L", new Integer(0));
1082     proline.put("V", new Integer(0));
1083     proline.put("C", new Integer(0));
1084     proline.put("A", new Integer(0));
1085     proline.put("G", new Integer(0));
1086     proline.put("M", new Integer(0));
1087     proline.put("F", new Integer(0));
1088     proline.put("Y", new Integer(0));
1089     proline.put("W", new Integer(0));
1090     proline.put("H", new Integer(0));
1091     proline.put("K", new Integer(0));
1092     proline.put("R", new Integer(0));
1093     proline.put("E", new Integer(0));
1094     proline.put("Q", new Integer(0));
1095     proline.put("D", new Integer(0));
1096     proline.put("N", new Integer(0));
1097     proline.put("S", new Integer(0));
1098     proline.put("T", new Integer(0));
1099     proline.put("P", new Integer(1));
1100     proline.put("-", new Integer(1));
1101     proline.put("*", new Integer(1));
1102   }
1103
1104   static
1105   {
1106     propHash.put("hydrophobic", hydrophobic);
1107     propHash.put("small", small);
1108     propHash.put("positive", positive);
1109     propHash.put("negative", negative);
1110     propHash.put("charged", charged);
1111     propHash.put("aromatic", aromatic);
1112     propHash.put("aliphatic", aliphatic);
1113     propHash.put("tiny", tiny);
1114     propHash.put("proline", proline);
1115     propHash.put("polar", polar);
1116   }
1117
1118   private ResidueProperties()
1119   {
1120   }
1121
1122   public static double getHydmax()
1123   {
1124     return hydmax;
1125   }
1126
1127   public static double getHydmin()
1128   {
1129     return hydmin;
1130   }
1131
1132   public static double[] getHyd()
1133   {
1134     return hyd;
1135   }
1136
1137   public static Hashtable getAAHash()
1138   {
1139     return aaHash;
1140   }
1141
1142   public static Hashtable getAA3Hash()
1143   {
1144     return aa3Hash;
1145   }
1146
1147   public static int[][] getDNA()
1148   {
1149     return ResidueProperties.DNA;
1150   }
1151
1152   public static int[][] getBLOSUM62()
1153   {
1154     return ResidueProperties.BLOSUM62;
1155   }
1156
1157   public static int getPAM250(String A1, String A2)
1158   {
1159     Integer pog1 = (Integer) aaHash.get(A1);
1160     Integer pog2 = (Integer) aaHash.get(A2);
1161     int pog = ResidueProperties.PAM250[pog1.intValue()][pog2.intValue()];
1162
1163     return pog;
1164   }
1165
1166   public static int getBLOSUM62(String A1, String A2)
1167   {
1168     int pog = 0;
1169
1170     try
1171     {
1172       Integer pog1 = (Integer) aaHash.get(A1);
1173       Integer pog2 = (Integer) aaHash.get(A2);
1174       pog = ResidueProperties.BLOSUM62[pog1.intValue()][pog2.intValue()];
1175     }
1176     catch (Exception e)
1177     {
1178       //System.out.println("Unknown residue in " + A1 + " " + A2);
1179     }
1180
1181     return pog;
1182   }
1183
1184   public static Vector getCodons(String res)
1185   {
1186     if (codonHash.containsKey(res))
1187     {
1188       return (Vector) codonHash.get(res);
1189     }
1190
1191     return null;
1192   }
1193
1194   public static String codonTranslate(String codon)
1195   {
1196     Enumeration e = codonHash.keys();
1197
1198     while (e.hasMoreElements())
1199     {
1200       String key = (String) e.nextElement();
1201       Vector tmp = (Vector) codonHash.get(key);
1202
1203       if (tmp.contains(codon.toUpperCase()))
1204       {
1205         return key;
1206       }
1207     }
1208
1209     return null;
1210   }
1211 }