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