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