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