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