JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / schemes / ResidueProperties.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.schemes;
22
23 import jalview.analysis.scoremodels.FeatureScoreModel;
24 import jalview.analysis.scoremodels.PIDScoreModel;
25 import jalview.api.analysis.ScoreModelI;
26
27 import java.awt.Color;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Enumeration;
31 import java.util.HashMap;
32 import java.util.Hashtable;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Vector;
36
37 public class ResidueProperties
38 {
39   public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable<String, ScoreModelI>();
40
41   // Stores residue codes/names and colours and other things
42   public static final int[] aaIndex; // aaHash version 2.1.1 and below
43
44   public static final int[] nucleotideIndex;
45
46   public static final int[] purinepyrimidineIndex;
47
48   public static final Map<String, Integer> aa3Hash = new HashMap<String, Integer>();
49
50   public static final Map<String, String> aa2Triplet = new HashMap<String, String>();
51
52   public static final Map<String, String> nucleotideName = new HashMap<String, String>();
53
54   // lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET)
55   public static final Map<String, String> modifications = new HashMap<String, String>();
56
57   static
58   {
59     aaIndex = new int[255];
60     for (int i = 0; i < 255; i++)
61     {
62       aaIndex[i] = 23;
63     }
64
65     aaIndex['A'] = 0;
66     aaIndex['R'] = 1;
67     aaIndex['N'] = 2;
68     aaIndex['D'] = 3;
69     aaIndex['C'] = 4;
70     aaIndex['Q'] = 5;
71     aaIndex['E'] = 6;
72     aaIndex['G'] = 7;
73     aaIndex['H'] = 8;
74     aaIndex['I'] = 9;
75     aaIndex['L'] = 10;
76     aaIndex['K'] = 11;
77     aaIndex['M'] = 12;
78     aaIndex['F'] = 13;
79     aaIndex['P'] = 14;
80     aaIndex['S'] = 15;
81     aaIndex['T'] = 16;
82     aaIndex['W'] = 17;
83     aaIndex['Y'] = 18;
84     aaIndex['V'] = 19;
85     aaIndex['B'] = 20;
86     aaIndex['Z'] = 21;
87     aaIndex['X'] = 22;
88     aaIndex['U'] = 22;
89     aaIndex['a'] = 0;
90     aaIndex['r'] = 1;
91     aaIndex['n'] = 2;
92     aaIndex['d'] = 3;
93     aaIndex['c'] = 4;
94     aaIndex['q'] = 5;
95     aaIndex['e'] = 6;
96     aaIndex['g'] = 7;
97     aaIndex['h'] = 8;
98     aaIndex['i'] = 9;
99     aaIndex['l'] = 10;
100     aaIndex['k'] = 11;
101     aaIndex['m'] = 12;
102     aaIndex['f'] = 13;
103     aaIndex['p'] = 14;
104     aaIndex['s'] = 15;
105     aaIndex['t'] = 16;
106     aaIndex['w'] = 17;
107     aaIndex['y'] = 18;
108     aaIndex['v'] = 19;
109     aaIndex['b'] = 20;
110     aaIndex['z'] = 21;
111     aaIndex['x'] = 22;
112     aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
113     // extend subt. matrices
114   }
115
116   /**
117    * maximum (gap) index for matrices involving protein alphabet
118    */
119   public final static int maxProteinIndex = 23;
120
121   /**
122    * maximum (gap) index for matrices involving nucleotide alphabet
123    */
124   public final static int maxNucleotideIndex = 10;
125
126   static
127   {
128     nucleotideIndex = new int[255];
129     for (int i = 0; i < 255; i++)
130     {
131       nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
132     }
133
134     nucleotideIndex['A'] = 0;
135     nucleotideIndex['a'] = 0;
136     nucleotideIndex['C'] = 1;
137     nucleotideIndex['c'] = 1;
138     nucleotideIndex['G'] = 2;
139     nucleotideIndex['g'] = 2;
140     nucleotideIndex['T'] = 3;
141     nucleotideIndex['t'] = 3;
142     nucleotideIndex['U'] = 4;
143     nucleotideIndex['u'] = 4;
144     nucleotideIndex['I'] = 5;
145     nucleotideIndex['i'] = 5;
146     nucleotideIndex['X'] = 6;
147     nucleotideIndex['x'] = 6;
148     nucleotideIndex['R'] = 7;
149     nucleotideIndex['r'] = 7;
150     nucleotideIndex['Y'] = 8;
151     nucleotideIndex['y'] = 8;
152     nucleotideIndex['N'] = 9;
153     nucleotideIndex['n'] = 9;
154
155     nucleotideName.put("A", "Adenine");
156     nucleotideName.put("a", "Adenine");
157     nucleotideName.put("G", "Guanine");
158     nucleotideName.put("g", "Guanine");
159     nucleotideName.put("C", "Cytosine");
160     nucleotideName.put("c", "Cytosine");
161     nucleotideName.put("T", "Thymine");
162     nucleotideName.put("t", "Thymine");
163     nucleotideName.put("U", "Uracil");
164     nucleotideName.put("u", "Uracil");
165     nucleotideName.put("I", "Inosine");
166     nucleotideName.put("i", "Inosine");
167     nucleotideName.put("X", "Xanthine");
168     nucleotideName.put("x", "Xanthine");
169     nucleotideName.put("R", "Unknown Purine");
170     nucleotideName.put("r", "Unknown Purine");
171     nucleotideName.put("Y", "Unknown Pyrimidine");
172     nucleotideName.put("y", "Unknown Pyrimidine");
173     nucleotideName.put("N", "Unknown");
174     nucleotideName.put("n", "Unknown");
175     nucleotideName.put("W", "Weak nucleotide (A or T)");
176     nucleotideName.put("w", "Weak nucleotide (A or T)");
177     nucleotideName.put("S", "Strong nucleotide (G or C)");
178     nucleotideName.put("s", "Strong nucleotide (G or C)");
179     nucleotideName.put("M", "Amino (A or C)");
180     nucleotideName.put("m", "Amino (A or C)");
181     nucleotideName.put("K", "Keto (G or T)");
182     nucleotideName.put("k", "Keto (G or T)");
183     nucleotideName.put("B", "Not A (G or C or T)");
184     nucleotideName.put("b", "Not A (G or C or T)");
185     nucleotideName.put("H", "Not G (A or C or T)");
186     nucleotideName.put("h", "Not G (A or C or T)");
187     nucleotideName.put("D", "Not C (A or G or T)");
188     nucleotideName.put("d", "Not C (A or G or T)");
189     nucleotideName.put("V", "Not T (A or G or C");
190     nucleotideName.put("v", "Not T (A or G or C");
191
192   }
193
194   static
195   {
196     purinepyrimidineIndex = new int[255];
197     for (int i = 0; i < 255; i++)
198     {
199       purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
200       // gaps.
201     }
202
203     purinepyrimidineIndex['A'] = 0;
204     purinepyrimidineIndex['a'] = 0;
205     purinepyrimidineIndex['C'] = 1;
206     purinepyrimidineIndex['c'] = 1;
207     purinepyrimidineIndex['G'] = 0;
208     purinepyrimidineIndex['g'] = 0;
209     purinepyrimidineIndex['T'] = 1;
210     purinepyrimidineIndex['t'] = 1;
211     purinepyrimidineIndex['U'] = 1;
212     purinepyrimidineIndex['u'] = 1;
213     purinepyrimidineIndex['I'] = 2;
214     purinepyrimidineIndex['i'] = 2;
215     purinepyrimidineIndex['X'] = 2;
216     purinepyrimidineIndex['x'] = 2;
217     purinepyrimidineIndex['R'] = 0;
218     purinepyrimidineIndex['r'] = 0;
219     purinepyrimidineIndex['Y'] = 1;
220     purinepyrimidineIndex['y'] = 1;
221     purinepyrimidineIndex['N'] = 2;
222     purinepyrimidineIndex['n'] = 2;
223   }
224
225   static
226   {
227     aa3Hash.put("ALA", Integer.valueOf(0));
228     aa3Hash.put("ARG", Integer.valueOf(1));
229     aa3Hash.put("ASN", Integer.valueOf(2));
230     aa3Hash.put("ASP", Integer.valueOf(3)); // D
231     aa3Hash.put("CYS", Integer.valueOf(4));
232     aa3Hash.put("GLN", Integer.valueOf(5)); // Q
233     aa3Hash.put("GLU", Integer.valueOf(6)); // E
234     aa3Hash.put("GLY", Integer.valueOf(7));
235     aa3Hash.put("HIS", Integer.valueOf(8));
236     aa3Hash.put("ILE", Integer.valueOf(9));
237     aa3Hash.put("LEU", Integer.valueOf(10));
238     aa3Hash.put("LYS", Integer.valueOf(11));
239     aa3Hash.put("MET", Integer.valueOf(12));
240     aa3Hash.put("PHE", Integer.valueOf(13));
241     aa3Hash.put("PRO", Integer.valueOf(14));
242     aa3Hash.put("SER", Integer.valueOf(15));
243     aa3Hash.put("THR", Integer.valueOf(16));
244     aa3Hash.put("TRP", Integer.valueOf(17));
245     aa3Hash.put("TYR", Integer.valueOf(18));
246     aa3Hash.put("VAL", Integer.valueOf(19));
247     // IUB Nomenclature for ambiguous peptides
248     aa3Hash.put("ASX", Integer.valueOf(20)); // "B";
249     aa3Hash.put("GLX", Integer.valueOf(21)); // Z
250     aa3Hash.put("XAA", Integer.valueOf(22)); // X unknown
251     aa3Hash.put("-", Integer.valueOf(23));
252     aa3Hash.put("*", Integer.valueOf(23));
253     aa3Hash.put(".", Integer.valueOf(23));
254     aa3Hash.put(" ", Integer.valueOf(23));
255     aa3Hash.put("Gap", Integer.valueOf(23));
256     aa3Hash.put("UR3", Integer.valueOf(24));
257   }
258
259   static
260   {
261     aa2Triplet.put("A", "ALA");
262     aa2Triplet.put("a", "ALA");
263     aa2Triplet.put("R", "ARG");
264     aa2Triplet.put("r", "ARG");
265     aa2Triplet.put("N", "ASN");
266     aa2Triplet.put("n", "ASN");
267     aa2Triplet.put("D", "ASP");
268     aa2Triplet.put("d", "ASP");
269     aa2Triplet.put("C", "CYS");
270     aa2Triplet.put("c", "CYS");
271     aa2Triplet.put("Q", "GLN");
272     aa2Triplet.put("q", "GLN");
273     aa2Triplet.put("E", "GLU");
274     aa2Triplet.put("e", "GLU");
275     aa2Triplet.put("G", "GLY");
276     aa2Triplet.put("g", "GLY");
277     aa2Triplet.put("H", "HIS");
278     aa2Triplet.put("h", "HIS");
279     aa2Triplet.put("I", "ILE");
280     aa2Triplet.put("i", "ILE");
281     aa2Triplet.put("L", "LEU");
282     aa2Triplet.put("l", "LEU");
283     aa2Triplet.put("K", "LYS");
284     aa2Triplet.put("k", "LYS");
285     aa2Triplet.put("M", "MET");
286     aa2Triplet.put("m", "MET");
287     aa2Triplet.put("F", "PHE");
288     aa2Triplet.put("f", "PHE");
289     aa2Triplet.put("P", "PRO");
290     aa2Triplet.put("p", "PRO");
291     aa2Triplet.put("S", "SER");
292     aa2Triplet.put("s", "SER");
293     aa2Triplet.put("T", "THR");
294     aa2Triplet.put("t", "THR");
295     aa2Triplet.put("W", "TRP");
296     aa2Triplet.put("w", "TRP");
297     aa2Triplet.put("Y", "TYR");
298     aa2Triplet.put("y", "TYR");
299     aa2Triplet.put("V", "VAL");
300     aa2Triplet.put("v", "VAL");
301   }
302
303   public static final String[] aa = { "A", "R", "N", "D", "C", "Q", "E",
304       "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B",
305       "Z", "X", "_", "*", ".", " ", "U" };
306
307   public static final Color midBlue = new Color(100, 100, 255);
308
309   // not currently in use
310   // public static final Vector<Color> scaleColours = new Vector<Color>();
311   // static
312   // {
313   // scaleColours.addElement(new Color(114, 0, 147));
314   // scaleColours.addElement(new Color(156, 0, 98));
315   // scaleColours.addElement(new Color(190, 0, 0));
316   // scaleColours.addElement(Color.red);
317   // scaleColours.addElement(new Color(255, 125, 0));
318   // scaleColours.addElement(Color.orange);
319   // scaleColours.addElement(new Color(255, 194, 85));
320   // scaleColours.addElement(Color.yellow);
321   // scaleColours.addElement(new Color(255, 255, 181));
322   // scaleColours.addElement(Color.white);
323   // }
324
325   public static final Color[] taylor = { new Color(204, 255, 0),
326       // A Greenish-yellowy-yellow
327       new Color(0, 0, 255), // R Blueish-bluey-blue
328       new Color(204, 0, 255), // N Blueish-reddy-blue
329       new Color(255, 0, 0), // D Reddish-reddy-red
330       new Color(255, 255, 0), // C Yellowish-yellowy-yellow
331       new Color(255, 0, 204), // Q Reddish-bluey-red
332       new Color(255, 0, 102), // E Blueish-reddy-red
333       new Color(255, 153, 0), // G Yellowy-reddy-yellow
334       new Color(0, 102, 255), // H Greenish-bluey-blue
335       new Color(102, 255, 0), // I Greenish-yellowy-green
336       new Color(51, 255, 0), // L Yellowish-greeny-green
337       new Color(102, 0, 255), // K Reddish-bluey-blue
338       new Color(0, 255, 0), // M Greenish-greeny-green
339       new Color(0, 255, 102), // F Blueish-greeny-green
340       new Color(255, 204, 0), // P Reddish-yellowy-yellow
341       new Color(255, 51, 0), // S Yellowish-reddy-red
342       new Color(255, 102, 0), // T Reddish-yellowy-red
343       new Color(0, 204, 255), // W Blueish-greeny-green
344       new Color(0, 255, 204), // Y Greenish-bluey-green
345       new Color(153, 255, 0), // V Yellowish-greeny-yellow
346       Color.white, // B
347       Color.white, // Z
348       Color.white, // X
349       Color.white, // -
350       Color.white, // *
351       Color.white // .
352   };
353
354   public static final Color[] nucleotide = { new Color(100, 247, 63), // A
355       new Color(255, 179, 64), // C
356       new Color(235, 65, 60), // G
357       new Color(60, 136, 238), // T
358       new Color(60, 136, 238), // U
359       Color.white, // I (inosine)
360       Color.white, // X (xanthine)
361       Color.white, // R
362       Color.white, // Y
363       Color.white, // N
364       Color.white, // Gap
365   };
366
367   // Added for PurinePyrimidineColourScheme
368   public static final Color[] purinepyrimidine = {
369       new Color(255, 131, 250), // A, G, R purines purplish/orchid
370       new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
371       Color.white, // all other nucleotides
372       Color.white // Gap
373   };
374
375   // Zappo
376   public static final Color[] zappo = { Color.pink, // A
377       midBlue, // R
378       Color.green, // N
379       Color.red, // D
380       Color.yellow, // C
381       Color.green, // Q
382       Color.red, // E
383       Color.magenta, // G
384       midBlue,// Color.red, // H
385       Color.pink, // I
386       Color.pink, // L
387       midBlue, // K
388       Color.pink, // M
389       Color.orange, // F
390       Color.magenta, // P
391       Color.green, // S
392       Color.green, // T
393       Color.orange, // W
394       Color.orange, // Y
395       Color.pink, // V
396       Color.white, // B
397       Color.white, // Z
398       Color.white, // X
399       Color.white, // -
400       Color.white, // *
401       Color.white, // .
402       Color.white // ' '
403   };
404
405   // Dunno where I got these numbers from
406   public static final double[] hyd2 = { 0.62, // A
407       0.29, // R
408       -0.90, // N
409       -0.74, // D
410       1.19, // C
411       0.48, // Q
412       -0.40, // E
413       1.38, // G
414       -1.50, // H
415       1.06, // I
416       0.64, // L
417       -0.78, // K
418       0.12, // M
419       -0.85, // F
420       -2.53, // P
421       -0.18, // S
422       -0.05, // T
423       1.08, // W
424       0.81, // Y
425       0.0, // V
426       0.26, // B
427       0.0, // Z
428       0.0 // X
429   };
430
431   public static final double[] helix = { 1.42, 0.98, 0.67, 1.01, 0.70,
432       1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, 1.45, 1.13, 0.57, 0.77,
433       0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
434
435   public static final double helixmin = 0.57;
436
437   public static final double helixmax = 1.51;
438
439   public static final double[] strand = { 0.83, 0.93, 0.89, 0.54, 1.19,
440       1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, 1.05, 1.38, 0.55, 0.75,
441       1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
442
443   public static final double strandmin = 0.37;
444
445   public static final double strandmax = 1.7;
446
447   public static final double[] turn = { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98,
448       0.74, 1.56, 0.95, 0.47, 0.59, 1.01, 0.60, 0.60, 1.52, 1.43, 0.96,
449       0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0 };
450
451   public static final double turnmin = 0.47;
452
453   public static final double turnmax = 1.56;
454
455   public static final double[] buried = { 1.7, 0.1, 0.4, 0.4, 4.6, 0.3,
456       0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, 0.6, 0.8, 0.7, 1.6, 0.5,
457       2.9, 0.4, 0.3, 1.358, 0.00 };
458
459   public static final double buriedmin = 0.05;
460
461   public static final double buriedmax = 4.6;
462
463   // This is hydropathy index
464   // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
465   // 1157, 105-132, 1982
466   public static final double[] hyd = { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5,
467       -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, 2.8, -1.6, -0.8, -0.7, -0.9,
468       -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
469
470   public static final double hydmax = 4.5;
471
472   public static final double hydmin = -3.9;
473
474   // public static final double hydmax = 1.38;
475   // public static final double hydmin = -2.53;
476   private static final int[][] BLOSUM62 = {
477       { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
478           -2, 0, -2, -1, 0, -4 },
479       { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
480           -2, -3, -1, 0, -1, -4 },
481       { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
482           -3, 3, 0, -1, -4 },
483       { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
484           -3, -3, 4, 1, -1, -4 },
485       { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
486           -2, -2, -1, -3, -3, -2, -4 },
487       { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
488           -2, 0, 3, -1, -4 },
489       { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
490           -2, 1, 4, -1, -4 },
491       { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
492           -3, -3, -1, -2, -1, -4 },
493       { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
494           2, -3, 0, 0, -1, -4 },
495       { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
496           -1, 3, -3, -3, -1, -4 },
497       { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
498           -1, 1, -4, -3, -1, -4 },
499       { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
500           -2, -2, 0, 1, -1, -4 },
501       { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
502           -1, 1, -3, -1, -1, -4 },
503       { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
504           3, -1, -3, -3, -1, -4 },
505       { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
506           -4, -3, -2, -2, -1, -2, -4 },
507       { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
508           -2, 0, 0, 0, -4 },
509       { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
510           -2, 0, -1, -1, 0, -4 },
511       { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
512           11, 2, -3, -4, -3, -2, -4 },
513       { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
514           2, 7, -1, -3, -2, -1, -4 },
515       { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
516           -1, 4, -3, -2, -1, -4 },
517       { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
518           -3, -3, 4, 1, -1, -4 },
519       { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
520           -2, 1, 4, -1, -4 },
521       { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
522           -2, -1, -1, -1, -1, -1, -4 },
523       { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
524           -4, -4, -4, -4, -4, -4, 1 }, };
525
526   static final int[][] PAM250 = {
527       { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
528           0, 0, 0, 0, -8 },
529       { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
530           -2, -1, 0, -1, -8 },
531       { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
532           2, 1, 0, -8 },
533       { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
534           -2, 3, 3, -1, -8 },
535       { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
536           -8, 0, -2, -4, -5, -3, -8 },
537       { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
538           -2, 1, 3, -1, -8 },
539       { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
540           -2, 3, 3, -1, -8 },
541       { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
542           -1, 0, 0, -1, -8 },
543       { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
544           -2, 1, 2, -1, -8 },
545       { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
546           -1, 4, -2, -2, -1, -8 },
547       { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
548           -1, 2, -3, -3, -1, -8 },
549       { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
550           -2, 1, 0, -1, -8 },
551       { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
552           -2, 2, -2, -2, -1, -8 },
553       { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
554           7, -1, -4, -5, -2, -8 },
555       { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
556           -1, -1, 0, -1, -8 },
557       { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
558           -1, 0, 0, 0, -8 },
559       { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
560           0, 0, -1, 0, -8 },
561       { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
562           17, 0, -6, -5, -6, -4, -8 },
563       { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
564           10, -2, -3, -4, -2, -8 },
565       { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
566           -2, 4, -2, -2, -1, -8 },
567       { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
568           -2, 3, 2, -1, -8 },
569       { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
570           -2, 2, 3, -1, -8 },
571       { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
572           -2, -1, -1, -1, -1, -8 },
573       { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
574           -8, -8, -8, -8, -8, -8, 1 }, };
575
576   // not currently used
577   // public static final Map<String, Color> ssHash = new Hashtable<String,
578   // Color>();
579   // static
580   // {
581   // ssHash.put("H", Color.magenta);
582   // ssHash.put("E", Color.yellow);
583   // ssHash.put("-", Color.white);
584   // ssHash.put(".", Color.white);
585   // ssHash.put("S", Color.cyan);
586   // ssHash.put("T", Color.blue);
587   // ssHash.put("G", Color.pink);
588   // ssHash.put("I", Color.pink);
589   // ssHash.put("B", Color.yellow);
590   // }
591
592   /*
593    * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
594    * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
595    */
596
597   // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
598   // Will equate sequences if working with mixed nucleotide sets.
599   // treats T and U identically. R and Y weak equivalence with AG and CTU.
600   // N matches any other base weakly
601   //
602   static final int[][] DNA = { { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
603       { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
604       { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
605       { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
606       { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
607       { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
608       { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
609       { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
610       { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
611       { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
612       { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
613   };
614   /**
615    * register matrices in list
616    */
617   static
618   {
619     scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
620     scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
621     scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
622   }
623
624   public static final Color[] pidColours = { midBlue,
625       new Color(153, 153, 255),
626       // Color.lightGray,
627       new Color(204, 204, 255), };
628
629   public static final float[] pidThresholds = { 80, 60, 40, };
630
631   public static List<String> STOP = Arrays.asList("TGA", "TAA", "TAG");
632
633   public static String START = "ATG";
634
635   /**
636    * Nucleotide Ambiguity Codes
637    */
638   public static final Map<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
639
640   /**
641    * Codon triplets with additional symbols for unambiguous codons that include
642    * ambiguity codes
643    */
644   public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
645
646   /**
647    * all ambiguity codes for a given base
648    */
649   public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
650
651   static
652   {
653     /*
654      * Ambiguity codes as per http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html
655      */
656     ambiguityCodes.put("R", new String[] { "A", "G" });
657     ambiguityCodes.put("Y", new String[] { "T", "C" });
658     ambiguityCodes.put("W", new String[] { "A", "T" });
659     ambiguityCodes.put("S", new String[] { "G", "C" });
660     ambiguityCodes.put("M", new String[] { "A", "C" });
661     ambiguityCodes.put("K", new String[] { "G", "T" });
662     ambiguityCodes.put("H", new String[] { "A", "T", "C" });
663     ambiguityCodes.put("B", new String[] { "G", "T", "C" });
664     ambiguityCodes.put("V", new String[] { "G", "A", "C" });
665     ambiguityCodes.put("D", new String[] { "G", "A", "T" });
666     ambiguityCodes.put("N", new String[] { "G", "A", "T", "C" });
667
668     // Now build codon translation table
669     codonHash2.put("AAA", "K");
670     codonHash2.put("AAG", "K");
671     codonHash2.put("AAC", "N");
672     codonHash2.put("AAT", "N");
673
674     codonHash2.put("CAA", "Q");
675     codonHash2.put("CAG", "Q");
676     codonHash2.put("CAC", "H");
677     codonHash2.put("CAT", "H");
678
679     codonHash2.put("GAA", "E");
680     codonHash2.put("GAG", "E");
681     codonHash2.put("GAC", "D");
682     codonHash2.put("GAT", "D");
683
684     codonHash2.put("TAC", "Y");
685     codonHash2.put("TAT", "Y");
686
687     codonHash2.put("ACA", "T");
688     codonHash2.put("ACC", "T");
689     codonHash2.put("ACT", "T");
690     codonHash2.put("ACG", "T");
691
692     codonHash2.put("CCA", "P");
693     codonHash2.put("CCG", "P");
694     codonHash2.put("CCC", "P");
695     codonHash2.put("CCT", "P");
696
697     codonHash2.put("GCA", "A");
698     codonHash2.put("GCG", "A");
699     codonHash2.put("GCC", "A");
700     codonHash2.put("GCT", "A");
701
702     codonHash2.put("TCA", "S");
703     codonHash2.put("TCG", "S");
704     codonHash2.put("TCC", "S");
705     codonHash2.put("TCT", "S");
706     codonHash2.put("AGC", "S");
707     codonHash2.put("AGT", "S");
708
709     codonHash2.put("AGA", "R");
710     codonHash2.put("AGG", "R");
711     codonHash2.put("CGA", "R");
712     codonHash2.put("CGG", "R");
713     codonHash2.put("CGC", "R");
714     codonHash2.put("CGT", "R");
715
716     codonHash2.put("GGA", "G");
717     codonHash2.put("GGG", "G");
718     codonHash2.put("GGC", "G");
719     codonHash2.put("GGT", "G");
720
721     codonHash2.put("TGA", "*");
722     codonHash2.put("TAA", "*");
723     codonHash2.put("TAG", "*");
724
725     codonHash2.put("TGG", "W");
726
727     codonHash2.put("TGC", "C");
728     codonHash2.put("TGT", "C");
729
730     codonHash2.put("ATA", "I");
731     codonHash2.put("ATC", "I");
732     codonHash2.put("ATT", "I");
733
734     codonHash2.put("ATG", "M");
735
736     codonHash2.put("CTA", "L");
737     codonHash2.put("CTG", "L");
738     codonHash2.put("CTC", "L");
739     codonHash2.put("CTT", "L");
740     codonHash2.put("TTA", "L");
741     codonHash2.put("TTG", "L");
742
743     codonHash2.put("GTA", "V");
744     codonHash2.put("GTG", "V");
745     codonHash2.put("GTC", "V");
746     codonHash2.put("GTT", "V");
747
748     codonHash2.put("TTC", "F");
749     codonHash2.put("TTT", "F");
750
751     buildAmbiguityCodonSet();
752   }
753
754   /**
755    * programmatic generation of codons including ambiguity codes
756    */
757   public static void buildAmbiguityCodonSet()
758   {
759     if (_ambiguityCodes.size() > 0)
760     {
761       System.err
762               .println("Ignoring multiple calls to buildAmbiguityCodonSet");
763       return;
764     }
765     // Invert the ambiguity code set
766     for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
767     {
768       for (String r : acode.getValue())
769       {
770         List<String> codesfor = _ambiguityCodes.get(r);
771         if (codesfor == null)
772         {
773           _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
774         }
775         if (!codesfor.contains(acode.getKey()))
776         {
777           codesfor.add(acode.getKey());
778         }
779         else
780         {
781           System.err
782                   .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
783                           + acode.getKey() + " in residue " + r);
784         }
785       }
786     }
787     // and programmatically add in the ambiguity codes that yield the same amino
788     // acid
789     String[] unambcodons = codonHash2.keySet().toArray(
790             new String[codonHash2.size()]);
791     for (String codon : unambcodons)
792     {
793       String residue = codonHash2.get(codon);
794       String acodon[][] = new String[codon.length()][];
795       for (int i = 0, iSize = codon.length(); i < iSize; i++)
796       {
797         String _ac = "" + codon.charAt(i);
798         List<String> acodes = _ambiguityCodes.get(_ac);
799         if (acodes != null)
800         {
801           acodon[i] = acodes.toArray(new String[acodes.size()]);
802         }
803         else
804         {
805           acodon[i] = new String[] {};
806         }
807       }
808       // enumerate all combinations and test for veracity of translation
809       int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
810       for (int i = 0; i < tpos.length; i++)
811       {
812         tpos[i] = -1;
813       }
814       tpos[acodon.length - 1] = 0;
815       int ipos, j;
816       while (tpos[0] < acodon[0].length)
817       {
818         // make all codons for this combination
819         char allres[][] = new char[tpos.length][];
820         String _acodon = "";
821         for (ipos = 0; ipos < tpos.length; ipos++)
822         {
823           if (acodon[ipos].length == 0 || tpos[ipos] < 0)
824           {
825             _acodon += codon.charAt(ipos);
826             allres[ipos] = new char[] { codon.charAt(ipos) };
827           }
828           else
829           {
830             _acodon += acodon[ipos][tpos[ipos]];
831             String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
832             allres[ipos] = new char[altbase.length];
833             j = 0;
834             for (String ab : altbase)
835             {
836               allres[ipos][j++] = ab.charAt(0);
837             }
838           }
839         }
840         // test all codons for this combination
841         for (ipos = 0; ipos < cpos.length; ipos++)
842         {
843           cpos[ipos] = 0;
844         }
845         boolean valid = true;
846         do
847         {
848           String _codon = "";
849           for (j = 0; j < cpos.length; j++)
850           {
851             _codon += allres[j][cpos[j]];
852           }
853           String tr = codonHash2.get(_codon);
854           if (valid = (tr != null && tr.equals(residue)))
855           {
856             // advance to next combination
857             ipos = acodon.length - 1;
858             while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
859             {
860               cpos[ipos] = 0;
861               ipos--;
862             }
863           }
864         } while (valid && cpos[0] < allres[0].length);
865         if (valid)
866         {
867           // Add this to the set of codons we will translate
868           // System.out.println("Adding ambiguity codon: " + _acodon + " for "
869           // + residue);
870           codonHash2.put(_acodon, residue);
871         }
872         else
873         {
874           // System.err.println("Rejecting ambiguity codon: " + _acodon
875           // + " for " + residue);
876         }
877         // next combination
878         ipos = acodon.length - 1;
879         while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
880         {
881           tpos[ipos] = -1;
882           ipos--;
883         }
884       }
885     }
886   }
887
888   // Stores residue codes/names and colours and other things
889   public static Map<String, Map<String, Integer>> propHash = new Hashtable<String, Map<String, Integer>>();
890
891   public static Map<String, Integer> hydrophobic = new Hashtable<String, Integer>();
892
893   public static Map<String, Integer> polar = new Hashtable<String, Integer>();
894
895   public static Map<String, Integer> small = new Hashtable<String, Integer>();
896
897   public static Map<String, Integer> positive = new Hashtable<String, Integer>();
898
899   public static Map<String, Integer> negative = new Hashtable<String, Integer>();
900
901   public static Map<String, Integer> charged = new Hashtable<String, Integer>();
902
903   public static Map<String, Integer> aromatic = new Hashtable<String, Integer>();
904
905   public static Map<String, Integer> aliphatic = new Hashtable<String, Integer>();
906
907   public static Map<String, Integer> tiny = new Hashtable<String, Integer>();
908
909   public static Map<String, Integer> proline = new Hashtable<String, Integer>();
910
911   static
912   {
913     hydrophobic.put("I", Integer.valueOf(1));
914     hydrophobic.put("L", Integer.valueOf(1));
915     hydrophobic.put("V", Integer.valueOf(1));
916     hydrophobic.put("C", Integer.valueOf(1));
917     hydrophobic.put("A", Integer.valueOf(1));
918     hydrophobic.put("G", Integer.valueOf(1));
919     hydrophobic.put("M", Integer.valueOf(1));
920     hydrophobic.put("F", Integer.valueOf(1));
921     hydrophobic.put("Y", Integer.valueOf(1));
922     hydrophobic.put("W", Integer.valueOf(1));
923     hydrophobic.put("H", Integer.valueOf(1));
924     hydrophobic.put("K", Integer.valueOf(1));
925     hydrophobic.put("X", Integer.valueOf(1));
926     hydrophobic.put("-", Integer.valueOf(1));
927     hydrophobic.put("*", Integer.valueOf(1));
928     hydrophobic.put("R", Integer.valueOf(0));
929     hydrophobic.put("E", Integer.valueOf(0));
930     hydrophobic.put("Q", Integer.valueOf(0));
931     hydrophobic.put("D", Integer.valueOf(0));
932     hydrophobic.put("N", Integer.valueOf(0));
933     hydrophobic.put("S", Integer.valueOf(0));
934     hydrophobic.put("T", Integer.valueOf(0));
935     hydrophobic.put("P", Integer.valueOf(0));
936   }
937
938   static
939   {
940     polar.put("Y", Integer.valueOf(1));
941     polar.put("W", Integer.valueOf(1));
942     polar.put("H", Integer.valueOf(1));
943     polar.put("K", Integer.valueOf(1));
944     polar.put("R", Integer.valueOf(1));
945     polar.put("E", Integer.valueOf(1));
946     polar.put("Q", Integer.valueOf(1));
947     polar.put("D", Integer.valueOf(1));
948     polar.put("N", Integer.valueOf(1));
949     polar.put("S", Integer.valueOf(1));
950     polar.put("T", Integer.valueOf(1));
951     polar.put("X", Integer.valueOf(1));
952     polar.put("-", Integer.valueOf(1));
953     polar.put("*", Integer.valueOf(1));
954     polar.put("I", Integer.valueOf(0));
955     polar.put("L", Integer.valueOf(0));
956     polar.put("V", Integer.valueOf(0));
957     polar.put("C", Integer.valueOf(0));
958     polar.put("A", Integer.valueOf(0));
959     polar.put("G", Integer.valueOf(0));
960     polar.put("M", Integer.valueOf(0));
961     polar.put("F", Integer.valueOf(0));
962     polar.put("P", Integer.valueOf(0));
963   }
964
965   static
966   {
967     small.put("I", Integer.valueOf(0));
968     small.put("L", Integer.valueOf(0));
969     small.put("V", Integer.valueOf(1));
970     small.put("C", Integer.valueOf(1));
971     small.put("A", Integer.valueOf(1));
972     small.put("G", Integer.valueOf(1));
973     small.put("M", Integer.valueOf(0));
974     small.put("F", Integer.valueOf(0));
975     small.put("Y", Integer.valueOf(0));
976     small.put("W", Integer.valueOf(0));
977     small.put("H", Integer.valueOf(0));
978     small.put("K", Integer.valueOf(0));
979     small.put("R", Integer.valueOf(0));
980     small.put("E", Integer.valueOf(0));
981     small.put("Q", Integer.valueOf(0));
982     small.put("D", Integer.valueOf(1));
983     small.put("N", Integer.valueOf(1));
984     small.put("S", Integer.valueOf(1));
985     small.put("T", Integer.valueOf(1));
986     small.put("P", Integer.valueOf(1));
987     small.put("-", Integer.valueOf(1));
988     small.put("*", Integer.valueOf(1));
989   }
990
991   static
992   {
993     positive.put("I", Integer.valueOf(0));
994     positive.put("L", Integer.valueOf(0));
995     positive.put("V", Integer.valueOf(0));
996     positive.put("C", Integer.valueOf(0));
997     positive.put("A", Integer.valueOf(0));
998     positive.put("G", Integer.valueOf(0));
999     positive.put("M", Integer.valueOf(0));
1000     positive.put("F", Integer.valueOf(0));
1001     positive.put("Y", Integer.valueOf(0));
1002     positive.put("W", Integer.valueOf(0));
1003     positive.put("H", Integer.valueOf(1));
1004     positive.put("K", Integer.valueOf(1));
1005     positive.put("R", Integer.valueOf(1));
1006     positive.put("E", Integer.valueOf(0));
1007     positive.put("Q", Integer.valueOf(0));
1008     positive.put("D", Integer.valueOf(0));
1009     positive.put("N", Integer.valueOf(0));
1010     positive.put("S", Integer.valueOf(0));
1011     positive.put("T", Integer.valueOf(0));
1012     positive.put("P", Integer.valueOf(0));
1013     positive.put("-", Integer.valueOf(1));
1014     positive.put("*", Integer.valueOf(1));
1015   }
1016
1017   static
1018   {
1019     negative.put("I", Integer.valueOf(0));
1020     negative.put("L", Integer.valueOf(0));
1021     negative.put("V", Integer.valueOf(0));
1022     negative.put("C", Integer.valueOf(0));
1023     negative.put("A", Integer.valueOf(0));
1024     negative.put("G", Integer.valueOf(0));
1025     negative.put("M", Integer.valueOf(0));
1026     negative.put("F", Integer.valueOf(0));
1027     negative.put("Y", Integer.valueOf(0));
1028     negative.put("W", Integer.valueOf(0));
1029     negative.put("H", Integer.valueOf(0));
1030     negative.put("K", Integer.valueOf(0));
1031     negative.put("R", Integer.valueOf(0));
1032     negative.put("E", Integer.valueOf(1));
1033     negative.put("Q", Integer.valueOf(0));
1034     negative.put("D", Integer.valueOf(1));
1035     negative.put("N", Integer.valueOf(0));
1036     negative.put("S", Integer.valueOf(0));
1037     negative.put("T", Integer.valueOf(0));
1038     negative.put("P", Integer.valueOf(0));
1039     negative.put("-", Integer.valueOf(1));
1040     negative.put("*", Integer.valueOf(1));
1041   }
1042
1043   static
1044   {
1045     charged.put("I", Integer.valueOf(0));
1046     charged.put("L", Integer.valueOf(0));
1047     charged.put("V", Integer.valueOf(0));
1048     charged.put("C", Integer.valueOf(0));
1049     charged.put("A", Integer.valueOf(0));
1050     charged.put("G", Integer.valueOf(0));
1051     charged.put("M", Integer.valueOf(0));
1052     charged.put("F", Integer.valueOf(0));
1053     charged.put("Y", Integer.valueOf(0));
1054     charged.put("W", Integer.valueOf(0));
1055     charged.put("H", Integer.valueOf(1));
1056     charged.put("K", Integer.valueOf(1));
1057     charged.put("R", Integer.valueOf(1));
1058     charged.put("E", Integer.valueOf(1));
1059     charged.put("Q", Integer.valueOf(0));
1060     charged.put("D", Integer.valueOf(1));
1061     charged.put("N", Integer.valueOf(0)); // Asparagine is polar but not
1062                                           // charged.
1063     // Alternative would be charged and
1064     // negative (in basic form)?
1065     charged.put("S", Integer.valueOf(0));
1066     charged.put("T", Integer.valueOf(0));
1067     charged.put("P", Integer.valueOf(0));
1068     charged.put("-", Integer.valueOf(1));
1069     charged.put("*", Integer.valueOf(1));
1070   }
1071
1072   static
1073   {
1074     aromatic.put("I", Integer.valueOf(0));
1075     aromatic.put("L", Integer.valueOf(0));
1076     aromatic.put("V", Integer.valueOf(0));
1077     aromatic.put("C", Integer.valueOf(0));
1078     aromatic.put("A", Integer.valueOf(0));
1079     aromatic.put("G", Integer.valueOf(0));
1080     aromatic.put("M", Integer.valueOf(0));
1081     aromatic.put("F", Integer.valueOf(1));
1082     aromatic.put("Y", Integer.valueOf(1));
1083     aromatic.put("W", Integer.valueOf(1));
1084     aromatic.put("H", Integer.valueOf(1));
1085     aromatic.put("K", Integer.valueOf(0));
1086     aromatic.put("R", Integer.valueOf(0));
1087     aromatic.put("E", Integer.valueOf(0));
1088     aromatic.put("Q", Integer.valueOf(0));
1089     aromatic.put("D", Integer.valueOf(0));
1090     aromatic.put("N", Integer.valueOf(0));
1091     aromatic.put("S", Integer.valueOf(0));
1092     aromatic.put("T", Integer.valueOf(0));
1093     aromatic.put("P", Integer.valueOf(0));
1094     aromatic.put("-", Integer.valueOf(1));
1095     aromatic.put("*", Integer.valueOf(1));
1096   }
1097
1098   static
1099   {
1100     aliphatic.put("I", Integer.valueOf(1));
1101     aliphatic.put("L", Integer.valueOf(1));
1102     aliphatic.put("V", Integer.valueOf(1));
1103     aliphatic.put("C", Integer.valueOf(0));
1104     aliphatic.put("A", Integer.valueOf(0));
1105     aliphatic.put("G", Integer.valueOf(0));
1106     aliphatic.put("M", Integer.valueOf(0));
1107     aliphatic.put("F", Integer.valueOf(0));
1108     aliphatic.put("Y", Integer.valueOf(0));
1109     aliphatic.put("W", Integer.valueOf(0));
1110     aliphatic.put("H", Integer.valueOf(0));
1111     aliphatic.put("K", Integer.valueOf(0));
1112     aliphatic.put("R", Integer.valueOf(0));
1113     aliphatic.put("E", Integer.valueOf(0));
1114     aliphatic.put("Q", Integer.valueOf(0));
1115     aliphatic.put("D", Integer.valueOf(0));
1116     aliphatic.put("N", Integer.valueOf(0));
1117     aliphatic.put("S", Integer.valueOf(0));
1118     aliphatic.put("T", Integer.valueOf(0));
1119     aliphatic.put("P", Integer.valueOf(0));
1120     aliphatic.put("-", Integer.valueOf(1));
1121     aliphatic.put("*", Integer.valueOf(1));
1122   }
1123
1124   static
1125   {
1126     tiny.put("I", Integer.valueOf(0));
1127     tiny.put("L", Integer.valueOf(0));
1128     tiny.put("V", Integer.valueOf(0));
1129     tiny.put("C", Integer.valueOf(0));
1130     tiny.put("A", Integer.valueOf(1));
1131     tiny.put("G", Integer.valueOf(1));
1132     tiny.put("M", Integer.valueOf(0));
1133     tiny.put("F", Integer.valueOf(0));
1134     tiny.put("Y", Integer.valueOf(0));
1135     tiny.put("W", Integer.valueOf(0));
1136     tiny.put("H", Integer.valueOf(0));
1137     tiny.put("K", Integer.valueOf(0));
1138     tiny.put("R", Integer.valueOf(0));
1139     tiny.put("E", Integer.valueOf(0));
1140     tiny.put("Q", Integer.valueOf(0));
1141     tiny.put("D", Integer.valueOf(0));
1142     tiny.put("N", Integer.valueOf(0));
1143     tiny.put("S", Integer.valueOf(1));
1144     tiny.put("T", Integer.valueOf(0));
1145     tiny.put("P", Integer.valueOf(0));
1146     tiny.put("-", Integer.valueOf(1));
1147     tiny.put("*", Integer.valueOf(1));
1148   }
1149
1150   static
1151   {
1152     proline.put("I", Integer.valueOf(0));
1153     proline.put("L", Integer.valueOf(0));
1154     proline.put("V", Integer.valueOf(0));
1155     proline.put("C", Integer.valueOf(0));
1156     proline.put("A", Integer.valueOf(0));
1157     proline.put("G", Integer.valueOf(0));
1158     proline.put("M", Integer.valueOf(0));
1159     proline.put("F", Integer.valueOf(0));
1160     proline.put("Y", Integer.valueOf(0));
1161     proline.put("W", Integer.valueOf(0));
1162     proline.put("H", Integer.valueOf(0));
1163     proline.put("K", Integer.valueOf(0));
1164     proline.put("R", Integer.valueOf(0));
1165     proline.put("E", Integer.valueOf(0));
1166     proline.put("Q", Integer.valueOf(0));
1167     proline.put("D", Integer.valueOf(0));
1168     proline.put("N", Integer.valueOf(0));
1169     proline.put("S", Integer.valueOf(0));
1170     proline.put("T", Integer.valueOf(0));
1171     proline.put("P", Integer.valueOf(1));
1172     proline.put("-", Integer.valueOf(1));
1173     proline.put("*", Integer.valueOf(1));
1174   }
1175
1176   static
1177   {
1178     propHash.put("hydrophobic", hydrophobic);
1179     propHash.put("small", small);
1180     propHash.put("positive", positive);
1181     propHash.put("negative", negative);
1182     propHash.put("charged", charged);
1183     propHash.put("aromatic", aromatic);
1184     propHash.put("aliphatic", aliphatic);
1185     propHash.put("tiny", tiny);
1186     propHash.put("proline", proline);
1187     propHash.put("polar", polar);
1188   }
1189   static
1190   {
1191     int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1192     for (int i = 0; i < maxProteinIndex; i++)
1193     {
1194       int maxF = 0, maxP = 0, maxEP = 0;
1195       String ic = "";
1196       if (aa.length > i)
1197       {
1198         ic += aa[i];
1199       }
1200       else
1201       {
1202         ic = "-";
1203       }
1204       for (int j = i + 1; j < maxProteinIndex; j++)
1205       {
1206         String jc = "";
1207         if (aa.length > j)
1208         {
1209           jc += aa[j];
1210         }
1211         else
1212         {
1213           jc = "-";
1214         }
1215         propMatrixF[i][j] = 0;
1216         propMatrixPos[i][j] = 0;
1217         propMatrixEpos[i][j] = 0;
1218         for (String ph : propHash.keySet())
1219         {
1220           Map<String, Integer> pph = propHash.get(ph);
1221           if (pph.get(ic) != null && pph.get(jc) != null)
1222           {
1223             int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1224             // Still working on these definitions.
1225             propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1226             propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1227             propMatrixF[i][j] += icp == jcp ? 2 : 0;
1228             propMatrixF[j][i] += icp == jcp ? 2 : 0;
1229             propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1230             propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1231           }
1232         }
1233         if (maxF < propMatrixF[i][j])
1234         {
1235           maxF = propMatrixF[i][j];
1236         }
1237         if (maxP < propMatrixPos[i][j])
1238         {
1239           maxP = propMatrixPos[i][j];
1240         }
1241         if (maxEP < propMatrixEpos[i][j])
1242         {
1243           maxEP = propMatrixEpos[i][j];
1244         }
1245       }
1246       propMatrixF[i][i] = maxF;
1247       propMatrixPos[i][i] = maxP;
1248       propMatrixEpos[i][i] = maxEP;
1249     }
1250     // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1251     // scoreMatrices.put("Conservation Pos", new
1252     // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1253     // scoreMatrices.put("Conservation Both", new
1254     // ScoreMatrix("Conservation Both",propMatrixF,0));
1255     // scoreMatrices.put("Conservation EnhPos", new
1256     // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1257     scoreMatrices.put("PID", new PIDScoreModel());
1258     scoreMatrices.put("Displayed Features", new FeatureScoreModel());
1259   }
1260
1261   private ResidueProperties()
1262   {
1263   }
1264
1265   public static double getHydmax()
1266   {
1267     return hydmax;
1268   }
1269
1270   public static double getHydmin()
1271   {
1272     return hydmin;
1273   }
1274
1275   public static double[] getHyd()
1276   {
1277     return hyd;
1278   }
1279
1280   public static Map<String, Integer> getAA3Hash()
1281   {
1282     return aa3Hash;
1283   }
1284
1285   public static int[][] getDNA()
1286   {
1287     return ResidueProperties.DNA;
1288   }
1289
1290   public static int[][] getBLOSUM62()
1291   {
1292     return ResidueProperties.BLOSUM62;
1293   }
1294
1295   public static int getPAM250(String A1, String A2)
1296   {
1297     return getPAM250(A1.charAt(0), A2.charAt(0));
1298   }
1299
1300   public static int getBLOSUM62(char c1, char c2)
1301   {
1302     int pog = 0;
1303
1304     try
1305     {
1306       int a = aaIndex[c1];
1307       int b = aaIndex[c2];
1308
1309       pog = ResidueProperties.BLOSUM62[a][b];
1310     } catch (Exception e)
1311     {
1312       // System.out.println("Unknown residue in " + A1 + " " + A2);
1313     }
1314
1315     return pog;
1316   }
1317
1318   public static String codonTranslate(String lccodon)
1319   {
1320     String cdn = codonHash2.get(lccodon.toUpperCase());
1321     if ("*".equals(cdn))
1322     {
1323       return "STOP";
1324     }
1325     return cdn;
1326   }
1327
1328   public static int[][] getDefaultPeptideMatrix()
1329   {
1330     return ResidueProperties.getBLOSUM62();
1331   }
1332
1333   public static int[][] getDefaultDnaMatrix()
1334   {
1335     return ResidueProperties.getDNA();
1336   }
1337
1338   /**
1339    * get a ScoreMatrix based on its string name
1340    * 
1341    * @param pwtype
1342    * @return matrix in scoreMatrices with key pwtype or null
1343    */
1344   public static ScoreMatrix getScoreMatrix(String pwtype)
1345   {
1346     Object val = scoreMatrices.get(pwtype);
1347     if (val != null && val instanceof ScoreMatrix)
1348     {
1349       return (ScoreMatrix) val;
1350     }
1351     return null;
1352   }
1353
1354   /**
1355    * get a ScoreModel based on its string name
1356    * 
1357    * @param pwtype
1358    * @return scoremodel of type pwtype or null
1359    */
1360   public static ScoreModelI getScoreModel(String pwtype)
1361   {
1362     return scoreMatrices.get(pwtype);
1363   }
1364
1365   public static int getPAM250(char c, char d)
1366   {
1367     int a = aaIndex[c];
1368     int b = aaIndex[d];
1369
1370     int pog = ResidueProperties.PAM250[a][b];
1371
1372     return pog;
1373   }
1374
1375   public static Hashtable<String, String> toDssp3State;
1376   static
1377   {
1378     toDssp3State = new Hashtable<String, String>();
1379     toDssp3State.put("H", "H");
1380     toDssp3State.put("E", "E");
1381     toDssp3State.put("C", " ");
1382     toDssp3State.put(" ", " ");
1383     toDssp3State.put("T", " ");
1384     toDssp3State.put("B", "E");
1385     toDssp3State.put("G", "H");
1386     toDssp3State.put("I", "H");
1387     toDssp3State.put("X", " ");
1388   }
1389
1390   /**
1391    * translate from other dssp secondary structure alphabets to 3-state
1392    * 
1393    * @param ssstring
1394    * @return ssstring as a three-state secondary structure assignment.
1395    */
1396   public static String getDssp3state(String ssstring)
1397   {
1398     if (ssstring == null)
1399     {
1400       return null;
1401     }
1402     StringBuffer ss = new StringBuffer();
1403     for (int i = 0; i < ssstring.length(); i++)
1404     {
1405       String ssc = ssstring.substring(i, i + 1);
1406       if (toDssp3State.containsKey(ssc))
1407       {
1408         ss.append(toDssp3State.get(ssc));
1409       }
1410       else
1411       {
1412         ss.append(" ");
1413       }
1414     }
1415     return ss.toString();
1416   }
1417
1418   static
1419   {
1420     modifications.put("MSE", "MET"); // Selenomethionine
1421     // the rest tbc; from
1422     // http://sourceforge.net/p/jmol/mailman/message/12833570/
1423     // modifications.put("CSE", "CYS"); // Selenocysteine
1424     // modifications.put("PTR", "TYR"); // Phosphotyrosine
1425     // modifications.put("SEP", "SER"); // Phosphoserine
1426     // modifications.put("HYP", "PRO"); // 4-hydroxyproline
1427     // modifications.put("5HP", "GLU"); // Pyroglutamic acid; 5-hydroxyproline
1428     // modifications.put("PCA", "GLU"); // Pyroglutamic acid
1429     // modifications.put("LYZ", "LYS"); // 5-hydroxylysine
1430
1431     // Additional protein alphabets used in the SCOP database and PDB files
1432     // source:
1433     // https://github.com/biopython/biopython/blob/master/Bio/Data/SCOPData.py
1434     modifications.put("00C", "CYS");
1435     modifications.put("01W", "XAA");
1436     modifications.put("02K", "ALA");
1437     modifications.put("03Y", "CYS");
1438     modifications.put("07O", "CYS");
1439     modifications.put("08P", "CYS");
1440     modifications.put("0A0", "ASP");
1441     modifications.put("0A1", "TYR");
1442     modifications.put("0A2", "LYS");
1443     modifications.put("0A8", "CYS");
1444     modifications.put("0AA", "VAL");
1445     modifications.put("0AB", "VAL");
1446     modifications.put("0AC", "GLY");
1447     modifications.put("0AD", "GLY");
1448     modifications.put("0AF", "TRP");
1449     modifications.put("0AG", "LEU");
1450     modifications.put("0AH", "SER");
1451     modifications.put("0AK", "ASP");
1452     modifications.put("0AM", "ALA");
1453     modifications.put("0AP", "CYS");
1454     modifications.put("0AU", "UR3");
1455     modifications.put("0AV", "ALA");
1456     modifications.put("0AZ", "PRO");
1457     modifications.put("0BN", "PHE");
1458     modifications.put("0C ", "CYS");
1459     modifications.put("0CS", "ALA");
1460     modifications.put("0DC", "CYS");
1461     modifications.put("0DG", "GLY");
1462     modifications.put("0DT", "THR");
1463     modifications.put("0FL", "ALA");
1464     modifications.put("0G ", "GLY");
1465     modifications.put("0NC", "ALA");
1466     modifications.put("0SP", "ALA");
1467     modifications.put("0U ", "UR3");
1468     modifications.put("0YG", "YG");
1469     modifications.put("10C", "CYS");
1470     modifications.put("125", "UR3");
1471     modifications.put("126", "UR3");
1472     modifications.put("127", "UR3");
1473     modifications.put("128", "ASN");
1474     modifications.put("12A", "ALA");
1475     modifications.put("143", "CYS");
1476     modifications.put("175", "ASG");
1477     modifications.put("193", "XAA");
1478     modifications.put("1AP", "ALA");
1479     modifications.put("1MA", "ALA");
1480     modifications.put("1MG", "GLY");
1481     modifications.put("1PA", "PHE");
1482     modifications.put("1PI", "ALA");
1483     modifications.put("1PR", "ASN");
1484     modifications.put("1SC", "CYS");
1485     modifications.put("1TQ", "TRP");
1486     modifications.put("1TY", "TYR");
1487     modifications.put("1X6", "SER");
1488     modifications.put("200", "PHE");
1489     modifications.put("23F", "PHE");
1490     modifications.put("23S", "XAA");
1491     modifications.put("26B", "THR");
1492     modifications.put("2AD", "XAA");
1493     modifications.put("2AG", "ALA");
1494     modifications.put("2AO", "XAA");
1495     modifications.put("2AR", "ALA");
1496     modifications.put("2AS", "XAA");
1497     modifications.put("2AT", "THR");
1498     modifications.put("2AU", "UR3");
1499     modifications.put("2BD", "ILE");
1500     modifications.put("2BT", "THR");
1501     modifications.put("2BU", "ALA");
1502     modifications.put("2CO", "CYS");
1503     modifications.put("2DA", "ALA");
1504     modifications.put("2DF", "ASN");
1505     modifications.put("2DM", "ASN");
1506     modifications.put("2DO", "XAA");
1507     modifications.put("2DT", "THR");
1508     modifications.put("2EG", "GLY");
1509     modifications.put("2FE", "ASN");
1510     modifications.put("2FI", "ASN");
1511     modifications.put("2FM", "MET");
1512     modifications.put("2GT", "THR");
1513     modifications.put("2HF", "HIS");
1514     modifications.put("2LU", "LEU");
1515     modifications.put("2MA", "ALA");
1516     modifications.put("2MG", "GLY");
1517     modifications.put("2ML", "LEU");
1518     modifications.put("2MR", "ARG");
1519     modifications.put("2MT", "PRO");
1520     modifications.put("2MU", "UR3");
1521     modifications.put("2NT", "THR");
1522     modifications.put("2OM", "UR3");
1523     modifications.put("2OT", "THR");
1524     modifications.put("2PI", "XAA");
1525     modifications.put("2PR", "GLY");
1526     modifications.put("2SA", "ASN");
1527     modifications.put("2SI", "XAA");
1528     modifications.put("2ST", "THR");
1529     modifications.put("2TL", "THR");
1530     modifications.put("2TY", "TYR");
1531     modifications.put("2VA", "VAL");
1532     modifications.put("2XA", "CYS");
1533     modifications.put("32S", "XAA");
1534     modifications.put("32T", "XAA");
1535     modifications.put("3AH", "HIS");
1536     modifications.put("3AR", "XAA");
1537     modifications.put("3CF", "PHE");
1538     modifications.put("3DA", "ALA");
1539     modifications.put("3DR", "ASN");
1540     modifications.put("3GA", "ALA");
1541     modifications.put("3MD", "ASP");
1542     modifications.put("3ME", "UR3");
1543     modifications.put("3NF", "TYR");
1544     modifications.put("3QN", "LYS");
1545     modifications.put("3TY", "XAA");
1546     modifications.put("3XH", "GLY");
1547     modifications.put("4AC", "ASN");
1548     modifications.put("4BF", "TYR");
1549     modifications.put("4CF", "PHE");
1550     modifications.put("4CY", "MET");
1551     modifications.put("4DP", "TRP");
1552     modifications.put("4F3", "GYG");
1553     modifications.put("4FB", "PRO");
1554     modifications.put("4FW", "TRP");
1555     modifications.put("4HT", "TRP");
1556     modifications.put("4IN", "TRP");
1557     modifications.put("4MF", "ASN");
1558     modifications.put("4MM", "XAA");
1559     modifications.put("4OC", "CYS");
1560     modifications.put("4PC", "CYS");
1561     modifications.put("4PD", "CYS");
1562     modifications.put("4PE", "CYS");
1563     modifications.put("4PH", "PHE");
1564     modifications.put("4SC", "CYS");
1565     modifications.put("4SU", "UR3");
1566     modifications.put("4TA", "ASN");
1567     modifications.put("4U7", "ALA");
1568     modifications.put("56A", "HIS");
1569     modifications.put("5AA", "ALA");
1570     modifications.put("5AB", "ALA");
1571     modifications.put("5AT", "THR");
1572     modifications.put("5BU", "UR3");
1573     modifications.put("5CG", "GLY");
1574     modifications.put("5CM", "CYS");
1575     modifications.put("5CS", "CYS");
1576     modifications.put("5FA", "ALA");
1577     modifications.put("5FC", "CYS");
1578     modifications.put("5FU", "UR3");
1579     modifications.put("5HP", "GLU");
1580     modifications.put("5HT", "THR");
1581     modifications.put("5HU", "UR3");
1582     modifications.put("5IC", "CYS");
1583     modifications.put("5IT", "THR");
1584     modifications.put("5IU", "UR3");
1585     modifications.put("5MC", "CYS");
1586     modifications.put("5MD", "ASN");
1587     modifications.put("5MU", "UR3");
1588     modifications.put("5NC", "CYS");
1589     modifications.put("5PC", "CYS");
1590     modifications.put("5PY", "THR");
1591     modifications.put("5SE", "UR3");
1592     modifications.put("5ZA", "TWG");
1593     modifications.put("64T", "THR");
1594     modifications.put("6CL", "LYS");
1595     modifications.put("6CT", "THR");
1596     modifications.put("6CW", "TRP");
1597     modifications.put("6HA", "ALA");
1598     modifications.put("6HC", "CYS");
1599     modifications.put("6HG", "GLY");
1600     modifications.put("6HN", "LYS");
1601     modifications.put("6HT", "THR");
1602     modifications.put("6IA", "ALA");
1603     modifications.put("6MA", "ALA");
1604     modifications.put("6MC", "ALA");
1605     modifications.put("6MI", "ASN");
1606     modifications.put("6MT", "ALA");
1607     modifications.put("6MZ", "ASN");
1608     modifications.put("6OG", "GLY");
1609     modifications.put("70U", "UR3");
1610     modifications.put("7DA", "ALA");
1611     modifications.put("7GU", "GLY");
1612     modifications.put("7JA", "ILE");
1613     modifications.put("7MG", "GLY");
1614     modifications.put("8AN", "ALA");
1615     modifications.put("8FG", "GLY");
1616     modifications.put("8MG", "GLY");
1617     modifications.put("8OG", "GLY");
1618     modifications.put("9NE", "GLU");
1619     modifications.put("9NF", "PHE");
1620     modifications.put("9NR", "ARG");
1621     modifications.put("9NV", "VAL");
1622     modifications.put("A  ", "ALA");
1623     modifications.put("A1P", "ASN");
1624     modifications.put("A23", "ALA");
1625     modifications.put("A2L", "ALA");
1626     modifications.put("A2M", "ALA");
1627     modifications.put("A34", "ALA");
1628     modifications.put("A35", "ALA");
1629     modifications.put("A38", "ALA");
1630     modifications.put("A39", "ALA");
1631     modifications.put("A3A", "ALA");
1632     modifications.put("A3P", "ALA");
1633     modifications.put("A40", "ALA");
1634     modifications.put("A43", "ALA");
1635     modifications.put("A44", "ALA");
1636     modifications.put("A47", "ALA");
1637     modifications.put("A5L", "ALA");
1638     modifications.put("A5M", "CYS");
1639     modifications.put("A5N", "ASN");
1640     modifications.put("A5O", "ALA");
1641     modifications.put("A66", "XAA");
1642     modifications.put("AA3", "ALA");
1643     modifications.put("AA4", "ALA");
1644     modifications.put("AAR", "ARG");
1645     modifications.put("AB7", "XAA");
1646     modifications.put("ABA", "ALA");
1647     modifications.put("ABR", "ALA");
1648     modifications.put("ABS", "ALA");
1649     modifications.put("ABT", "ASN");
1650     modifications.put("ACB", "ASP");
1651     modifications.put("ACL", "ARG");
1652     modifications.put("AD2", "ALA");
1653     modifications.put("ADD", "XAA");
1654     modifications.put("ADX", "ASN");
1655     modifications.put("AEA", "XAA");
1656     modifications.put("AEI", "ASP");
1657     modifications.put("AET", "ALA");
1658     modifications.put("AFA", "ASN");
1659     modifications.put("AFF", "ASN");
1660     modifications.put("AFG", "GLY");
1661     modifications.put("AGM", "ARG");
1662     modifications.put("AGT", "CYS");
1663     modifications.put("AHB", "ASN");
1664     modifications.put("AHH", "XAA");
1665     modifications.put("AHO", "ALA");
1666     modifications.put("AHP", "ALA");
1667     modifications.put("AHS", "XAA");
1668     modifications.put("AHT", "XAA");
1669     modifications.put("AIB", "ALA");
1670     modifications.put("AKL", "ASP");
1671     modifications.put("AKZ", "ASP");
1672     modifications.put("ALA", "ALA");
1673     modifications.put("ALC", "ALA");
1674     modifications.put("ALM", "ALA");
1675     modifications.put("ALN", "ALA");
1676     modifications.put("ALO", "THR");
1677     modifications.put("ALQ", "XAA");
1678     modifications.put("ALS", "ALA");
1679     modifications.put("ALT", "ALA");
1680     modifications.put("ALV", "ALA");
1681     modifications.put("ALY", "LYS");
1682     modifications.put("AN8", "ALA");
1683     modifications.put("AP7", "ALA");
1684     modifications.put("APE", "XAA");
1685     modifications.put("APH", "ALA");
1686     modifications.put("API", "LYS");
1687     modifications.put("APK", "LYS");
1688     modifications.put("APM", "XAA");
1689     modifications.put("APP", "XAA");
1690     modifications.put("AR2", "ARG");
1691     modifications.put("AR4", "GLU");
1692     modifications.put("AR7", "ARG");
1693     modifications.put("ARG", "ARG");
1694     modifications.put("ARM", "ARG");
1695     modifications.put("ARO", "ARG");
1696     modifications.put("ARV", "XAA");
1697     modifications.put("AS ", "ALA");
1698     modifications.put("AS2", "ASP");
1699     modifications.put("AS9", "XAA");
1700     modifications.put("ASA", "ASP");
1701     modifications.put("ASB", "ASP");
1702     modifications.put("ASI", "ASP");
1703     modifications.put("ASK", "ASP");
1704     modifications.put("ASL", "ASP");
1705     modifications.put("ASM", "XAA");
1706     modifications.put("ASN", "ASN");
1707     modifications.put("ASP", "ASP");
1708     modifications.put("ASQ", "ASP");
1709     modifications.put("ASU", "ASN");
1710     modifications.put("ASX", "ASX");
1711     modifications.put("ATD", "THR");
1712     modifications.put("ATL", "THR");
1713     modifications.put("ATM", "THR");
1714     modifications.put("AVC", "ALA");
1715     modifications.put("AVN", "XAA");
1716     modifications.put("AYA", "ALA");
1717     modifications.put("AYG", "AYG");
1718     modifications.put("AZK", "LYS");
1719     modifications.put("AZS", "SER");
1720     modifications.put("AZY", "TYR");
1721     modifications.put("B1F", "PHE");
1722     modifications.put("B1P", "ASN");
1723     modifications.put("B2A", "ALA");
1724     modifications.put("B2F", "PHE");
1725     modifications.put("B2I", "ILE");
1726     modifications.put("B2V", "VAL");
1727     modifications.put("B3A", "ALA");
1728     modifications.put("B3D", "ASP");
1729     modifications.put("B3E", "GLU");
1730     modifications.put("B3K", "LYS");
1731     modifications.put("B3L", "XAA");
1732     modifications.put("B3M", "XAA");
1733     modifications.put("B3Q", "XAA");
1734     modifications.put("B3S", "SER");
1735     modifications.put("B3T", "XAA");
1736     modifications.put("B3U", "HIS");
1737     modifications.put("B3X", "ASN");
1738     modifications.put("B3Y", "TYR");
1739     modifications.put("BB6", "CYS");
1740     modifications.put("BB7", "CYS");
1741     modifications.put("BB8", "PHE");
1742     modifications.put("BB9", "CYS");
1743     modifications.put("BBC", "CYS");
1744     modifications.put("BCS", "CYS");
1745     modifications.put("BE2", "XAA");
1746     modifications.put("BFD", "ASP");
1747     modifications.put("BG1", "SER");
1748     modifications.put("BGM", "GLY");
1749     modifications.put("BH2", "ASP");
1750     modifications.put("BHD", "ASP");
1751     modifications.put("BIF", "PHE");
1752     modifications.put("BIL", "XAA");
1753     modifications.put("BIU", "ILE");
1754     modifications.put("BJH", "XAA");
1755     modifications.put("BLE", "LEU");
1756     modifications.put("BLY", "LYS");
1757     modifications.put("BMP", "ASN");
1758     modifications.put("BMT", "THR");
1759     modifications.put("BNN", "PHE");
1760     modifications.put("BNO", "XAA");
1761     modifications.put("BOE", "THR");
1762     modifications.put("BOR", "ARG");
1763     modifications.put("BPE", "CYS");
1764     modifications.put("BRU", "UR3");
1765     modifications.put("BSE", "SER");
1766     modifications.put("BT5", "ASN");
1767     modifications.put("BTA", "LEU");
1768     modifications.put("BTC", "CYS");
1769     modifications.put("BTR", "TRP");
1770     modifications.put("BUC", "CYS");
1771     modifications.put("BUG", "VAL");
1772     modifications.put("BVP", "UR3");
1773     modifications.put("BZG", "ASN");
1774     modifications.put("C  ", "CYS");
1775     modifications.put("C12", "TYG");
1776     modifications.put("C1X", "LYS");
1777     modifications.put("C25", "CYS");
1778     modifications.put("C2L", "CYS");
1779     modifications.put("C2S", "CYS");
1780     modifications.put("C31", "CYS");
1781     modifications.put("C32", "CYS");
1782     modifications.put("C34", "CYS");
1783     modifications.put("C36", "CYS");
1784     modifications.put("C37", "CYS");
1785     modifications.put("C38", "CYS");
1786     modifications.put("C3Y", "CYS");
1787     modifications.put("C42", "CYS");
1788     modifications.put("C43", "CYS");
1789     modifications.put("C45", "CYS");
1790     modifications.put("C46", "CYS");
1791     modifications.put("C49", "CYS");
1792     modifications.put("C4R", "CYS");
1793     modifications.put("C4S", "CYS");
1794     modifications.put("C5C", "CYS");
1795     modifications.put("C66", "XAA");
1796     modifications.put("C6C", "CYS");
1797     modifications.put("C99", "TFG");
1798     modifications.put("CAF", "CYS");
1799     modifications.put("CAL", "XAA");
1800     modifications.put("CAR", "CYS");
1801     modifications.put("CAS", "CYS");
1802     modifications.put("CAV", "XAA");
1803     modifications.put("CAY", "CYS");
1804     modifications.put("CB2", "CYS");
1805     modifications.put("CBR", "CYS");
1806     modifications.put("CBV", "CYS");
1807     modifications.put("CCC", "CYS");
1808     modifications.put("CCL", "LYS");
1809     modifications.put("CCS", "CYS");
1810     modifications.put("CCY", "CYG");
1811     modifications.put("CDE", "XAA");
1812     modifications.put("CDV", "XAA");
1813     modifications.put("CDW", "CYS");
1814     modifications.put("CEA", "CYS");
1815     modifications.put("CFL", "CYS");
1816     modifications.put("CFY", "FCYG"); // check
1817     modifications.put("CG1", "GLY");
1818     modifications.put("CGA", "GLU");
1819     modifications.put("CGU", "GLU");
1820     modifications.put("CH ", "CYS");
1821     modifications.put("CH6", "MYG");
1822     modifications.put("CH7", "KYG");
1823     modifications.put("CHF", "XAA");
1824     modifications.put("CHG", "XAA");
1825     modifications.put("CHP", "GLY");
1826     modifications.put("CHS", "XAA");
1827     modifications.put("CIR", "ARG");
1828     modifications.put("CJO", "GYG");
1829     modifications.put("CLE", "LEU");
1830     modifications.put("CLG", "LYS");
1831     modifications.put("CLH", "LYS");
1832     modifications.put("CLV", "AFG");
1833     modifications.put("CM0", "ASN");
1834     modifications.put("CME", "CYS");
1835     modifications.put("CMH", "CYS");
1836     modifications.put("CML", "CYS");
1837     modifications.put("CMR", "CYS");
1838     modifications.put("CMT", "CYS");
1839     modifications.put("CNU", "UR3");
1840     modifications.put("CP1", "CYS");
1841     modifications.put("CPC", "XAA");
1842     modifications.put("CPI", "XAA");
1843     modifications.put("CQR", "GYG");
1844     modifications.put("CR0", "TLG");
1845     modifications.put("CR2", "GYG");
1846     modifications.put("CR5", "GLY");
1847     modifications.put("CR7", "KYG");
1848     modifications.put("CR8", "HYG");
1849     modifications.put("CRF", "TWG");
1850     modifications.put("CRG", "THG");
1851     modifications.put("CRK", "MYG");
1852     modifications.put("CRO", "GYG");
1853     modifications.put("CRQ", "QYG");
1854     modifications.put("CRU", "EYG");
1855     modifications.put("CRW", "ASG");
1856     modifications.put("CRX", "ASG");
1857     modifications.put("CS0", "CYS");
1858     modifications.put("CS1", "CYS");
1859     modifications.put("CS3", "CYS");
1860     modifications.put("CS4", "CYS");
1861     modifications.put("CS8", "ASN");
1862     modifications.put("CSA", "CYS");
1863     modifications.put("CSB", "CYS");
1864     modifications.put("CSD", "CYS");
1865     modifications.put("CSE", "CYS");
1866     modifications.put("CSF", "CYS");
1867     modifications.put("CSH", "SHG");
1868     modifications.put("CSI", "GLY");
1869     modifications.put("CSJ", "CYS");
1870     modifications.put("CSL", "CYS");
1871     modifications.put("CSO", "CYS");
1872     modifications.put("CSP", "CYS");
1873     modifications.put("CSR", "CYS");
1874     modifications.put("CSS", "CYS");
1875     modifications.put("CSU", "CYS");
1876     modifications.put("CSW", "CYS");
1877     modifications.put("CSX", "CYS");
1878     modifications.put("CSY", "SYG");
1879     modifications.put("CSZ", "CYS");
1880     modifications.put("CTE", "TRP");
1881     modifications.put("CTG", "THR");
1882     modifications.put("CTH", "THR");
1883     modifications.put("CUC", "XAA");
1884     modifications.put("CWR", "SER");
1885     modifications.put("CXM", "MET");
1886     modifications.put("CY0", "CYS");
1887     modifications.put("CY1", "CYS");
1888     modifications.put("CY3", "CYS");
1889     modifications.put("CY4", "CYS");
1890     modifications.put("CYA", "CYS");
1891     modifications.put("CYD", "CYS");
1892     modifications.put("CYF", "CYS");
1893     modifications.put("CYG", "CYS");
1894     modifications.put("CYJ", "XAA");
1895     modifications.put("CYM", "CYS");
1896     modifications.put("CYQ", "CYS");
1897     modifications.put("CYR", "CYS");
1898     modifications.put("CYS", "CYS");
1899     modifications.put("CZ2", "CYS");
1900     modifications.put("CZO", "GYG");
1901     modifications.put("CZZ", "CYS");
1902     modifications.put("D11", "THR");
1903     modifications.put("D1P", "ASN");
1904     modifications.put("D3 ", "ASN");
1905     modifications.put("D33", "ASN");
1906     modifications.put("D3P", "GLY");
1907     modifications.put("D3T", "THR");
1908     modifications.put("D4M", "THR");
1909     modifications.put("D4P", "XAA");
1910     modifications.put("DA ", "ALA");
1911     modifications.put("DA2", "XAA");
1912     modifications.put("DAB", "ALA");
1913     modifications.put("DAH", "PHE");
1914     modifications.put("DAL", "ALA");
1915     modifications.put("DAR", "ARG");
1916     modifications.put("DAS", "ASP");
1917     modifications.put("DBB", "THR");
1918     modifications.put("DBM", "ASN");
1919     modifications.put("DBS", "SER");
1920     modifications.put("DBU", "THR");
1921     modifications.put("DBY", "TYR");
1922     modifications.put("DBZ", "ALA");
1923     modifications.put("DC ", "CYS");
1924     modifications.put("DC2", "CYS");
1925     modifications.put("DCG", "GLY");
1926     modifications.put("DCI", "XAA");
1927     modifications.put("DCL", "XAA");
1928     modifications.put("DCT", "CYS");
1929     modifications.put("DCY", "CYS");
1930     modifications.put("DDE", "HIS");
1931     modifications.put("DDG", "GLY");
1932     modifications.put("DDN", "UR3");
1933     modifications.put("DDX", "ASN");
1934     modifications.put("DFC", "CYS");
1935     modifications.put("DFG", "GLY");
1936     modifications.put("DFI", "XAA");
1937     modifications.put("DFO", "XAA");
1938     modifications.put("DFT", "ASN");
1939     modifications.put("DG ", "GLY");
1940     modifications.put("DGH", "GLY");
1941     modifications.put("DGI", "GLY");
1942     modifications.put("DGL", "GLU");
1943     modifications.put("DGN", "GLN");
1944     modifications.put("DHA", "SER");
1945     modifications.put("DHI", "HIS");
1946     modifications.put("DHL", "XAA");
1947     modifications.put("DHN", "VAL");
1948     modifications.put("DHP", "XAA");
1949     modifications.put("DHU", "UR3");
1950     modifications.put("DHV", "VAL");
1951     modifications.put("DI ", "ILE");
1952     modifications.put("DIL", "ILE");
1953     modifications.put("DIR", "ARG");
1954     modifications.put("DIV", "VAL");
1955     modifications.put("DLE", "LEU");
1956     modifications.put("DLS", "LYS");
1957     modifications.put("DLY", "LYS");
1958     modifications.put("DM0", "LYS");
1959     modifications.put("DMH", "ASN");
1960     modifications.put("DMK", "ASP");
1961     modifications.put("DMT", "XAA");
1962     modifications.put("DN ", "ASN");
1963     modifications.put("DNE", "LEU");
1964     modifications.put("DNG", "LEU");
1965     modifications.put("DNL", "LYS");
1966     modifications.put("DNM", "LEU");
1967     modifications.put("DNP", "ALA");
1968     modifications.put("DNR", "CYS");
1969     modifications.put("DNS", "LYS");
1970     modifications.put("DOA", "XAA");
1971     modifications.put("DOC", "CYS");
1972     modifications.put("DOH", "ASP");
1973     modifications.put("DON", "LEU");
1974     modifications.put("DPB", "THR");
1975     modifications.put("DPH", "PHE");
1976     modifications.put("DPL", "PRO");
1977     modifications.put("DPP", "ALA");
1978     modifications.put("DPQ", "TYR");
1979     modifications.put("DPR", "PRO");
1980     modifications.put("DPY", "ASN");
1981     modifications.put("DRM", "UR3");
1982     modifications.put("DRP", "ASN");
1983     modifications.put("DRT", "THR");
1984     modifications.put("DRZ", "ASN");
1985     modifications.put("DSE", "SER");
1986     modifications.put("DSG", "ASN");
1987     modifications.put("DSN", "SER");
1988     modifications.put("DSP", "ASP");
1989     modifications.put("DT ", "THR");
1990     modifications.put("DTH", "THR");
1991     modifications.put("DTR", "TRP");
1992     modifications.put("DTY", "TYR");
1993     modifications.put("DU ", "UR3");
1994     modifications.put("DVA", "VAL");
1995     modifications.put("DXD", "ASN");
1996     modifications.put("DXN", "ASN");
1997     modifications.put("DYG", "DYG");
1998     modifications.put("DYS", "CYS");
1999     modifications.put("DZM", "ALA");
2000     modifications.put("E  ", "ALA");
2001     modifications.put("E1X", "ALA");
2002     modifications.put("ECC", "GLN");
2003     modifications.put("EDA", "ALA");
2004     modifications.put("EFC", "CYS");
2005     modifications.put("EHP", "PHE");
2006     modifications.put("EIT", "THR");
2007     modifications.put("ENP", "ASN");
2008     modifications.put("ESB", "TYR");
2009     modifications.put("ESC", "MET");
2010     modifications.put("EXB", "XAA");
2011     modifications.put("EXY", "LEU");
2012     modifications.put("EY5", "ASN");
2013     modifications.put("EYS", "XAA");
2014     modifications.put("F2F", "PHE");
2015     modifications.put("FA2", "ALA");
2016     modifications.put("FA5", "ASN");
2017     modifications.put("FAG", "ASN");
2018     modifications.put("FAI", "ASN");
2019     modifications.put("FB5", "ALA");
2020     modifications.put("FB6", "ALA");
2021     modifications.put("FCL", "PHE");
2022     modifications.put("FFD", "ASN");
2023     modifications.put("FGA", "GLU");
2024     modifications.put("FGL", "GLY");
2025     modifications.put("FGP", "SER");
2026     modifications.put("FHL", "XAA");
2027     modifications.put("FHO", "LYS");
2028     modifications.put("FHU", "UR3");
2029     modifications.put("FLA", "ALA");
2030     modifications.put("FLE", "LEU");
2031     modifications.put("FLT", "TYR");
2032     modifications.put("FME", "MET");
2033     modifications.put("FMG", "GLY");
2034     modifications.put("FMU", "ASN");
2035     modifications.put("FOE", "CYS");
2036     modifications.put("FOX", "GLY");
2037     modifications.put("FP9", "PRO");
2038     modifications.put("FPA", "PHE");
2039     modifications.put("FRD", "XAA");
2040     modifications.put("FT6", "TRP");
2041     modifications.put("FTR", "TRP");
2042     modifications.put("FTY", "TYR");
2043     modifications.put("FVA", "VAL");
2044     modifications.put("FZN", "LYS");
2045     modifications.put("G  ", "GLY");
2046     modifications.put("G25", "GLY");
2047     modifications.put("G2L", "GLY");
2048     modifications.put("G2S", "GLY");
2049     modifications.put("G31", "GLY");
2050     modifications.put("G32", "GLY");
2051     modifications.put("G33", "GLY");
2052     modifications.put("G36", "GLY");
2053     modifications.put("G38", "GLY");
2054     modifications.put("G42", "GLY");
2055     modifications.put("G46", "GLY");
2056     modifications.put("G47", "GLY");
2057     modifications.put("G48", "GLY");
2058     modifications.put("G49", "GLY");
2059     modifications.put("G4P", "ASN");
2060     modifications.put("G7M", "GLY");
2061     modifications.put("GAO", "GLY");
2062     modifications.put("GAU", "GLU");
2063     modifications.put("GCK", "CYS");
2064     modifications.put("GCM", "XAA");
2065     modifications.put("GDP", "GLY");
2066     modifications.put("GDR", "GLY");
2067     modifications.put("GFL", "GLY");
2068     modifications.put("GGL", "GLU");
2069     modifications.put("GH3", "GLY");
2070     modifications.put("GHG", "GLN");
2071     modifications.put("GHP", "GLY");
2072     modifications.put("GL3", "GLY");
2073     modifications.put("GLH", "GLN");
2074     modifications.put("GLJ", "GLU");
2075     modifications.put("GLK", "GLU");
2076     modifications.put("GLM", "XAA");
2077     modifications.put("GLN", "GLN");
2078     modifications.put("GLQ", "GLU");
2079     modifications.put("GLU", "GLU");
2080     modifications.put("GLX", "GLX");
2081     modifications.put("GLY", "GLY");
2082     modifications.put("GLZ", "GLY");
2083     modifications.put("GMA", "GLU");
2084     modifications.put("GMS", "GLY");
2085     modifications.put("GMU", "UR3");
2086     modifications.put("GN7", "GLY");
2087     modifications.put("GND", "XAA");
2088     modifications.put("GNE", "ASN");
2089     modifications.put("GOM", "GLY");
2090     modifications.put("GPL", "LYS");
2091     modifications.put("GS ", "GLY");
2092     modifications.put("GSC", "GLY");
2093     modifications.put("GSR", "GLY");
2094     modifications.put("GSS", "GLY");
2095     modifications.put("GSU", "GLU");
2096     modifications.put("GT9", "CYS");
2097     modifications.put("GTP", "GLY");
2098     modifications.put("GVL", "XAA");
2099     modifications.put("GYC", "CYG");
2100     modifications.put("GYS", "SYG");
2101     modifications.put("H2U", "UR3");
2102     modifications.put("H5M", "PRO");
2103     modifications.put("HAC", "ALA");
2104     modifications.put("HAR", "ARG");
2105     modifications.put("HBN", "HIS");
2106     modifications.put("HCS", "XAA");
2107     modifications.put("HDP", "UR3");
2108     modifications.put("HEU", "UR3");
2109     modifications.put("HFA", "XAA");
2110     modifications.put("HGL", "XAA");
2111     modifications.put("HHI", "HIS");
2112     modifications.put("HHK", "AK"); // check
2113     modifications.put("HIA", "HIS");
2114     modifications.put("HIC", "HIS");
2115     modifications.put("HIP", "HIS");
2116     modifications.put("HIQ", "HIS");
2117     modifications.put("HIS", "HIS");
2118     modifications.put("HL2", "LEU");
2119     modifications.put("HLU", "LEU");
2120     modifications.put("HMR", "ARG");
2121     modifications.put("HOL", "ASN");
2122     modifications.put("HPC", "PHE");
2123     modifications.put("HPE", "PHE");
2124     modifications.put("HPH", "PHE");
2125     modifications.put("HPQ", "PHE");
2126     modifications.put("HQA", "ALA");
2127     modifications.put("HRG", "ARG");
2128     modifications.put("HRP", "TRP");
2129     modifications.put("HS8", "HIS");
2130     modifications.put("HS9", "HIS");
2131     modifications.put("HSE", "SER");
2132     modifications.put("HSL", "SER");
2133     modifications.put("HSO", "HIS");
2134     modifications.put("HTI", "CYS");
2135     modifications.put("HTN", "ASN");
2136     modifications.put("HTR", "TRP");
2137     modifications.put("HV5", "ALA");
2138     modifications.put("HVA", "VAL");
2139     modifications.put("HY3", "PRO");
2140     modifications.put("HYP", "PRO");
2141     modifications.put("HZP", "PRO");
2142     modifications.put("I  ", "ILE");
2143     modifications.put("I2M", "ILE");
2144     modifications.put("I58", "LYS");
2145     modifications.put("I5C", "CYS");
2146     modifications.put("IAM", "ALA");
2147     modifications.put("IAR", "ARG");
2148     modifications.put("IAS", "ASP");
2149     modifications.put("IC ", "CYS");
2150     modifications.put("IEL", "LYS");
2151     modifications.put("IEY", "HYG");
2152     modifications.put("IG ", "GLY");
2153     modifications.put("IGL", "GLY");
2154     modifications.put("IGU", "GLY");
2155     modifications.put("IIC", "SHG");
2156     modifications.put("IIL", "ILE");
2157     modifications.put("ILE", "ILE");
2158     modifications.put("ILG", "GLU");
2159     modifications.put("ILX", "ILE");
2160     modifications.put("IMC", "CYS");
2161     modifications.put("IML", "ILE");
2162     modifications.put("IOY", "PHE");
2163     modifications.put("IPG", "GLY");
2164     modifications.put("IPN", "ASN");
2165     modifications.put("IRN", "ASN");
2166     modifications.put("IT1", "LYS");
2167     modifications.put("IU ", "UR3");
2168     modifications.put("IYR", "TYR");
2169     modifications.put("IYT", "THR");
2170     modifications.put("IZO", "MET");
2171     modifications.put("JJJ", "CYS");
2172     modifications.put("JJK", "CYS");
2173     modifications.put("JJL", "CYS");
2174     modifications.put("JW5", "ASN");
2175     modifications.put("K1R", "CYS");
2176     modifications.put("KAG", "GLY");
2177     modifications.put("KCX", "LYS");
2178     modifications.put("KGC", "LYS");
2179     modifications.put("KNB", "ALA");
2180     modifications.put("KOR", "MET");
2181     modifications.put("KPI", "LYS");
2182     modifications.put("KST", "LYS");
2183     modifications.put("KYQ", "LYS");
2184     modifications.put("L2A", "XAA");
2185     modifications.put("LA2", "LYS");
2186     modifications.put("LAA", "ASP");
2187     modifications.put("LAL", "ALA");
2188     modifications.put("LBY", "LYS");
2189     modifications.put("LC ", "CYS");
2190     modifications.put("LCA", "ALA");
2191     modifications.put("LCC", "ASN");
2192     modifications.put("LCG", "GLY");
2193     modifications.put("LCH", "ASN");
2194     modifications.put("LCK", "LYS");
2195     modifications.put("LCX", "LYS");
2196     modifications.put("LDH", "LYS");
2197     modifications.put("LED", "LEU");
2198     modifications.put("LEF", "LEU");
2199     modifications.put("LEH", "LEU");
2200     modifications.put("LEI", "VAL");
2201     modifications.put("LEM", "LEU");
2202     modifications.put("LEN", "LEU");
2203     modifications.put("LET", "XAA");
2204     modifications.put("LEU", "LEU");
2205     modifications.put("LEX", "LEU");
2206     modifications.put("LG ", "GLY");
2207     modifications.put("LGP", "GLY");
2208     modifications.put("LHC", "XAA");
2209     modifications.put("LHU", "UR3");
2210     modifications.put("LKC", "ASN");
2211     modifications.put("LLP", "LYS");
2212     modifications.put("LLY", "LYS");
2213     modifications.put("LME", "GLU");
2214     modifications.put("LMF", "LYS");
2215     modifications.put("LMQ", "GLN");
2216     modifications.put("LMS", "ASN");
2217     modifications.put("LP6", "LYS");
2218     modifications.put("LPD", "PRO");
2219     modifications.put("LPG", "GLY");
2220     modifications.put("LPL", "XAA");
2221     modifications.put("LPS", "SER");
2222     modifications.put("LSO", "XAA");
2223     modifications.put("LTA", "XAA");
2224     modifications.put("LTR", "TRP");
2225     modifications.put("LVG", "GLY");
2226     modifications.put("LVN", "VAL");
2227     modifications.put("LYF", "LYS");
2228     modifications.put("LYK", "LYS");
2229     modifications.put("LYM", "LYS");
2230     modifications.put("LYN", "LYS");
2231     modifications.put("LYR", "LYS");
2232     modifications.put("LYS", "LYS");
2233     modifications.put("LYX", "LYS");
2234     modifications.put("LYZ", "LYS");
2235     modifications.put("M0H", "CYS");
2236     modifications.put("M1G", "GLY");
2237     modifications.put("M2G", "GLY");
2238     modifications.put("M2L", "LYS");
2239     modifications.put("M2S", "MET");
2240     modifications.put("M30", "GLY");
2241     modifications.put("M3L", "LYS");
2242     modifications.put("M5M", "CYS");
2243     modifications.put("MA ", "ALA");
2244     modifications.put("MA6", "ALA");
2245     modifications.put("MA7", "ALA");
2246     modifications.put("MAA", "ALA");
2247     modifications.put("MAD", "ALA");
2248     modifications.put("MAI", "ARG");
2249     modifications.put("MBQ", "TYR");
2250     modifications.put("MBZ", "ASN");
2251     modifications.put("MC1", "SER");
2252     modifications.put("MCG", "XAA");
2253     modifications.put("MCL", "LYS");
2254     modifications.put("MCS", "CYS");
2255     modifications.put("MCY", "CYS");
2256     modifications.put("MD3", "CYS");
2257     modifications.put("MD6", "GLY");
2258     modifications.put("MDH", "XAA");
2259     modifications.put("MDO", "ASG");
2260     modifications.put("MDR", "ASN");
2261     modifications.put("MEA", "PHE");
2262     modifications.put("MED", "MET");
2263     modifications.put("MEG", "GLU");
2264     modifications.put("MEN", "ASN");
2265     modifications.put("MEP", "UR3");
2266     modifications.put("MEQ", "GLN");
2267     modifications.put("MET", "MET");
2268     modifications.put("MEU", "GLY");
2269     modifications.put("MF3", "XAA");
2270     modifications.put("MFC", "GYG");
2271     modifications.put("MG1", "GLY");
2272     modifications.put("MGG", "ARG");
2273     modifications.put("MGN", "GLN");
2274     modifications.put("MGQ", "ALA");
2275     modifications.put("MGV", "GLY");
2276     modifications.put("MGY", "GLY");
2277     modifications.put("MHL", "LEU");
2278     modifications.put("MHO", "MET");
2279     modifications.put("MHS", "HIS");
2280     modifications.put("MIA", "ALA");
2281     modifications.put("MIS", "SER");
2282     modifications.put("MK8", "LEU");
2283     modifications.put("ML3", "LYS");
2284     modifications.put("MLE", "LEU");
2285     modifications.put("MLL", "LEU");
2286     modifications.put("MLY", "LYS");
2287     modifications.put("MLZ", "LYS");
2288     modifications.put("MME", "MET");
2289     modifications.put("MMO", "ARG");
2290     modifications.put("MMT", "THR");
2291     modifications.put("MND", "ASN");
2292     modifications.put("MNL", "LEU");
2293     modifications.put("MNU", "UR3");
2294     modifications.put("MNV", "VAL");
2295     modifications.put("MOD", "XAA");
2296     modifications.put("MP8", "PRO");
2297     modifications.put("MPH", "XAA");
2298     modifications.put("MPJ", "XAA");
2299     modifications.put("MPQ", "GLY");
2300     modifications.put("MRG", "GLY");
2301     modifications.put("MSA", "GLY");
2302     modifications.put("MSE", "MET");
2303     modifications.put("MSL", "MET");
2304     modifications.put("MSO", "MET");
2305     modifications.put("MSP", "XAA");
2306     modifications.put("MT2", "MET");
2307     modifications.put("MTR", "THR");
2308     modifications.put("MTU", "ALA");
2309     modifications.put("MTY", "TYR");
2310     modifications.put("MVA", "VAL");
2311     modifications.put("N  ", "ASN");
2312     modifications.put("N10", "SER");
2313     modifications.put("N2C", "XAA");
2314     modifications.put("N5I", "ASN");
2315     modifications.put("N5M", "CYS");
2316     modifications.put("N6G", "GLY");
2317     modifications.put("N7P", "PRO");
2318     modifications.put("NA8", "ALA");
2319     modifications.put("NAL", "ALA");
2320     modifications.put("NAM", "ALA");
2321     modifications.put("NB8", "ASN");
2322     modifications.put("NBQ", "TYR");
2323     modifications.put("NC1", "SER");
2324     modifications.put("NCB", "ALA");
2325     modifications.put("NCX", "ASN");
2326     modifications.put("NCY", "XAA");
2327     modifications.put("NDF", "PHE");
2328     modifications.put("NDN", "UR3");
2329     modifications.put("NEM", "HIS");
2330     modifications.put("NEP", "HIS");
2331     modifications.put("NF2", "ASN");
2332     modifications.put("NFA", "PHE");
2333     modifications.put("NHL", "GLU");
2334     modifications.put("NIT", "XAA");
2335     modifications.put("NIY", "TYR");
2336     modifications.put("NLE", "LEU");
2337     modifications.put("NLN", "LEU");
2338     modifications.put("NLO", "LEU");
2339     modifications.put("NLP", "LEU");
2340     modifications.put("NLQ", "GLN");
2341     modifications.put("NMC", "GLY");
2342     modifications.put("NMM", "ARG");
2343     modifications.put("NMS", "THR");
2344     modifications.put("NMT", "THR");
2345     modifications.put("NNH", "ARG");
2346     modifications.put("NP3", "ASN");
2347     modifications.put("NPH", "CYS");
2348     modifications.put("NPI", "ALA");
2349     modifications.put("NRP", "LYG");
2350     modifications.put("NRQ", "MYG");
2351     modifications.put("NSK", "XAA");
2352     modifications.put("NTY", "TYR");
2353     modifications.put("NVA", "VAL");
2354     modifications.put("NYC", "TWG");
2355     modifications.put("NYG", "NYG");
2356     modifications.put("NYM", "ASN");
2357     modifications.put("NYS", "CYS");
2358     modifications.put("NZH", "HIS");
2359     modifications.put("O12", "XAA");
2360     modifications.put("O2C", "ASN");
2361     modifications.put("O2G", "GLY");
2362     modifications.put("OAD", "ASN");
2363     modifications.put("OAS", "SER");
2364     modifications.put("OBF", "XAA");
2365     modifications.put("OBS", "XAA");
2366     modifications.put("OCS", "CYS");
2367     modifications.put("OCY", "CYS");
2368     modifications.put("ODP", "ASN");
2369     modifications.put("OHI", "HIS");
2370     modifications.put("OHS", "ASP");
2371     modifications.put("OIC", "XAA");
2372     modifications.put("OIP", "ILE");
2373     modifications.put("OLE", "XAA");
2374     modifications.put("OLT", "THR");
2375     modifications.put("OLZ", "SER");
2376     modifications.put("OMC", "CYS");
2377     modifications.put("OMG", "GLY");
2378     modifications.put("OMT", "MET");
2379     modifications.put("OMU", "UR3");
2380     modifications.put("ONE", "UR3");
2381     modifications.put("ONH", "ALA");
2382     modifications.put("ONL", "XAA");
2383     modifications.put("OPR", "ARG");
2384     modifications.put("ORN", "ALA");
2385     modifications.put("ORQ", "ARG");
2386     modifications.put("OSE", "SER");
2387     modifications.put("OTB", "XAA");
2388     modifications.put("OTH", "THR");
2389     modifications.put("OTY", "TYR");
2390     modifications.put("OXX", "ASP");
2391     modifications.put("P  ", "GLY");
2392     modifications.put("P1L", "CYS");
2393     modifications.put("P1P", "ASN");
2394     modifications.put("P2T", "THR");
2395     modifications.put("P2U", "UR3");
2396     modifications.put("P2Y", "PRO");
2397     modifications.put("P5P", "ALA");
2398     modifications.put("PAQ", "TYR");
2399     modifications.put("PAS", "ASP");
2400     modifications.put("PAT", "TRP");
2401     modifications.put("PAU", "ALA");
2402     modifications.put("PBB", "CYS");
2403     modifications.put("PBF", "PHE");
2404     modifications.put("PBT", "ASN");
2405     modifications.put("PCA", "GLU");
2406     modifications.put("PCC", "PRO");
2407     modifications.put("PCE", "XAA");
2408     modifications.put("PCS", "PHE");
2409     modifications.put("PDL", "XAA");
2410     modifications.put("PDU", "UR3");
2411     modifications.put("PEC", "CYS");
2412     modifications.put("PF5", "PHE");
2413     modifications.put("PFF", "PHE");
2414     modifications.put("PFX", "XAA");
2415     modifications.put("PG1", "SER");
2416     modifications.put("PG7", "GLY");
2417     modifications.put("PG9", "GLY");
2418     modifications.put("PGL", "XAA");
2419     modifications.put("PGN", "GLY");
2420     modifications.put("PGP", "GLY");
2421     modifications.put("PGY", "GLY");
2422     modifications.put("PHA", "PHE");
2423     modifications.put("PHD", "ASP");
2424     modifications.put("PHE", "PHE");
2425     modifications.put("PHI", "PHE");
2426     modifications.put("PHL", "PHE");
2427     modifications.put("PHM", "PHE");
2428     modifications.put("PIA", "AYG");
2429     modifications.put("PIV", "XAA");
2430     modifications.put("PLE", "LEU");
2431     modifications.put("PM3", "PHE");
2432     modifications.put("PMT", "CYS");
2433     modifications.put("POM", "PRO");
2434     modifications.put("PPN", "PHE");
2435     modifications.put("PPU", "ALA");
2436     modifications.put("PPW", "GLY");
2437     modifications.put("PQ1", "ASN");
2438     modifications.put("PR3", "CYS");
2439     modifications.put("PR5", "ALA");
2440     modifications.put("PR9", "PRO");
2441     modifications.put("PRN", "ALA");
2442     modifications.put("PRO", "PRO");
2443     modifications.put("PRS", "PRO");
2444     modifications.put("PSA", "PHE");
2445     modifications.put("PSH", "HIS");
2446     modifications.put("PST", "THR");
2447     modifications.put("PSU", "UR3");
2448     modifications.put("PSW", "CYS");
2449     modifications.put("PTA", "XAA");
2450     modifications.put("PTH", "TYR");
2451     modifications.put("PTM", "TYR");
2452     modifications.put("PTR", "TYR");
2453     modifications.put("PU ", "ALA");
2454     modifications.put("PUY", "ASN");
2455     modifications.put("PVH", "HIS");
2456     modifications.put("PVL", "XAA");
2457     modifications.put("PYA", "ALA");
2458     modifications.put("PYO", "UR3");
2459     modifications.put("PYX", "CYS");
2460     modifications.put("PYY", "ASN");
2461     modifications.put("QLG", "QLG");
2462     modifications.put("QMM", "GLN");
2463     modifications.put("QPA", "CYS");
2464     modifications.put("QPH", "PHE");
2465     modifications.put("QUO", "GLY");
2466     modifications.put("R  ", "ALA");
2467     modifications.put("R1A", "CYS");
2468     modifications.put("R4K", "TRP");
2469     modifications.put("RC7", "HYG");
2470     modifications.put("RE0", "TRP");
2471     modifications.put("RE3", "TRP");
2472     modifications.put("RIA", "ALA");
2473     modifications.put("RMP", "ALA");
2474     modifications.put("RON", "XAA");
2475     modifications.put("RT ", "THR");
2476     modifications.put("RTP", "ASN");
2477     modifications.put("S1H", "SER");
2478     modifications.put("S2C", "CYS");
2479     modifications.put("S2D", "ALA");
2480     modifications.put("S2M", "THR");
2481     modifications.put("S2P", "ALA");
2482     modifications.put("S4A", "ALA");
2483     modifications.put("S4C", "CYS");
2484     modifications.put("S4G", "GLY");
2485     modifications.put("S4U", "UR3");
2486     modifications.put("S6G", "GLY");
2487     modifications.put("SAC", "SER");
2488     modifications.put("SAH", "CYS");
2489     modifications.put("SAR", "GLY");
2490     modifications.put("SBL", "SER");
2491     modifications.put("SC ", "CYS");
2492     modifications.put("SCH", "CYS");
2493     modifications.put("SCS", "CYS");
2494     modifications.put("SCY", "CYS");
2495     modifications.put("SD2", "XAA");
2496     modifications.put("SDG", "GLY");
2497     modifications.put("SDP", "SER");
2498     modifications.put("SEB", "SER");
2499     modifications.put("SEC", "ALA");
2500     modifications.put("SEG", "ALA");
2501     modifications.put("SEL", "SER");
2502     modifications.put("SEM", "SER");
2503     modifications.put("SEN", "SER");
2504     modifications.put("SEP", "SER");
2505     modifications.put("SER", "SER");
2506     modifications.put("SET", "SER");
2507     modifications.put("SGB", "SER");
2508     modifications.put("SHC", "CYS");
2509     modifications.put("SHP", "GLY");
2510     modifications.put("SHR", "LYS");
2511     modifications.put("SIB", "CYS");
2512     modifications.put("SIC", "DC"); // check
2513     modifications.put("SLA", "PRO");
2514     modifications.put("SLR", "PRO");
2515     modifications.put("SLZ", "LYS");
2516     modifications.put("SMC", "CYS");
2517     modifications.put("SME", "MET");
2518     modifications.put("SMF", "PHE");
2519     modifications.put("SMP", "ALA");
2520     modifications.put("SMT", "THR");
2521     modifications.put("SNC", "CYS");
2522     modifications.put("SNN", "ASN");
2523     modifications.put("SOC", "CYS");
2524     modifications.put("SOS", "ASN");
2525     modifications.put("SOY", "SER");
2526     modifications.put("SPT", "THR");
2527     modifications.put("SRA", "ALA");
2528     modifications.put("SSU", "UR3");
2529     modifications.put("STY", "TYR");
2530     modifications.put("SUB", "XAA");
2531     modifications.put("SUI", "DG");
2532     modifications.put("SUN", "SER");
2533     modifications.put("SUR", "UR3");
2534     modifications.put("SVA", "SER");
2535     modifications.put("SVV", "SER");
2536     modifications.put("SVW", "SER");
2537     modifications.put("SVX", "SER");
2538     modifications.put("SVY", "SER");
2539     modifications.put("SVZ", "XAA");
2540     modifications.put("SWG", "SWG");
2541     modifications.put("SYS", "CYS");
2542     modifications.put("T  ", "THR");
2543     modifications.put("T11", "PHE");
2544     modifications.put("T23", "THR");
2545     modifications.put("T2S", "THR");
2546     modifications.put("T2T", "ASN");
2547     modifications.put("T31", "UR3");
2548     modifications.put("T32", "THR");
2549     modifications.put("T36", "THR");
2550     modifications.put("T37", "THR");
2551     modifications.put("T38", "THR");
2552     modifications.put("T39", "THR");
2553     modifications.put("T3P", "THR");
2554     modifications.put("T41", "THR");
2555     modifications.put("T48", "THR");
2556     modifications.put("T49", "THR");
2557     modifications.put("T4S", "THR");
2558     modifications.put("T5O", "UR3");
2559     modifications.put("T5S", "THR");
2560     modifications.put("T66", "XAA");
2561     modifications.put("T6A", "ALA");
2562     modifications.put("TA3", "THR");
2563     modifications.put("TA4", "XAA");
2564     modifications.put("TAF", "THR");
2565     modifications.put("TAL", "ASN");
2566     modifications.put("TAV", "ASP");
2567     modifications.put("TBG", "VAL");
2568     modifications.put("TBM", "THR");
2569     modifications.put("TC1", "CYS");
2570     modifications.put("TCP", "THR");
2571     modifications.put("TCQ", "TYR");
2572     modifications.put("TCR", "TRP");
2573     modifications.put("TCY", "ALA");
2574     modifications.put("TDD", "LEU");
2575     modifications.put("TDY", "THR");
2576     modifications.put("TFE", "THR");
2577     modifications.put("TFO", "ALA");
2578     modifications.put("TFQ", "PHE");
2579     modifications.put("TFT", "THR");
2580     modifications.put("TGP", "GLY");
2581     modifications.put("TH6", "THR");
2582     modifications.put("THC", "THR");
2583     modifications.put("THO", "XAA");
2584     modifications.put("THR", "THR");
2585     modifications.put("THX", "ASN");
2586     modifications.put("THZ", "ARG");
2587     modifications.put("TIH", "ALA");
2588     modifications.put("TLB", "ASN");
2589     modifications.put("TLC", "THR");
2590     modifications.put("TLN", "UR3");
2591     modifications.put("TMB", "THR");
2592     modifications.put("TMD", "THR");
2593     modifications.put("TNB", "CYS");
2594     modifications.put("TNR", "SER");
2595     modifications.put("TOX", "TRP");
2596     modifications.put("TP1", "THR");
2597     modifications.put("TPC", "CYS");
2598     modifications.put("TPG", "GLY");
2599     modifications.put("TPH", "XAA");
2600     modifications.put("TPL", "TRP");
2601     modifications.put("TPO", "THR");
2602     modifications.put("TPQ", "TYR");
2603     modifications.put("TQI", "TRP");
2604     modifications.put("TQQ", "TRP");
2605     modifications.put("TRF", "TRP");
2606     modifications.put("TRG", "LYS");
2607     modifications.put("TRN", "TRP");
2608     modifications.put("TRO", "TRP");
2609     modifications.put("TRP", "TRP");
2610     modifications.put("TRQ", "TRP");
2611     modifications.put("TRW", "TRP");
2612     modifications.put("TRX", "TRP");
2613     modifications.put("TS ", "ASN");
2614     modifications.put("TST", "XAA");
2615     modifications.put("TT ", "ASN");
2616     modifications.put("TTD", "THR");
2617     modifications.put("TTI", "UR3");
2618     modifications.put("TTM", "THR");
2619     modifications.put("TTQ", "TRP");
2620     modifications.put("TTS", "TYR");
2621     modifications.put("TY1", "TYR");
2622     modifications.put("TY2", "TYR");
2623     modifications.put("TY3", "TYR");
2624     modifications.put("TY5", "TYR");
2625     modifications.put("TYB", "TYR");
2626     modifications.put("TYI", "TYR");
2627     modifications.put("TYJ", "TYR");
2628     modifications.put("TYN", "TYR");
2629     modifications.put("TYO", "TYR");
2630     modifications.put("TYQ", "TYR");
2631     modifications.put("TYR", "TYR");
2632     modifications.put("TYS", "TYR");
2633     modifications.put("TYT", "TYR");
2634     modifications.put("TYU", "ASN");
2635     modifications.put("TYW", "TYR");
2636     modifications.put("TYX", "XAA");
2637     modifications.put("TYY", "TYR");
2638     modifications.put("TZB", "XAA");
2639     modifications.put("TZO", "XAA");
2640     modifications.put("U  ", "UR3");
2641     modifications.put("U25", "UR3");
2642     modifications.put("U2L", "UR3");
2643     modifications.put("U2N", "UR3");
2644     modifications.put("U2P", "UR3");
2645     modifications.put("U31", "UR3");
2646     modifications.put("U33", "UR3");
2647     modifications.put("U34", "UR3");
2648     modifications.put("U36", "UR3");
2649     modifications.put("U37", "UR3");
2650     modifications.put("U8U", "UR3");
2651     modifications.put("UAR", "UR3");
2652     modifications.put("UCL", "UR3");
2653     modifications.put("UD5", "UR3");
2654     modifications.put("UDP", "ASN");
2655     modifications.put("UFP", "ASN");
2656     modifications.put("UFR", "UR3");
2657     modifications.put("UFT", "UR3");
2658     modifications.put("UMA", "ALA");
2659     modifications.put("UMP", "UR3");
2660     modifications.put("UMS", "UR3");
2661     modifications.put("UN1", "XAA");
2662     modifications.put("UN2", "XAA");
2663     modifications.put("UNK", "XAA");
2664     modifications.put("UR3", "UR3");
2665     modifications.put("URD", "UR3");
2666     modifications.put("US1", "UR3");
2667     modifications.put("US2", "UR3");
2668     modifications.put("US3", "THR");
2669     modifications.put("US5", "UR3");
2670     modifications.put("USM", "UR3");
2671     modifications.put("VAD", "VAL");
2672     modifications.put("VAF", "VAL");
2673     modifications.put("VAL", "VAL");
2674     modifications.put("VB1", "LYS");
2675     modifications.put("VDL", "XAA");
2676     modifications.put("VLL", "XAA");
2677     modifications.put("VLM", "XAA");
2678     modifications.put("VMS", "XAA");
2679     modifications.put("VOL", "XAA");
2680     modifications.put("WCR", "GYG");
2681     modifications.put("X  ", "GLY");
2682     modifications.put("X2W", "GLU");
2683     modifications.put("X4A", "ASN");
2684     modifications.put("X9Q", "AFG");
2685     modifications.put("XAD", "ALA");
2686     modifications.put("XAE", "ASN");
2687     modifications.put("XAL", "ALA");
2688     modifications.put("XAR", "ASN");
2689     modifications.put("XCL", "CYS");
2690     modifications.put("XCN", "CYS");
2691     modifications.put("XCP", "XAA");
2692     modifications.put("XCR", "CYS");
2693     modifications.put("XCS", "ASN");
2694     modifications.put("XCT", "CYS");
2695     modifications.put("XCY", "CYS");
2696     modifications.put("XGA", "ASN");
2697     modifications.put("XGL", "GLY");
2698     modifications.put("XGR", "GLY");
2699     modifications.put("XGU", "GLY");
2700     modifications.put("XPR", "PRO");
2701     modifications.put("XSN", "ASN");
2702     modifications.put("XTH", "THR");
2703     modifications.put("XTL", "THR");
2704     modifications.put("XTR", "THR");
2705     modifications.put("XTS", "GLY");
2706     modifications.put("XTY", "ASN");
2707     modifications.put("XUA", "ALA");
2708     modifications.put("XUG", "GLY");
2709     modifications.put("XX1", "LYS");
2710     modifications.put("XXY", "THG");
2711     modifications.put("XYG", "DYG");
2712     modifications.put("Y  ", "ALA");
2713     modifications.put("YCM", "CYS");
2714     modifications.put("YG ", "GLY");
2715     modifications.put("YOF", "TYR");
2716     modifications.put("YRR", "ASN");
2717     modifications.put("YYG", "GLY");
2718     modifications.put("Z  ", "CYS");
2719     modifications.put("Z01", "ALA");
2720     modifications.put("ZAD", "ALA");
2721     modifications.put("ZAL", "ALA");
2722     modifications.put("ZBC", "CYS");
2723     modifications.put("ZBU", "UR3");
2724     modifications.put("ZCL", "PHE");
2725     modifications.put("ZCY", "CYS");
2726     modifications.put("ZDU", "UR3");
2727     modifications.put("ZFB", "XAA");
2728     modifications.put("ZGU", "GLY");
2729     modifications.put("ZHP", "ASN");
2730     modifications.put("ZTH", "THR");
2731     modifications.put("ZU0", "THR");
2732     modifications.put("ZZJ", "ALA");
2733
2734   }
2735
2736   public static String getCanonicalAminoAcid(String aA)
2737   {
2738     String canonical = modifications.get(aA);
2739     return canonical == null ? aA : canonical;
2740   }
2741
2742   // main method generates perl representation of residue property hash
2743   // / cut here
2744   public static void main(String[] args)
2745   {
2746     Hashtable<String, Vector<String>> aaProps = new Hashtable<String, Vector<String>>();
2747     System.out.println("my %aa = {");
2748     // invert property hashes
2749     for (String pname : propHash.keySet())
2750     {
2751       Map<String, Integer> phash = propHash.get(pname);
2752       for (String rname : phash.keySet())
2753       {
2754         Vector<String> aprops = aaProps.get(rname);
2755         if (aprops == null)
2756         {
2757           aprops = new Vector<String>();
2758           aaProps.put(rname, aprops);
2759         }
2760         Integer hasprop = phash.get(rname);
2761         if (hasprop.intValue() == 1)
2762         {
2763           aprops.addElement(pname);
2764         }
2765       }
2766     }
2767     Enumeration<String> res = aaProps.keys();
2768     while (res.hasMoreElements())
2769     {
2770       String rname = res.nextElement();
2771
2772       System.out.print("'" + rname + "' => [");
2773       Enumeration<String> props = aaProps.get(rname).elements();
2774       while (props.hasMoreElements())
2775       {
2776         System.out.print("'" + props.nextElement() + "'");
2777         if (props.hasMoreElements())
2778         {
2779           System.out.println(", ");
2780         }
2781       }
2782       System.out.println("]" + (res.hasMoreElements() ? "," : ""));
2783     }
2784     System.out.println("};");
2785   }
2786
2787   // to here
2788
2789   /**
2790    * Returns a list of residue characters for the specified inputs
2791    * 
2792    * @param forNucleotide
2793    * @param includeAmbiguous
2794    * @return
2795    */
2796   public static List<String> getResidues(boolean forNucleotide,
2797           boolean includeAmbiguous)
2798   {
2799     List<String> result = new ArrayList<String>();
2800     if (forNucleotide)
2801     {
2802       for (String nuc : nucleotideName.keySet())
2803       {
2804         int val = nucleotideIndex[nuc.charAt(0)];
2805         if ((!includeAmbiguous && val > 4) || (val >= maxNucleotideIndex))
2806         {
2807           continue;
2808         }
2809         nuc = nuc.toUpperCase();
2810         if (!result.contains(nuc))
2811         {
2812           result.add(nuc);
2813         }
2814       }
2815     }
2816     else
2817     {
2818       /*
2819        * Peptide
2820        */
2821       for (String res : aa3Hash.keySet())
2822       {
2823         int index = aa3Hash.get(res).intValue();
2824         if ((!includeAmbiguous && index >= 20) || index >= maxProteinIndex)
2825         {
2826           continue;
2827         }
2828         res = res.toUpperCase();
2829         if (!result.contains(res))
2830         {
2831           result.add(res);
2832         }
2833       }
2834     }
2835
2836     return result;
2837   }
2838
2839   /**
2840    * Returns the single letter code for a three letter code, or '0' if not known
2841    * 
2842    * @param threeLetterCode
2843    *          not case sensitive
2844    * @return
2845    */
2846   public static char getSingleCharacterCode(String threeLetterCode)
2847   {
2848     if (threeLetterCode == null)
2849     {
2850       return '0';
2851     }
2852     Integer index = ResidueProperties.aa3Hash.get(threeLetterCode
2853             .toUpperCase());
2854     return index == null ? '0' : aa[index].charAt(0);
2855   }
2856 }