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