apply gpl development license
[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] = -1;
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   };
285
286   // Zappo
287   public static final Color[] zappo =
288   { Color.pink, // A
289       midBlue, // R
290       Color.green, // N
291       Color.red, // D
292       Color.yellow, // C
293       Color.green, // Q
294       Color.red, // E
295       Color.magenta, // G
296       midBlue,// Color.red, // H
297       Color.pink, // I
298       Color.pink, // L
299       midBlue, // K
300       Color.pink, // M
301       Color.orange, // F
302       Color.magenta, // P
303       Color.green, // S
304       Color.green, // T
305       Color.orange, // W
306       Color.orange, // Y
307       Color.pink, // V
308       Color.white, // B
309       Color.white, // Z
310       Color.white, // X
311       Color.white, // -
312       Color.white, // *
313       Color.white, // .
314       Color.white // ' '
315   };
316
317   // Dunno where I got these numbers from
318   public static final double[] hyd2 =
319   { 0.62, // A
320       0.29, // R
321       -0.90, // N
322       -0.74, // D
323       1.19, // C
324       0.48, // Q
325       -0.40, // E
326       1.38, // G
327       -1.50, // H
328       1.06, // I
329       0.64, // L
330       -0.78, // K
331       0.12, // M
332       -0.85, // F
333       -2.53, // P
334       -0.18, // S
335       -0.05, // T
336       1.08, // W
337       0.81, // Y
338       0.0, // V
339       0.26, // B
340       0.0, // Z
341       0.0 // X
342   };
343
344   public static final double[] helix =
345   { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
346       1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
347
348   public static final double helixmin = 0.57;
349
350   public static final double helixmax = 1.51;
351
352   public static final double[] strand =
353   { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
354       1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
355
356   public static final double strandmin = 0.37;
357
358   public static final double strandmax = 1.7;
359
360   public static final double[] turn =
361   { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
362       0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
363       0 };
364
365   public static final double turnmin = 0.47;
366
367   public static final double turnmax = 1.56;
368
369   public static final double[] buried =
370   { 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,
371       0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
372
373   public static final double buriedmin = 0.05;
374
375   public static final double buriedmax = 4.6;
376
377   // This is hydropathy index
378   // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
379   // 1157, 105-132, 1982
380   public static final double[] hyd =
381   { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
382       1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
383
384   public static final double hydmax = 4.5;
385
386   public static final double hydmin = -3.9;
387
388   // public static final double hydmax = 1.38;
389   // public static final double hydmin = -2.53;
390   private static final int[][] BLOSUM62 =
391   {
392       { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
393           -2, 0, -2, -1, 0, -4 },
394       { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
395           -2, -3, -1, 0, -1, -4 },
396       { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
397           -3, 3, 0, -1, -4 },
398       { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
399           -3, -3, 4, 1, -1, -4 },
400       { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
401           -2, -2, -1, -3, -3, -2, -4 },
402       { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
403           -2, 0, 3, -1, -4 },
404       { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
405           -2, 1, 4, -1, -4 },
406       { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
407           -3, -3, -1, -2, -1, -4 },
408       { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
409           2, -3, 0, 0, -1, -4 },
410       { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
411           -1, 3, -3, -3, -1, -4 },
412       { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
413           -1, 1, -4, -3, -1, -4 },
414       { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
415           -2, -2, 0, 1, -1, -4 },
416       { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
417           -1, 1, -3, -1, -1, -4 },
418       { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
419           3, -1, -3, -3, -1, -4 },
420       { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
421           -4, -3, -2, -2, -1, -2, -4 },
422       { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
423           -2, 0, 0, 0, -4 },
424       { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
425           -2, 0, -1, -1, 0, -4 },
426       { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
427           11, 2, -3, -4, -3, -2, -4 },
428       { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
429           2, 7, -1, -3, -2, -1, -4 },
430       { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
431           -1, 4, -3, -2, -1, -4 },
432       { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
433           -3, -3, 4, 1, -1, -4 },
434       { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
435           -2, 1, 4, -1, -4 },
436       { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
437           -2, -1, -1, -1, -1, -1, -4 },
438       { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
439           -4, -4, -4, -4, -4, -4, 1 }, };
440
441   static final int[][] PAM250 =
442   {
443       { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
444           0, 0, 0, 0, -8 },
445       { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
446           -2, -1, 0, -1, -8 },
447       { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
448           2, 1, 0, -8 },
449       { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
450           -2, 3, 3, -1, -8 },
451       { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
452           -8, 0, -2, -4, -5, -3, -8 },
453       { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
454           -2, 1, 3, -1, -8 },
455       { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
456           -2, 3, 3, -1, -8 },
457       { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
458           -1, 0, 0, -1, -8 },
459       { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
460           -2, 1, 2, -1, -8 },
461       { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
462           -1, 4, -2, -2, -1, -8 },
463       { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
464           -1, 2, -3, -3, -1, -8 },
465       { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
466           -2, 1, 0, -1, -8 },
467       { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
468           -2, 2, -2, -2, -1, -8 },
469       { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
470           7, -1, -4, -5, -2, -8 },
471       { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
472           -1, -1, 0, -1, -8 },
473       { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
474           -1, 0, 0, 0, -8 },
475       { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
476           0, 0, -1, 0, -8 },
477       { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
478           17, 0, -6, -5, -6, -4, -8 },
479       { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
480           10, -2, -3, -4, -2, -8 },
481       { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
482           -2, 4, -2, -2, -1, -8 },
483       { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
484           -2, 3, 2, -1, -8 },
485       { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
486           -2, 2, 3, -1, -8 },
487       { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
488           -2, -1, -1, -1, -1, -8 },
489       { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
490           -8, -8, -8, -8, -8, -8, 1 }, };
491
492   public static final Hashtable ssHash = new Hashtable(); // stores the number
493                                                           // value of the aa
494
495   static
496   {
497     ssHash.put("H", Color.magenta);
498     ssHash.put("E", Color.yellow);
499     ssHash.put("-", Color.white);
500     ssHash.put(".", Color.white);
501     ssHash.put("S", Color.cyan);
502     ssHash.put("T", Color.blue);
503     ssHash.put("G", Color.pink);
504     ssHash.put("I", Color.pink);
505     ssHash.put("B", Color.yellow);
506   }
507
508   static final int[][] DNA =
509   {
510   { 5, -4, -4, -4, 1 }, // C
511       { -4, 5, -4, -4, 1 }, // T
512       { -4, -4, 5, -4, 1 }, // A
513       { -4, -4, -4, 5, 1 }, // G
514       { 1, 1, 1, 1, 1 }, // -
515   };
516   /**
517    * register matrices in list
518    */
519   static
520   {
521     scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
522     scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
523     scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
524   }
525
526   public static final Color[] pidColours =
527   { midBlue, new Color(153, 153, 255),
528   // Color.lightGray,
529       new Color(204, 204, 255), };
530
531   public static final float[] pidThresholds =
532   { 80, 60, 40, };
533
534   public static Hashtable codonHash = new Hashtable();
535
536   public static Vector Lys = new Vector();
537
538   public static Vector Asn = new Vector();
539
540   public static Vector Gln = new Vector();
541
542   public static Vector His = new Vector();
543
544   public static Vector Glu = new Vector();
545
546   public static Vector Asp = new Vector();
547
548   public static Vector Tyr = new Vector();
549
550   public static Vector Thr = new Vector();
551
552   public static Vector Pro = new Vector();
553
554   public static Vector Ala = new Vector();
555
556   public static Vector Ser = new Vector();
557
558   public static Vector Arg = new Vector();
559
560   public static Vector Gly = new Vector();
561
562   public static Vector Trp = new Vector();
563
564   public static Vector Cys = new Vector();
565
566   public static Vector Ile = new Vector();
567
568   public static Vector Met = new Vector();
569
570   public static Vector Leu = new Vector();
571
572   public static Vector Val = new Vector();
573
574   public static Vector Phe = new Vector();
575
576   public static Vector STOP = new Vector();
577
578   static
579   {
580     codonHash.put("K", Lys);
581     codonHash.put("N", Asn);
582     codonHash.put("Q", Gln);
583     codonHash.put("H", His);
584     codonHash.put("E", Glu);
585     codonHash.put("D", Asp);
586     codonHash.put("Y", Tyr);
587     codonHash.put("T", Thr);
588     codonHash.put("P", Pro);
589     codonHash.put("A", Ala);
590     codonHash.put("S", Ser);
591     codonHash.put("R", Arg);
592     codonHash.put("G", Gly);
593     codonHash.put("W", Trp);
594     codonHash.put("C", Cys);
595     codonHash.put("I", Ile);
596     codonHash.put("M", Met);
597     codonHash.put("L", Leu);
598     codonHash.put("V", Val);
599     codonHash.put("F", Phe);
600     codonHash.put("STOP", STOP);
601   }
602
603   public static Hashtable codonHash2 = new Hashtable();
604
605   static
606   {
607     codonHash2.put("AAA", "K");
608     codonHash2.put("AAG", "K");
609     codonHash2.put("AAC", "N");
610     codonHash2.put("AAT", "N");
611
612     codonHash2.put("CAA", "E");
613     codonHash2.put("CAG", "E");
614     codonHash2.put("CAC", "H");
615     codonHash2.put("CAT", "H");
616
617     codonHash2.put("GAA", "Q");
618     codonHash2.put("GAG", "Q");
619     codonHash2.put("GAC", "D");
620     codonHash2.put("GAT", "D");
621
622     codonHash2.put("TAC", "Y");
623     codonHash2.put("TAT", "Y");
624
625     codonHash2.put("ACA", "T");
626     codonHash2.put("AAG", "T");
627     codonHash2.put("ACC", "T");
628     codonHash2.put("ACT", "T");
629
630     codonHash2.put("CCA", "P");
631     codonHash2.put("CCG", "P");
632     codonHash2.put("CCC", "P");
633     codonHash2.put("CCT", "P");
634
635     codonHash2.put("GCA", "A");
636     codonHash2.put("GCG", "A");
637     codonHash2.put("GCC", "A");
638     codonHash2.put("GCT", "A");
639
640     codonHash2.put("TCA", "S");
641     codonHash2.put("TCG", "S");
642     codonHash2.put("TCC", "S");
643     codonHash2.put("TCT", "S");
644     codonHash2.put("AGC", "S");
645     codonHash2.put("AGT", "S");
646
647     codonHash2.put("AGA", "R");
648     codonHash2.put("AGG", "R");
649     codonHash2.put("CGA", "R");
650     codonHash2.put("CGG", "R");
651     codonHash2.put("CGC", "R");
652     codonHash2.put("CGT", "R");
653
654     codonHash2.put("GGA", "G");
655     codonHash2.put("GGG", "G");
656     codonHash2.put("GGC", "G");
657     codonHash2.put("GGT", "G");
658
659     codonHash2.put("TGA", "*");
660     codonHash2.put("TAA", "*");
661     codonHash2.put("TAG", "*");
662
663     codonHash2.put("TGG", "W");
664
665     codonHash2.put("TGC", "C");
666     codonHash2.put("TGT", "C");
667
668     codonHash2.put("ATA", "I");
669     codonHash2.put("ATC", "I");
670     codonHash2.put("ATT", "I");
671
672     codonHash2.put("ATG", "M");
673
674     codonHash2.put("CTA", "L");
675     codonHash2.put("CTG", "L");
676     codonHash2.put("CTC", "L");
677     codonHash2.put("CTT", "L");
678     codonHash2.put("TTA", "L");
679     codonHash2.put("TTG", "L");
680
681     codonHash2.put("GTA", "V");
682     codonHash2.put("GTG", "V");
683     codonHash2.put("GTC", "V");
684     codonHash2.put("GTT", "V");
685
686     codonHash2.put("TTC", "F");
687     codonHash2.put("TTT", "F");
688   }
689
690   static
691   {
692     Lys.addElement("AAA");
693     Lys.addElement("AAG");
694     Asn.addElement("AAC");
695     Asn.addElement("AAT");
696
697     Gln.addElement("CAA");
698     Gln.addElement("CAG");
699     His.addElement("CAC");
700     His.addElement("CAT");
701
702     Glu.addElement("GAA");
703     Glu.addElement("GAG");
704     Asp.addElement("GAC");
705     Asp.addElement("GAT");
706
707     Tyr.addElement("TAC");
708     Tyr.addElement("TAT");
709
710     Thr.addElement("ACA");
711     Thr.addElement("ACG");
712     Thr.addElement("ACC");
713     Thr.addElement("ACT");
714
715     Pro.addElement("CCA");
716     Pro.addElement("CCG");
717     Pro.addElement("CCC");
718     Pro.addElement("CCT");
719
720     Ala.addElement("GCA");
721     Ala.addElement("GCG");
722     Ala.addElement("GCC");
723     Ala.addElement("GCT");
724
725     Ser.addElement("TCA");
726     Ser.addElement("TCG");
727     Ser.addElement("TCC");
728     Ser.addElement("TCT");
729     Ser.addElement("AGC");
730     Ser.addElement("AGT");
731
732     Arg.addElement("AGA");
733     Arg.addElement("AGG");
734     Arg.addElement("CGA");
735     Arg.addElement("CGG");
736     Arg.addElement("CGC");
737     Arg.addElement("CGT");
738
739     Gly.addElement("GGA");
740     Gly.addElement("GGG");
741     Gly.addElement("GGC");
742     Gly.addElement("GGT");
743
744     STOP.addElement("TGA");
745     STOP.addElement("TAA");
746     STOP.addElement("TAG");
747
748     Trp.addElement("TGG");
749
750     Cys.addElement("TGC");
751     Cys.addElement("TGT");
752
753     Ile.addElement("ATA");
754     Ile.addElement("ATC");
755     Ile.addElement("ATT");
756
757     Met.addElement("ATG");
758
759     Leu.addElement("CTA");
760     Leu.addElement("CTG");
761     Leu.addElement("CTC");
762     Leu.addElement("CTT");
763     Leu.addElement("TTA");
764     Leu.addElement("TTG");
765
766     Val.addElement("GTA");
767     Val.addElement("GTG");
768     Val.addElement("GTC");
769     Val.addElement("GTT");
770
771     Phe.addElement("TTC");
772     Phe.addElement("TTT");
773   }
774
775   // Stores residue codes/names and colours and other things
776   public static Hashtable propHash = new Hashtable();
777
778   public static Hashtable hydrophobic = new Hashtable();
779
780   public static Hashtable polar = new Hashtable();
781
782   public static Hashtable small = new Hashtable();
783
784   public static Hashtable positive = new Hashtable();
785
786   public static Hashtable negative = new Hashtable();
787
788   public static Hashtable charged = new Hashtable();
789
790   public static Hashtable aromatic = new Hashtable();
791
792   public static Hashtable aliphatic = new Hashtable();
793
794   public static Hashtable tiny = new Hashtable();
795
796   public static Hashtable proline = new Hashtable();
797
798   static
799   {
800     hydrophobic.put("I", new Integer(1));
801     hydrophobic.put("L", new Integer(1));
802     hydrophobic.put("V", new Integer(1));
803     hydrophobic.put("C", new Integer(1));
804     hydrophobic.put("A", new Integer(1));
805     hydrophobic.put("G", new Integer(1));
806     hydrophobic.put("M", new Integer(1));
807     hydrophobic.put("F", new Integer(1));
808     hydrophobic.put("Y", new Integer(1));
809     hydrophobic.put("W", new Integer(1));
810     hydrophobic.put("H", new Integer(1));
811     hydrophobic.put("K", new Integer(1));
812     hydrophobic.put("X", new Integer(1));
813     hydrophobic.put("-", new Integer(1));
814     hydrophobic.put("*", new Integer(1));
815     hydrophobic.put("R", new Integer(0));
816     hydrophobic.put("E", new Integer(0));
817     hydrophobic.put("Q", new Integer(0));
818     hydrophobic.put("D", new Integer(0));
819     hydrophobic.put("N", new Integer(0));
820     hydrophobic.put("S", new Integer(0));
821     hydrophobic.put("T", new Integer(0));
822     hydrophobic.put("P", new Integer(0));
823   }
824
825   static
826   {
827     polar.put("Y", new Integer(1));
828     polar.put("W", new Integer(1));
829     polar.put("H", new Integer(1));
830     polar.put("K", new Integer(1));
831     polar.put("R", new Integer(1));
832     polar.put("E", new Integer(1));
833     polar.put("Q", new Integer(1));
834     polar.put("D", new Integer(1));
835     polar.put("N", new Integer(1));
836     polar.put("S", new Integer(1));
837     polar.put("T", new Integer(1));
838     polar.put("X", new Integer(1));
839     polar.put("-", new Integer(1));
840     polar.put("*", new Integer(1));
841     polar.put("I", new Integer(0));
842     polar.put("L", new Integer(0));
843     polar.put("V", new Integer(0));
844     polar.put("C", new Integer(0));
845     polar.put("A", new Integer(0));
846     polar.put("G", new Integer(0));
847     polar.put("M", new Integer(0));
848     polar.put("F", new Integer(0));
849     polar.put("P", new Integer(0));
850   }
851
852   static
853   {
854     small.put("I", new Integer(0));
855     small.put("L", new Integer(0));
856     small.put("V", new Integer(1));
857     small.put("C", new Integer(1));
858     small.put("A", new Integer(1));
859     small.put("G", new Integer(1));
860     small.put("M", new Integer(0));
861     small.put("F", new Integer(0));
862     small.put("Y", new Integer(0));
863     small.put("W", new Integer(0));
864     small.put("H", new Integer(0));
865     small.put("K", new Integer(0));
866     small.put("R", new Integer(0));
867     small.put("E", new Integer(0));
868     small.put("Q", new Integer(0));
869     small.put("D", new Integer(1));
870     small.put("N", new Integer(1));
871     small.put("S", new Integer(1));
872     small.put("T", new Integer(1));
873     small.put("P", new Integer(1));
874     small.put("-", new Integer(1));
875     small.put("*", new Integer(1));
876   }
877
878   static
879   {
880     positive.put("I", new Integer(0));
881     positive.put("L", new Integer(0));
882     positive.put("V", new Integer(0));
883     positive.put("C", new Integer(0));
884     positive.put("A", new Integer(0));
885     positive.put("G", new Integer(0));
886     positive.put("M", new Integer(0));
887     positive.put("F", new Integer(0));
888     positive.put("Y", new Integer(0));
889     positive.put("W", new Integer(0));
890     positive.put("H", new Integer(1));
891     positive.put("K", new Integer(1));
892     positive.put("R", new Integer(1));
893     positive.put("E", new Integer(0));
894     positive.put("Q", new Integer(0));
895     positive.put("D", new Integer(0));
896     positive.put("N", new Integer(0));
897     positive.put("S", new Integer(0));
898     positive.put("T", new Integer(0));
899     positive.put("P", new Integer(0));
900     positive.put("-", new Integer(1));
901     positive.put("*", new Integer(1));
902   }
903
904   static
905   {
906     negative.put("I", new Integer(0));
907     negative.put("L", new Integer(0));
908     negative.put("V", new Integer(0));
909     negative.put("C", new Integer(0));
910     negative.put("A", new Integer(0));
911     negative.put("G", new Integer(0));
912     negative.put("M", new Integer(0));
913     negative.put("F", new Integer(0));
914     negative.put("Y", new Integer(0));
915     negative.put("W", new Integer(0));
916     negative.put("H", new Integer(0));
917     negative.put("K", new Integer(0));
918     negative.put("R", new Integer(0));
919     negative.put("E", new Integer(1));
920     negative.put("Q", new Integer(0));
921     negative.put("D", new Integer(1));
922     negative.put("N", new Integer(0));
923     negative.put("S", new Integer(0));
924     negative.put("T", new Integer(0));
925     negative.put("P", new Integer(0));
926     negative.put("-", new Integer(1));
927     negative.put("*", new Integer(1));
928   }
929
930   static
931   {
932     charged.put("I", new Integer(0));
933     charged.put("L", new Integer(0));
934     charged.put("V", new Integer(0));
935     charged.put("C", new Integer(0));
936     charged.put("A", new Integer(0));
937     charged.put("G", new Integer(0));
938     charged.put("M", new Integer(0));
939     charged.put("F", new Integer(0));
940     charged.put("Y", new Integer(0));
941     charged.put("W", new Integer(0));
942     charged.put("H", new Integer(1));
943     charged.put("K", new Integer(1));
944     charged.put("R", new Integer(1));
945     charged.put("E", new Integer(1));
946     charged.put("Q", new Integer(0));
947     charged.put("D", new Integer(1));
948     charged.put("N", new Integer(1));
949     charged.put("S", new Integer(0));
950     charged.put("T", new Integer(0));
951     charged.put("P", new Integer(0));
952     charged.put("-", new Integer(1));
953     charged.put("*", new Integer(1));
954   }
955
956   static
957   {
958     aromatic.put("I", new Integer(0));
959     aromatic.put("L", new Integer(0));
960     aromatic.put("V", new Integer(0));
961     aromatic.put("C", new Integer(0));
962     aromatic.put("A", new Integer(0));
963     aromatic.put("G", new Integer(0));
964     aromatic.put("M", new Integer(0));
965     aromatic.put("F", new Integer(1));
966     aromatic.put("Y", new Integer(1));
967     aromatic.put("W", new Integer(1));
968     aromatic.put("H", new Integer(1));
969     aromatic.put("K", new Integer(0));
970     aromatic.put("R", new Integer(0));
971     aromatic.put("E", new Integer(0));
972     aromatic.put("Q", new Integer(0));
973     aromatic.put("D", new Integer(0));
974     aromatic.put("N", new Integer(0));
975     aromatic.put("S", new Integer(0));
976     aromatic.put("T", new Integer(0));
977     aromatic.put("P", new Integer(0));
978     aromatic.put("-", new Integer(1));
979     aromatic.put("*", new Integer(1));
980   }
981
982   static
983   {
984     aliphatic.put("I", new Integer(1));
985     aliphatic.put("L", new Integer(1));
986     aliphatic.put("V", new Integer(1));
987     aliphatic.put("C", new Integer(0));
988     aliphatic.put("A", new Integer(0));
989     aliphatic.put("G", new Integer(0));
990     aliphatic.put("M", new Integer(0));
991     aliphatic.put("F", new Integer(0));
992     aliphatic.put("Y", new Integer(0));
993     aliphatic.put("W", new Integer(0));
994     aliphatic.put("H", new Integer(0));
995     aliphatic.put("K", new Integer(0));
996     aliphatic.put("R", new Integer(0));
997     aliphatic.put("E", new Integer(0));
998     aliphatic.put("Q", new Integer(0));
999     aliphatic.put("D", new Integer(0));
1000     aliphatic.put("N", new Integer(0));
1001     aliphatic.put("S", new Integer(0));
1002     aliphatic.put("T", new Integer(0));
1003     aliphatic.put("P", new Integer(0));
1004     aliphatic.put("-", new Integer(1));
1005     aliphatic.put("*", new Integer(1));
1006   }
1007
1008   static
1009   {
1010     tiny.put("I", new Integer(0));
1011     tiny.put("L", new Integer(0));
1012     tiny.put("V", new Integer(0));
1013     tiny.put("C", new Integer(0));
1014     tiny.put("A", new Integer(1));
1015     tiny.put("G", new Integer(1));
1016     tiny.put("M", new Integer(0));
1017     tiny.put("F", new Integer(0));
1018     tiny.put("Y", new Integer(0));
1019     tiny.put("W", new Integer(0));
1020     tiny.put("H", new Integer(0));
1021     tiny.put("K", new Integer(0));
1022     tiny.put("R", new Integer(0));
1023     tiny.put("E", new Integer(0));
1024     tiny.put("Q", new Integer(0));
1025     tiny.put("D", new Integer(0));
1026     tiny.put("N", new Integer(0));
1027     tiny.put("S", new Integer(1));
1028     tiny.put("T", new Integer(0));
1029     tiny.put("P", new Integer(0));
1030     tiny.put("-", new Integer(1));
1031     tiny.put("*", new Integer(1));
1032   }
1033
1034   static
1035   {
1036     proline.put("I", new Integer(0));
1037     proline.put("L", new Integer(0));
1038     proline.put("V", new Integer(0));
1039     proline.put("C", new Integer(0));
1040     proline.put("A", new Integer(0));
1041     proline.put("G", new Integer(0));
1042     proline.put("M", new Integer(0));
1043     proline.put("F", new Integer(0));
1044     proline.put("Y", new Integer(0));
1045     proline.put("W", new Integer(0));
1046     proline.put("H", new Integer(0));
1047     proline.put("K", new Integer(0));
1048     proline.put("R", new Integer(0));
1049     proline.put("E", new Integer(0));
1050     proline.put("Q", new Integer(0));
1051     proline.put("D", new Integer(0));
1052     proline.put("N", new Integer(0));
1053     proline.put("S", new Integer(0));
1054     proline.put("T", new Integer(0));
1055     proline.put("P", new Integer(1));
1056     proline.put("-", new Integer(1));
1057     proline.put("*", new Integer(1));
1058   }
1059
1060   static
1061   {
1062     propHash.put("hydrophobic", hydrophobic);
1063     propHash.put("small", small);
1064     propHash.put("positive", positive);
1065     propHash.put("negative", negative);
1066     propHash.put("charged", charged);
1067     propHash.put("aromatic", aromatic);
1068     propHash.put("aliphatic", aliphatic);
1069     propHash.put("tiny", tiny);
1070     propHash.put("proline", proline);
1071     propHash.put("polar", polar);
1072   }
1073
1074   private ResidueProperties()
1075   {
1076   }
1077
1078   public static double getHydmax()
1079   {
1080     return hydmax;
1081   }
1082
1083   public static double getHydmin()
1084   {
1085     return hydmin;
1086   }
1087
1088   public static double[] getHyd()
1089   {
1090     return hyd;
1091   }
1092
1093   public static Hashtable getAA3Hash()
1094   {
1095     return aa3Hash;
1096   }
1097
1098   public static int[][] getDNA()
1099   {
1100     return ResidueProperties.DNA;
1101   }
1102
1103   public static int[][] getBLOSUM62()
1104   {
1105     return ResidueProperties.BLOSUM62;
1106   }
1107
1108   public static int getPAM250(String A1, String A2)
1109   {
1110     return getPAM250(A1.charAt(0), A2.charAt(0));
1111   }
1112
1113   public static int getBLOSUM62(char c1, char c2)
1114   {
1115     int pog = 0;
1116
1117     try
1118     {
1119       int a = aaIndex[c1];
1120       int b = aaIndex[c2];
1121
1122       pog = ResidueProperties.BLOSUM62[a][b];
1123     } catch (Exception e)
1124     {
1125       // System.out.println("Unknown residue in " + A1 + " " + A2);
1126     }
1127
1128     return pog;
1129   }
1130
1131   public static Vector getCodons(String res)
1132   {
1133     if (codonHash.containsKey(res))
1134     {
1135       return (Vector) codonHash.get(res);
1136     }
1137
1138     return null;
1139   }
1140
1141   public static String codonTranslate(String lccodon)
1142   {
1143     String codon=lccodon.toUpperCase();
1144     // all base ambiguity codes yield an 'X' amino acid residue
1145     if (codon.indexOf('X')>-1 || codon.indexOf('N')>-1)
1146     {
1147       return "X";
1148     }
1149     Enumeration e = codonHash.keys();
1150
1151     while (e.hasMoreElements())
1152     {
1153       String key = (String) e.nextElement();
1154       Vector tmp = (Vector) codonHash.get(key);
1155
1156       if (tmp.contains(codon))
1157       {
1158         return key;
1159       }
1160     }
1161
1162     return null;
1163   }
1164
1165   public static int[][] getDefaultPeptideMatrix()
1166   {
1167     return ResidueProperties.getBLOSUM62();
1168   }
1169
1170   public static int[][] getDefaultDnaMatrix()
1171   {
1172     return ResidueProperties.getDNA();
1173   }
1174
1175   /**
1176    * get a ScoreMatrix based on its string name
1177    * 
1178    * @param pwtype
1179    * @return matrix in scoreMatrices with key pwtype or null
1180    */
1181   public static ScoreMatrix getScoreMatrix(String pwtype)
1182   {
1183     Object val = scoreMatrices.get(pwtype);
1184     if (val != null)
1185     {
1186       return (ScoreMatrix) val;
1187     }
1188     return null;
1189   }
1190
1191   public static int getPAM250(char c, char d)
1192   {
1193     int a = aaIndex[c];
1194     int b = aaIndex[d];
1195
1196     int pog = ResidueProperties.PAM250[a][b];
1197
1198     return pog;
1199   }
1200
1201   public static Hashtable toDssp3State;
1202   static
1203   {
1204     toDssp3State = new Hashtable();
1205     toDssp3State.put("H", "H");
1206     toDssp3State.put("E", "E");
1207     toDssp3State.put("C", " ");
1208     toDssp3State.put(" ", " ");
1209     toDssp3State.put("T", " ");
1210     toDssp3State.put("B", "E");
1211     toDssp3State.put("G", "H");
1212     toDssp3State.put("I", "H");
1213     toDssp3State.put("X", " ");
1214   }
1215
1216   /**
1217    * translate from other dssp secondary structure alphabets to 3-state
1218    * 
1219    * @param ssstring
1220    * @return ssstring as a three-state secondary structure assignment.
1221    */
1222   public static String getDssp3state(String ssstring)
1223   {
1224     if (ssstring == null)
1225     {
1226       return null;
1227     }
1228     StringBuffer ss = new StringBuffer();
1229     for (int i = 0; i < ssstring.length(); i++)
1230     {
1231       String ssc = ssstring.substring(i, i + 1);
1232       if (toDssp3State.containsKey(ssc))
1233       {
1234         ss.append((String) toDssp3State.get(ssc));
1235       }
1236       else
1237       {
1238         ss.append(" ");
1239       }
1240     }
1241     return ss.toString();
1242   }
1243
1244   // main method generates perl representation of residue property hash
1245   // / cut here
1246   public static void main(String[] args)
1247   {
1248     Hashtable aa = new Hashtable();
1249     System.out.println("my %aa = {");
1250     // invert property hashes
1251     Enumeration prop = propHash.keys();
1252     while (prop.hasMoreElements())
1253     {
1254       String pname = (String) prop.nextElement();
1255       Hashtable phash = (Hashtable) propHash.get(pname);
1256       Enumeration res = phash.keys();
1257       while (res.hasMoreElements())
1258       {
1259         String rname = (String) res.nextElement();
1260         Vector aprops = (Vector) aa.get(rname);
1261         if (aprops == null)
1262         {
1263           aprops = new Vector();
1264           aa.put(rname, aprops);
1265         }
1266         Integer hasprop = (Integer) phash.get(rname);
1267         if (hasprop.intValue() == 1)
1268         {
1269           aprops.addElement(pname);
1270         }
1271       }
1272     }
1273     Enumeration res = aa.keys();
1274     while (res.hasMoreElements())
1275     {
1276       String rname = (String) res.nextElement();
1277
1278       System.out.print("'" + rname + "' => [");
1279       Enumeration props = ((Vector) aa.get(rname)).elements();
1280       while (props.hasMoreElements())
1281       {
1282         System.out.print("'" + (String) props.nextElement() + "'");
1283         if (props.hasMoreElements())
1284         {
1285           System.out.println(", ");
1286         }
1287       }
1288       System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1289     }
1290     System.out.println("};");
1291   }
1292   // to here
1293 }