2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemes;
21 import java.util.List;
25 public class ResidueProperties
27 public static Hashtable scoreMatrices = new Hashtable();
29 // Stores residue codes/names and colours and other things
30 public static final int[] aaIndex; // aaHash version 2.1.1 and below
32 public static final int[] nucleotideIndex;
34 public static final int[] purinepyrimidineIndex;
36 public static final Hashtable aa3Hash = new Hashtable();
38 public static final Hashtable aa2Triplet = new Hashtable();
40 public static final Hashtable nucleotideName = new Hashtable();
44 aaIndex = new int[255];
45 for (int i = 0; i < 255; i++)
97 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
98 // extend subt. matrices
102 * maximum (gap) index for matrices involving protein alphabet
104 public final static int maxProteinIndex = 23;
107 * maximum (gap) index for matrices involving nucleotide alphabet
109 public final static int maxNucleotideIndex = 10;
113 nucleotideIndex = new int[255];
114 for (int i = 0; i < 255; i++)
116 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
119 nucleotideIndex['A'] = 0;
120 nucleotideIndex['a'] = 0;
121 nucleotideIndex['C'] = 1;
122 nucleotideIndex['c'] = 1;
123 nucleotideIndex['G'] = 2;
124 nucleotideIndex['g'] = 2;
125 nucleotideIndex['T'] = 3;
126 nucleotideIndex['t'] = 3;
127 nucleotideIndex['U'] = 4;
128 nucleotideIndex['u'] = 4;
129 nucleotideIndex['I'] = 5;
130 nucleotideIndex['i'] = 5;
131 nucleotideIndex['X'] = 6;
132 nucleotideIndex['x'] = 6;
133 nucleotideIndex['R'] = 7;
134 nucleotideIndex['r'] = 7;
135 nucleotideIndex['Y'] = 8;
136 nucleotideIndex['y'] = 8;
137 nucleotideIndex['N'] = 9;
138 nucleotideIndex['n'] = 9;
140 nucleotideName.put("A", "Adenine");
141 nucleotideName.put("a", "Adenine");
142 nucleotideName.put("G", "Guanine");
143 nucleotideName.put("g", "Guanine");
144 nucleotideName.put("C", "Cytosine");
145 nucleotideName.put("c", "Cytosine");
146 nucleotideName.put("T", "Thymine");
147 nucleotideName.put("t", "Thymine");
148 nucleotideName.put("U", "Uracil");
149 nucleotideName.put("u", "Uracil");
150 nucleotideName.put("I", "Inosine");
151 nucleotideName.put("i", "Inosine");
152 nucleotideName.put("X", "Xanthine");
153 nucleotideName.put("x", "Xanthine");
154 nucleotideName.put("R", "Unknown Purine");
155 nucleotideName.put("r", "Unknown Purine");
156 nucleotideName.put("Y", "Unknown Pyrimidine");
157 nucleotideName.put("y", "Unknown Pyrimidine");
158 nucleotideName.put("N", "Unknown");
159 nucleotideName.put("n", "Unknown");
160 nucleotideName.put("W", "Weak nucleotide (A or T)");
161 nucleotideName.put("w", "Weak nucleotide (A or T)");
162 nucleotideName.put("S", "Strong nucleotide (G or C)");
163 nucleotideName.put("s", "Strong nucleotide (G or C)");
164 nucleotideName.put("M", "Amino (A or C)");
165 nucleotideName.put("m", "Amino (A or C)");
166 nucleotideName.put("K", "Keto (G or T)");
167 nucleotideName.put("k", "Keto (G or T)");
168 nucleotideName.put("B", "Not A (G or C or T)");
169 nucleotideName.put("b", "Not A (G or C or T)");
170 nucleotideName.put("H", "Not G (A or C or T)");
171 nucleotideName.put("h", "Not G (A or C or T)");
172 nucleotideName.put("D", "Not C (A or G or T)");
173 nucleotideName.put("d", "Not C (A or G or T)");
174 nucleotideName.put("V", "Not T (A or G or C");
175 nucleotideName.put("v", "Not T (A or G or C");
181 purinepyrimidineIndex = new int[255];
182 for (int i = 0; i < 255; i++)
184 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
188 purinepyrimidineIndex['A'] = 0;
189 purinepyrimidineIndex['a'] = 0;
190 purinepyrimidineIndex['C'] = 1;
191 purinepyrimidineIndex['c'] = 1;
192 purinepyrimidineIndex['G'] = 0;
193 purinepyrimidineIndex['g'] = 0;
194 purinepyrimidineIndex['T'] = 1;
195 purinepyrimidineIndex['t'] = 1;
196 purinepyrimidineIndex['U'] = 1;
197 purinepyrimidineIndex['u'] = 1;
198 purinepyrimidineIndex['I'] = 2;
199 purinepyrimidineIndex['i'] = 2;
200 purinepyrimidineIndex['X'] = 2;
201 purinepyrimidineIndex['x'] = 2;
202 purinepyrimidineIndex['R'] = 0;
203 purinepyrimidineIndex['r'] = 0;
204 purinepyrimidineIndex['Y'] = 1;
205 purinepyrimidineIndex['y'] = 1;
206 purinepyrimidineIndex['N'] = 2;
207 purinepyrimidineIndex['n'] = 2;
212 aa3Hash.put("ALA", new Integer(0));
213 aa3Hash.put("ARG", new Integer(1));
214 aa3Hash.put("ASN", new Integer(2));
215 aa3Hash.put("ASP", new Integer(3)); // D
216 aa3Hash.put("CYS", new Integer(4));
217 aa3Hash.put("GLN", new Integer(5)); // Q
218 aa3Hash.put("GLU", new Integer(6)); // E
219 aa3Hash.put("GLY", new Integer(7));
220 aa3Hash.put("HIS", new Integer(8));
221 aa3Hash.put("ILE", new Integer(9));
222 aa3Hash.put("LEU", new Integer(10));
223 aa3Hash.put("LYS", new Integer(11));
224 aa3Hash.put("MET", new Integer(12));
225 aa3Hash.put("PHE", new Integer(13));
226 aa3Hash.put("PRO", new Integer(14));
227 aa3Hash.put("SER", new Integer(15));
228 aa3Hash.put("THR", new Integer(16));
229 aa3Hash.put("TRP", new Integer(17));
230 aa3Hash.put("TYR", new Integer(18));
231 aa3Hash.put("VAL", new Integer(19));
232 // IUB Nomenclature for ambiguous peptides
233 aa3Hash.put("ASX", new Integer(20)); // "B";
234 aa3Hash.put("GLX", new Integer(21)); // X
235 aa3Hash.put("XAA", new Integer(22)); // X unknown
236 aa3Hash.put("-", new Integer(23));
237 aa3Hash.put("*", new Integer(23));
238 aa3Hash.put(".", new Integer(23));
239 aa3Hash.put(" ", new Integer(23));
240 aa3Hash.put("Gap", new Integer(23));
245 aa2Triplet.put("A", "ALA");
246 aa2Triplet.put("a", "ALA");
247 aa2Triplet.put("R", "ARG");
248 aa2Triplet.put("r", "ARG");
249 aa2Triplet.put("N", "ASN");
250 aa2Triplet.put("n", "ASN");
251 aa2Triplet.put("D", "ASP");
252 aa2Triplet.put("d", "ASP");
253 aa2Triplet.put("C", "CYS");
254 aa2Triplet.put("c", "CYS");
255 aa2Triplet.put("Q", "GLN");
256 aa2Triplet.put("q", "GLN");
257 aa2Triplet.put("E", "GLU");
258 aa2Triplet.put("e", "GLU");
259 aa2Triplet.put("G", "GLY");
260 aa2Triplet.put("g", "GLY");
261 aa2Triplet.put("H", "HIS");
262 aa2Triplet.put("h", "HIS");
263 aa2Triplet.put("I", "ILE");
264 aa2Triplet.put("i", "ILE");
265 aa2Triplet.put("L", "LEU");
266 aa2Triplet.put("l", "LEU");
267 aa2Triplet.put("K", "LYS");
268 aa2Triplet.put("k", "LYS");
269 aa2Triplet.put("M", "MET");
270 aa2Triplet.put("m", "MET");
271 aa2Triplet.put("F", "PHE");
272 aa2Triplet.put("f", "PHE");
273 aa2Triplet.put("P", "PRO");
274 aa2Triplet.put("p", "PRO");
275 aa2Triplet.put("S", "SER");
276 aa2Triplet.put("s", "SER");
277 aa2Triplet.put("T", "THR");
278 aa2Triplet.put("t", "THR");
279 aa2Triplet.put("W", "TRP");
280 aa2Triplet.put("w", "TRP");
281 aa2Triplet.put("Y", "TYR");
282 aa2Triplet.put("y", "TYR");
283 aa2Triplet.put("V", "VAL");
284 aa2Triplet.put("v", "VAL");
287 public static final String[] aa =
288 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
289 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
291 public static final Color midBlue = new Color(100, 100, 255);
293 public static final Vector scaleColours = new Vector();
297 scaleColours.addElement(new Color(114, 0, 147));
298 scaleColours.addElement(new Color(156, 0, 98));
299 scaleColours.addElement(new Color(190, 0, 0));
300 scaleColours.addElement(Color.red);
301 scaleColours.addElement(new Color(255, 125, 0));
302 scaleColours.addElement(Color.orange);
303 scaleColours.addElement(new Color(255, 194, 85));
304 scaleColours.addElement(Color.yellow);
305 scaleColours.addElement(new Color(255, 255, 181));
306 scaleColours.addElement(Color.white);
309 public static final Color[] taylor =
310 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
311 new Color(0, 0, 255), // R Blueish-bluey-blue
312 new Color(204, 0, 255), // N Blueish-reddy-blue
313 new Color(255, 0, 0), // D Reddish-reddy-red
314 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
315 new Color(255, 0, 204), // Q Reddish-bluey-red
316 new Color(255, 0, 102), // E Blueish-reddy-red
317 new Color(255, 153, 0), // G Yellowy-reddy-yellow
318 new Color(0, 102, 255), // H Greenish-bluey-blue
319 new Color(102, 255, 0), // I Greenish-yellowy-green
320 new Color(51, 255, 0), // L Yellowish-greeny-green
321 new Color(102, 0, 255), // K Reddish-bluey-blue
322 new Color(0, 255, 0), // M Greenish-greeny-green
323 new Color(0, 255, 102), // F Blueish-greeny-green
324 new Color(255, 204, 0), // P Reddish-yellowy-yellow
325 new Color(255, 51, 0), // S Yellowish-reddy-red
326 new Color(255, 102, 0), // T Reddish-yellowy-red
327 new Color(0, 204, 255), // W Blueish-greeny-green
328 new Color(0, 255, 204), // Y Greenish-bluey-green
329 new Color(153, 255, 0), // V Yellowish-greeny-yellow
338 public static final Color[] nucleotide =
339 { new Color(100, 247, 63), // A
340 new Color(255, 179, 64), // C
341 new Color(235, 65, 60), // G
342 new Color(60, 136, 238), // T
343 new Color(60, 136, 238), // U
344 Color.white, // I (inosine)
345 Color.white, // X (xanthine)
352 // Added for PurinePyrimidineColourScheme
353 public static final Color[] purinepyrimidine =
354 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
355 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
356 Color.white, // all other nucleotides
361 public static final Color[] zappo =
370 midBlue,// Color.red, // H
391 // Dunno where I got these numbers from
392 public static final double[] hyd2 =
418 public static final double[] helix =
419 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
420 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
422 public static final double helixmin = 0.57;
424 public static final double helixmax = 1.51;
426 public static final double[] strand =
427 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
428 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
430 public static final double strandmin = 0.37;
432 public static final double strandmax = 1.7;
434 public static final double[] turn =
435 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
436 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
439 public static final double turnmin = 0.47;
441 public static final double turnmax = 1.56;
443 public static final double[] buried =
444 { 1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2,
445 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
447 public static final double buriedmin = 0.05;
449 public static final double buriedmax = 4.6;
451 // This is hydropathy index
452 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
453 // 1157, 105-132, 1982
454 public static final double[] hyd =
455 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
456 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
458 public static final double hydmax = 4.5;
460 public static final double hydmin = -3.9;
462 // public static final double hydmax = 1.38;
463 // public static final double hydmin = -2.53;
464 private static final int[][] BLOSUM62 =
466 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
467 -2, 0, -2, -1, 0, -4 },
468 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
469 -2, -3, -1, 0, -1, -4 },
470 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
472 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
473 -3, -3, 4, 1, -1, -4 },
474 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
475 -2, -2, -1, -3, -3, -2, -4 },
476 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
478 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
480 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
481 -3, -3, -1, -2, -1, -4 },
482 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
483 2, -3, 0, 0, -1, -4 },
484 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
485 -1, 3, -3, -3, -1, -4 },
486 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
487 -1, 1, -4, -3, -1, -4 },
488 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
489 -2, -2, 0, 1, -1, -4 },
490 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
491 -1, 1, -3, -1, -1, -4 },
492 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
493 3, -1, -3, -3, -1, -4 },
494 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
495 -4, -3, -2, -2, -1, -2, -4 },
496 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
498 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
499 -2, 0, -1, -1, 0, -4 },
500 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
501 11, 2, -3, -4, -3, -2, -4 },
502 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
503 2, 7, -1, -3, -2, -1, -4 },
504 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
505 -1, 4, -3, -2, -1, -4 },
506 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
507 -3, -3, 4, 1, -1, -4 },
508 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
510 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
511 -2, -1, -1, -1, -1, -1, -4 },
512 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
513 -4, -4, -4, -4, -4, -4, 1 }, };
515 static final int[][] PAM250 =
517 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
519 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
521 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
523 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
525 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
526 -8, 0, -2, -4, -5, -3, -8 },
527 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
529 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
531 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
533 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
535 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
536 -1, 4, -2, -2, -1, -8 },
537 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
538 -1, 2, -3, -3, -1, -8 },
539 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
541 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
542 -2, 2, -2, -2, -1, -8 },
543 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
544 7, -1, -4, -5, -2, -8 },
545 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
547 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
549 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
551 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
552 17, 0, -6, -5, -6, -4, -8 },
553 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
554 10, -2, -3, -4, -2, -8 },
555 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
556 -2, 4, -2, -2, -1, -8 },
557 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
559 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
561 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
562 -2, -1, -1, -1, -1, -8 },
563 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
564 -8, -8, -8, -8, -8, -8, 1 }, };
566 public static final Hashtable ssHash = new Hashtable(); // stores the number
571 ssHash.put("H", Color.magenta);
572 ssHash.put("E", Color.yellow);
573 ssHash.put("-", Color.white);
574 ssHash.put(".", Color.white);
575 ssHash.put("S", Color.cyan);
576 ssHash.put("T", Color.blue);
577 ssHash.put("G", Color.pink);
578 ssHash.put("I", Color.pink);
579 ssHash.put("B", Color.yellow);
583 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
584 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
587 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
588 // Will equate sequences if working with mixed nucleotide sets.
589 // treats T and U identically. R and Y weak equivalence with AG and CTU.
590 // N matches any other base weakly
592 static final int[][] DNA =
594 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
595 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
596 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
597 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
598 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
599 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
600 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
601 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
602 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
603 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
604 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
607 * register matrices in list
611 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
612 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
613 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
617 public static final Color[] pidColours =
618 { midBlue, new Color(153, 153, 255),
620 new Color(204, 204, 255), };
622 public static final float[] pidThresholds =
625 public static Hashtable codonHash = new Hashtable();
627 public static Vector Lys = new Vector();
629 public static Vector Asn = new Vector();
631 public static Vector Gln = new Vector();
633 public static Vector His = new Vector();
635 public static Vector Glu = new Vector();
637 public static Vector Asp = new Vector();
639 public static Vector Tyr = new Vector();
641 public static Vector Thr = new Vector();
643 public static Vector Pro = new Vector();
645 public static Vector Ala = new Vector();
647 public static Vector Ser = new Vector();
649 public static Vector Arg = new Vector();
651 public static Vector Gly = new Vector();
653 public static Vector Trp = new Vector();
655 public static Vector Cys = new Vector();
657 public static Vector Ile = new Vector();
659 public static Vector Met = new Vector();
661 public static Vector Leu = new Vector();
663 public static Vector Val = new Vector();
665 public static Vector Phe = new Vector();
667 public static Vector STOP = new Vector();
671 codonHash.put("K", Lys);
672 codonHash.put("N", Asn);
673 codonHash.put("Q", Gln);
674 codonHash.put("H", His);
675 codonHash.put("E", Glu);
676 codonHash.put("D", Asp);
677 codonHash.put("Y", Tyr);
678 codonHash.put("T", Thr);
679 codonHash.put("P", Pro);
680 codonHash.put("A", Ala);
681 codonHash.put("S", Ser);
682 codonHash.put("R", Arg);
683 codonHash.put("G", Gly);
684 codonHash.put("W", Trp);
685 codonHash.put("C", Cys);
686 codonHash.put("I", Ile);
687 codonHash.put("M", Met);
688 codonHash.put("L", Leu);
689 codonHash.put("V", Val);
690 codonHash.put("F", Phe);
691 codonHash.put("STOP", STOP);
695 * Nucleotide Ambiguity Codes
697 public static final Hashtable<String,String[]> ambiguityCodes=new Hashtable<String,String[]>();
699 * Codon triplets with additional symbols for unambiguous codons that include ambiguity codes
701 public static final Hashtable<String,String> codonHash2 = new Hashtable<String,String>();
704 * all ambiguity codes for a given base
706 public final static Hashtable<String,List<String>> _ambiguityCodes = new Hashtable<String,List<String>>();
712 * 3.2. Purine (adenine or guanine): R
714 * R is the symbol previously recommended [1].
716 ambiguityCodes.put("R", new String[]
720 * 3.3. Pyrimidine (thymine or cytosine): Y
722 * Y is the symbol previously recommended [1].
724 ambiguityCodes.put("Y", new String[]
727 * 3.4. Adenine or thymine: W
729 * Although several diverse symbols have been used for this pair, (and for
730 * the reciprocal pair G+C), only two symbols have a rational basis, L and
731 * W: L derives from DNA density (light; G+C - heavy - would thus be H); W
732 * derives from the strength of the hydrogen bonding interaction between the
733 * base pairs (weak for A+T: G +C - strong - would thus be S). However, the
734 * system recommended for the three-base series (not-A = B, etc., see below,
735 * section 3.8) rules out H as this would be not-G. W is thus recommended.
737 ambiguityCodes.put("W", new String[]
740 * 3.5. Guanine or cytosine: S
742 * The choice of this symbol is discussed above in section 3.4.
744 ambiguityCodes.put("S", new String[]
747 * 3.6. Adenine or cytosine: M
749 * There are few common features between A and C. The presence of an NH2
750 * group in similar positions on both bases (Fig. 1) makes possible a
751 * logically derived symbol. A and N being ruled out, M (from aMino) is
755 * Fig. 1. Origin of the symbols M and K The four bases are drawn so as to
756 * show the relationship between adenine and cytosine on the one hand, which
757 * both have aMino groups at the ring position most distant from the point
758 * of attachment to the sugar, and between guanine and thymine on the other,
759 * which both have Keto groups at the corresponding position. The ring atoms
760 * are numbered as recommended [24-26], although for the present purpose
761 * this has the disadvantage of giving discordant numbers to the
762 * corresponding positions.
764 ambiguityCodes.put("M", new String[]
767 * 3.7. Guanine or thymine: K By analogy with A and C (section 3.6), both G
768 * and T have Keto groups in similar positions (Fig. 1).
770 ambiguityCodes.put("K", new String[]
773 * 3.8. Adenine or thymine or cytosine: H
775 * Not-G is the most simple means of memorising this combination and symbols
776 * logically related to G were examined. F and H would both be suitable, as
777 * the letters before and after G in the alphabet, but A would have no
778 * equivalent to F. The use of H has historical precedence [2].
780 ambiguityCodes.put("H", new String[]
783 * 3.9. Guanine or cytosine or thymine: B
785 * Not-A as above (section 3.8).
787 ambiguityCodes.put("B", new String[]
790 * 3.10. Guanine or adenine or cytosine: V
792 * Not-T by analogy with not-G (section 3.8) would be U but this is ruled
793 * out to eliminate confusion with uracil. V is the next logical choice.
794 * Note that T and U may in some cases be considered to be synonyms.
796 ambiguityCodes.put("V", new String[]
799 * 3.11. Guanine or adenine or thymine: D
801 * Not-C as above (section 3.8).
803 ambiguityCodes.put("D", new String[]
806 * 3.12. Guanine or adenine or thymine or cytosine: N
808 ambiguityCodes.put("R", new String[]
809 { "G", "A", "T", "C" });
810 // Now build codon translation table
811 codonHash2.put("AAA", "K");
812 codonHash2.put("AAG", "K");
813 codonHash2.put("AAC", "N");
814 codonHash2.put("AAT", "N");
816 codonHash2.put("CAA", "Q");
817 codonHash2.put("CAG", "Q");
818 codonHash2.put("CAC", "H");
819 codonHash2.put("CAT", "H");
821 codonHash2.put("GAA", "E");
822 codonHash2.put("GAG", "E");
823 codonHash2.put("GAC", "D");
824 codonHash2.put("GAT", "D");
826 codonHash2.put("TAC", "Y");
827 codonHash2.put("TAT", "Y");
829 codonHash2.put("ACA", "T");
830 codonHash2.put("ACC", "T");
831 codonHash2.put("ACT", "T");
832 codonHash2.put("ACG", "T");
834 codonHash2.put("CCA", "P");
835 codonHash2.put("CCG", "P");
836 codonHash2.put("CCC", "P");
837 codonHash2.put("CCT", "P");
839 codonHash2.put("GCA", "A");
840 codonHash2.put("GCG", "A");
841 codonHash2.put("GCC", "A");
842 codonHash2.put("GCT", "A");
844 codonHash2.put("TCA", "S");
845 codonHash2.put("TCG", "S");
846 codonHash2.put("TCC", "S");
847 codonHash2.put("TCT", "S");
848 codonHash2.put("AGC", "S");
849 codonHash2.put("AGT", "S");
851 codonHash2.put("AGA", "R");
852 codonHash2.put("AGG", "R");
853 codonHash2.put("CGA", "R");
854 codonHash2.put("CGG", "R");
855 codonHash2.put("CGC", "R");
856 codonHash2.put("CGT", "R");
858 codonHash2.put("GGA", "G");
859 codonHash2.put("GGG", "G");
860 codonHash2.put("GGC", "G");
861 codonHash2.put("GGT", "G");
863 codonHash2.put("TGA", "*");
864 codonHash2.put("TAA", "*");
865 codonHash2.put("TAG", "*");
867 codonHash2.put("TGG", "W");
869 codonHash2.put("TGC", "C");
870 codonHash2.put("TGT", "C");
872 codonHash2.put("ATA", "I");
873 codonHash2.put("ATC", "I");
874 codonHash2.put("ATT", "I");
876 codonHash2.put("ATG", "M");
878 codonHash2.put("CTA", "L");
879 codonHash2.put("CTG", "L");
880 codonHash2.put("CTC", "L");
881 codonHash2.put("CTT", "L");
882 codonHash2.put("TTA", "L");
883 codonHash2.put("TTG", "L");
885 codonHash2.put("GTA", "V");
886 codonHash2.put("GTG", "V");
887 codonHash2.put("GTC", "V");
888 codonHash2.put("GTT", "V");
890 codonHash2.put("TTC", "F");
891 codonHash2.put("TTT", "F");
893 buildAmbiguityCodonSet();
897 * programmatic generation of codons including ambiguity codes
899 public static void buildAmbiguityCodonSet()
901 if (_ambiguityCodes.size() > 0)
904 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
907 // Invert the ambiguity code set
908 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
910 for (String r : acode.getValue())
912 List<String> codesfor = _ambiguityCodes.get(r);
913 if (codesfor == null)
915 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
917 if (!codesfor.contains(acode.getKey()))
919 codesfor.add(acode.getKey());
924 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
925 + acode.getKey() + " in residue " + r);
929 // and programmatically add in the ambiguity codes that yield the same amino
931 String[] unambcodons = codonHash2.keySet().toArray(new String[codonHash2.size()]);
932 for (String codon : unambcodons)
934 String residue = codonHash2.get(codon);
935 String acodon[][] = new String[codon.length()][];
936 for (int i = 0, iSize = codon.length(); i < iSize; i++)
938 String _ac = "" + codon.charAt(i);
939 List<String> acodes = _ambiguityCodes.get(_ac);
942 acodon[i] = acodes.toArray(new String[acodes.size()]);
946 acodon[i] = new String[]
950 // enumerate all combinations and test for veracity of translation
951 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
952 for (int i = 0; i < tpos.length; i++)
956 tpos[acodon.length - 1] = 0;
958 while (tpos[0] < acodon[0].length)
960 // make all codons for this combination
961 char allres[][] = new char[tpos.length][];
964 for (ipos = 0; ipos < tpos.length; ipos++)
966 if (acodon[ipos].length==0 || tpos[ipos] < 0)
968 _acodon += codon.charAt(ipos);
969 allres[ipos] = new char[]
970 { codon.charAt(ipos) };
974 _acodon += acodon[ipos][tpos[ipos]];
975 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
976 allres[ipos] = new char[altbase.length];
978 for (String ab : altbase)
980 allres[ipos][j++] = ab.charAt(0);
984 // test all codons for this combination
985 for (ipos = 0; ipos < cpos.length; ipos++)
989 boolean valid = true;
993 for (j = 0; j < cpos.length; j++)
995 _codon += allres[j][cpos[j]];
997 String tr = codonHash2.get(_codon);
998 if (valid = (tr!=null && tr.equals(residue)))
1000 // advance to next combination
1001 ipos = acodon.length - 1;
1002 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
1008 } while (valid && cpos[0] < allres[0].length);
1011 // Add this to the set of codons we will translate
1012 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
1014 codonHash2.put(_acodon, residue);
1018 // System.err.println("Rejecting ambiguity codon: " + _acodon
1019 // + " for " + residue);
1022 ipos = acodon.length - 1;
1023 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1035 Lys.addElement("AAA");
1036 Lys.addElement("AAG");
1037 Asn.addElement("AAC");
1038 Asn.addElement("AAT");
1040 Gln.addElement("CAA");
1041 Gln.addElement("CAG");
1042 His.addElement("CAC");
1043 His.addElement("CAT");
1045 Glu.addElement("GAA");
1046 Glu.addElement("GAG");
1047 Asp.addElement("GAC");
1048 Asp.addElement("GAT");
1050 Tyr.addElement("TAC");
1051 Tyr.addElement("TAT");
1053 Thr.addElement("ACA");
1054 Thr.addElement("ACG");
1055 Thr.addElement("ACC");
1056 Thr.addElement("ACT");
1058 Pro.addElement("CCA");
1059 Pro.addElement("CCG");
1060 Pro.addElement("CCC");
1061 Pro.addElement("CCT");
1063 Ala.addElement("GCA");
1064 Ala.addElement("GCG");
1065 Ala.addElement("GCC");
1066 Ala.addElement("GCT");
1068 Ser.addElement("TCA");
1069 Ser.addElement("TCG");
1070 Ser.addElement("TCC");
1071 Ser.addElement("TCT");
1072 Ser.addElement("AGC");
1073 Ser.addElement("AGT");
1075 Arg.addElement("AGA");
1076 Arg.addElement("AGG");
1077 Arg.addElement("CGA");
1078 Arg.addElement("CGG");
1079 Arg.addElement("CGC");
1080 Arg.addElement("CGT");
1082 Gly.addElement("GGA");
1083 Gly.addElement("GGG");
1084 Gly.addElement("GGC");
1085 Gly.addElement("GGT");
1087 STOP.addElement("TGA");
1088 STOP.addElement("TAA");
1089 STOP.addElement("TAG");
1091 Trp.addElement("TGG");
1093 Cys.addElement("TGC");
1094 Cys.addElement("TGT");
1096 Ile.addElement("ATA");
1097 Ile.addElement("ATC");
1098 Ile.addElement("ATT");
1100 Met.addElement("ATG");
1102 Leu.addElement("CTA");
1103 Leu.addElement("CTG");
1104 Leu.addElement("CTC");
1105 Leu.addElement("CTT");
1106 Leu.addElement("TTA");
1107 Leu.addElement("TTG");
1109 Val.addElement("GTA");
1110 Val.addElement("GTG");
1111 Val.addElement("GTC");
1112 Val.addElement("GTT");
1114 Phe.addElement("TTC");
1115 Phe.addElement("TTT");
1118 // Stores residue codes/names and colours and other things
1119 public static Hashtable propHash = new Hashtable();
1121 public static Hashtable hydrophobic = new Hashtable();
1123 public static Hashtable polar = new Hashtable();
1125 public static Hashtable small = new Hashtable();
1127 public static Hashtable positive = new Hashtable();
1129 public static Hashtable negative = new Hashtable();
1131 public static Hashtable charged = new Hashtable();
1133 public static Hashtable aromatic = new Hashtable();
1135 public static Hashtable aliphatic = new Hashtable();
1137 public static Hashtable tiny = new Hashtable();
1139 public static Hashtable proline = new Hashtable();
1143 hydrophobic.put("I", new Integer(1));
1144 hydrophobic.put("L", new Integer(1));
1145 hydrophobic.put("V", new Integer(1));
1146 hydrophobic.put("C", new Integer(1));
1147 hydrophobic.put("A", new Integer(1));
1148 hydrophobic.put("G", new Integer(1));
1149 hydrophobic.put("M", new Integer(1));
1150 hydrophobic.put("F", new Integer(1));
1151 hydrophobic.put("Y", new Integer(1));
1152 hydrophobic.put("W", new Integer(1));
1153 hydrophobic.put("H", new Integer(1));
1154 hydrophobic.put("K", new Integer(1));
1155 hydrophobic.put("X", new Integer(1));
1156 hydrophobic.put("-", new Integer(1));
1157 hydrophobic.put("*", new Integer(1));
1158 hydrophobic.put("R", new Integer(0));
1159 hydrophobic.put("E", new Integer(0));
1160 hydrophobic.put("Q", new Integer(0));
1161 hydrophobic.put("D", new Integer(0));
1162 hydrophobic.put("N", new Integer(0));
1163 hydrophobic.put("S", new Integer(0));
1164 hydrophobic.put("T", new Integer(0));
1165 hydrophobic.put("P", new Integer(0));
1170 polar.put("Y", new Integer(1));
1171 polar.put("W", new Integer(1));
1172 polar.put("H", new Integer(1));
1173 polar.put("K", new Integer(1));
1174 polar.put("R", new Integer(1));
1175 polar.put("E", new Integer(1));
1176 polar.put("Q", new Integer(1));
1177 polar.put("D", new Integer(1));
1178 polar.put("N", new Integer(1));
1179 polar.put("S", new Integer(1));
1180 polar.put("T", new Integer(1));
1181 polar.put("X", new Integer(1));
1182 polar.put("-", new Integer(1));
1183 polar.put("*", new Integer(1));
1184 polar.put("I", new Integer(0));
1185 polar.put("L", new Integer(0));
1186 polar.put("V", new Integer(0));
1187 polar.put("C", new Integer(0));
1188 polar.put("A", new Integer(0));
1189 polar.put("G", new Integer(0));
1190 polar.put("M", new Integer(0));
1191 polar.put("F", new Integer(0));
1192 polar.put("P", new Integer(0));
1197 small.put("I", new Integer(0));
1198 small.put("L", new Integer(0));
1199 small.put("V", new Integer(1));
1200 small.put("C", new Integer(1));
1201 small.put("A", new Integer(1));
1202 small.put("G", new Integer(1));
1203 small.put("M", new Integer(0));
1204 small.put("F", new Integer(0));
1205 small.put("Y", new Integer(0));
1206 small.put("W", new Integer(0));
1207 small.put("H", new Integer(0));
1208 small.put("K", new Integer(0));
1209 small.put("R", new Integer(0));
1210 small.put("E", new Integer(0));
1211 small.put("Q", new Integer(0));
1212 small.put("D", new Integer(1));
1213 small.put("N", new Integer(1));
1214 small.put("S", new Integer(1));
1215 small.put("T", new Integer(1));
1216 small.put("P", new Integer(1));
1217 small.put("-", new Integer(1));
1218 small.put("*", new Integer(1));
1223 positive.put("I", new Integer(0));
1224 positive.put("L", new Integer(0));
1225 positive.put("V", new Integer(0));
1226 positive.put("C", new Integer(0));
1227 positive.put("A", new Integer(0));
1228 positive.put("G", new Integer(0));
1229 positive.put("M", new Integer(0));
1230 positive.put("F", new Integer(0));
1231 positive.put("Y", new Integer(0));
1232 positive.put("W", new Integer(0));
1233 positive.put("H", new Integer(1));
1234 positive.put("K", new Integer(1));
1235 positive.put("R", new Integer(1));
1236 positive.put("E", new Integer(0));
1237 positive.put("Q", new Integer(0));
1238 positive.put("D", new Integer(0));
1239 positive.put("N", new Integer(0));
1240 positive.put("S", new Integer(0));
1241 positive.put("T", new Integer(0));
1242 positive.put("P", new Integer(0));
1243 positive.put("-", new Integer(1));
1244 positive.put("*", new Integer(1));
1249 negative.put("I", new Integer(0));
1250 negative.put("L", new Integer(0));
1251 negative.put("V", new Integer(0));
1252 negative.put("C", new Integer(0));
1253 negative.put("A", new Integer(0));
1254 negative.put("G", new Integer(0));
1255 negative.put("M", new Integer(0));
1256 negative.put("F", new Integer(0));
1257 negative.put("Y", new Integer(0));
1258 negative.put("W", new Integer(0));
1259 negative.put("H", new Integer(0));
1260 negative.put("K", new Integer(0));
1261 negative.put("R", new Integer(0));
1262 negative.put("E", new Integer(1));
1263 negative.put("Q", new Integer(0));
1264 negative.put("D", new Integer(1));
1265 negative.put("N", new Integer(0));
1266 negative.put("S", new Integer(0));
1267 negative.put("T", new Integer(0));
1268 negative.put("P", new Integer(0));
1269 negative.put("-", new Integer(1));
1270 negative.put("*", new Integer(1));
1275 charged.put("I", new Integer(0));
1276 charged.put("L", new Integer(0));
1277 charged.put("V", new Integer(0));
1278 charged.put("C", new Integer(0));
1279 charged.put("A", new Integer(0));
1280 charged.put("G", new Integer(0));
1281 charged.put("M", new Integer(0));
1282 charged.put("F", new Integer(0));
1283 charged.put("Y", new Integer(0));
1284 charged.put("W", new Integer(0));
1285 charged.put("H", new Integer(1));
1286 charged.put("K", new Integer(1));
1287 charged.put("R", new Integer(1));
1288 charged.put("E", new Integer(1));
1289 charged.put("Q", new Integer(0));
1290 charged.put("D", new Integer(1));
1291 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1292 // Alternative would be charged and
1293 // negative (in basic form)?
1294 charged.put("S", new Integer(0));
1295 charged.put("T", new Integer(0));
1296 charged.put("P", new Integer(0));
1297 charged.put("-", new Integer(1));
1298 charged.put("*", new Integer(1));
1303 aromatic.put("I", new Integer(0));
1304 aromatic.put("L", new Integer(0));
1305 aromatic.put("V", new Integer(0));
1306 aromatic.put("C", new Integer(0));
1307 aromatic.put("A", new Integer(0));
1308 aromatic.put("G", new Integer(0));
1309 aromatic.put("M", new Integer(0));
1310 aromatic.put("F", new Integer(1));
1311 aromatic.put("Y", new Integer(1));
1312 aromatic.put("W", new Integer(1));
1313 aromatic.put("H", new Integer(1));
1314 aromatic.put("K", new Integer(0));
1315 aromatic.put("R", new Integer(0));
1316 aromatic.put("E", new Integer(0));
1317 aromatic.put("Q", new Integer(0));
1318 aromatic.put("D", new Integer(0));
1319 aromatic.put("N", new Integer(0));
1320 aromatic.put("S", new Integer(0));
1321 aromatic.put("T", new Integer(0));
1322 aromatic.put("P", new Integer(0));
1323 aromatic.put("-", new Integer(1));
1324 aromatic.put("*", new Integer(1));
1329 aliphatic.put("I", new Integer(1));
1330 aliphatic.put("L", new Integer(1));
1331 aliphatic.put("V", new Integer(1));
1332 aliphatic.put("C", new Integer(0));
1333 aliphatic.put("A", new Integer(0));
1334 aliphatic.put("G", new Integer(0));
1335 aliphatic.put("M", new Integer(0));
1336 aliphatic.put("F", new Integer(0));
1337 aliphatic.put("Y", new Integer(0));
1338 aliphatic.put("W", new Integer(0));
1339 aliphatic.put("H", new Integer(0));
1340 aliphatic.put("K", new Integer(0));
1341 aliphatic.put("R", new Integer(0));
1342 aliphatic.put("E", new Integer(0));
1343 aliphatic.put("Q", new Integer(0));
1344 aliphatic.put("D", new Integer(0));
1345 aliphatic.put("N", new Integer(0));
1346 aliphatic.put("S", new Integer(0));
1347 aliphatic.put("T", new Integer(0));
1348 aliphatic.put("P", new Integer(0));
1349 aliphatic.put("-", new Integer(1));
1350 aliphatic.put("*", new Integer(1));
1355 tiny.put("I", new Integer(0));
1356 tiny.put("L", new Integer(0));
1357 tiny.put("V", new Integer(0));
1358 tiny.put("C", new Integer(0));
1359 tiny.put("A", new Integer(1));
1360 tiny.put("G", new Integer(1));
1361 tiny.put("M", new Integer(0));
1362 tiny.put("F", new Integer(0));
1363 tiny.put("Y", new Integer(0));
1364 tiny.put("W", new Integer(0));
1365 tiny.put("H", new Integer(0));
1366 tiny.put("K", new Integer(0));
1367 tiny.put("R", new Integer(0));
1368 tiny.put("E", new Integer(0));
1369 tiny.put("Q", new Integer(0));
1370 tiny.put("D", new Integer(0));
1371 tiny.put("N", new Integer(0));
1372 tiny.put("S", new Integer(1));
1373 tiny.put("T", new Integer(0));
1374 tiny.put("P", new Integer(0));
1375 tiny.put("-", new Integer(1));
1376 tiny.put("*", new Integer(1));
1381 proline.put("I", new Integer(0));
1382 proline.put("L", new Integer(0));
1383 proline.put("V", new Integer(0));
1384 proline.put("C", new Integer(0));
1385 proline.put("A", new Integer(0));
1386 proline.put("G", new Integer(0));
1387 proline.put("M", new Integer(0));
1388 proline.put("F", new Integer(0));
1389 proline.put("Y", new Integer(0));
1390 proline.put("W", new Integer(0));
1391 proline.put("H", new Integer(0));
1392 proline.put("K", new Integer(0));
1393 proline.put("R", new Integer(0));
1394 proline.put("E", new Integer(0));
1395 proline.put("Q", new Integer(0));
1396 proline.put("D", new Integer(0));
1397 proline.put("N", new Integer(0));
1398 proline.put("S", new Integer(0));
1399 proline.put("T", new Integer(0));
1400 proline.put("P", new Integer(1));
1401 proline.put("-", new Integer(1));
1402 proline.put("*", new Integer(1));
1407 propHash.put("hydrophobic", hydrophobic);
1408 propHash.put("small", small);
1409 propHash.put("positive", positive);
1410 propHash.put("negative", negative);
1411 propHash.put("charged", charged);
1412 propHash.put("aromatic", aromatic);
1413 propHash.put("aliphatic", aliphatic);
1414 propHash.put("tiny", tiny);
1415 propHash.put("proline", proline);
1416 propHash.put("polar", polar);
1419 private ResidueProperties()
1423 public static double getHydmax()
1428 public static double getHydmin()
1433 public static double[] getHyd()
1438 public static Hashtable getAA3Hash()
1443 public static int[][] getDNA()
1445 return ResidueProperties.DNA;
1448 public static int[][] getBLOSUM62()
1450 return ResidueProperties.BLOSUM62;
1453 public static int getPAM250(String A1, String A2)
1455 return getPAM250(A1.charAt(0), A2.charAt(0));
1458 public static int getBLOSUM62(char c1, char c2)
1464 int a = aaIndex[c1];
1465 int b = aaIndex[c2];
1467 pog = ResidueProperties.BLOSUM62[a][b];
1468 } catch (Exception e)
1470 // System.out.println("Unknown residue in " + A1 + " " + A2);
1476 public static Vector getCodons(String res)
1478 if (codonHash.containsKey(res))
1480 return (Vector) codonHash.get(res);
1486 public static String codonTranslate(String lccodon)
1490 return _codonTranslate(lccodon);
1492 String cdn = codonHash2.get(lccodon.toUpperCase());
1493 if (cdn!=null && cdn.equals("*"))
1499 public static String _codonTranslate(String lccodon)
1501 String codon = lccodon.toUpperCase();
1502 // all base ambiguity codes yield an 'X' amino acid residue
1503 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1507 Enumeration e = codonHash.keys();
1509 while (e.hasMoreElements())
1511 String key = (String) e.nextElement();
1512 Vector tmp = (Vector) codonHash.get(key);
1514 if (tmp.contains(codon))
1523 public static int[][] getDefaultPeptideMatrix()
1525 return ResidueProperties.getBLOSUM62();
1528 public static int[][] getDefaultDnaMatrix()
1530 return ResidueProperties.getDNA();
1534 * get a ScoreMatrix based on its string name
1537 * @return matrix in scoreMatrices with key pwtype or null
1539 public static ScoreMatrix getScoreMatrix(String pwtype)
1541 Object val = scoreMatrices.get(pwtype);
1544 return (ScoreMatrix) val;
1549 public static int getPAM250(char c, char d)
1554 int pog = ResidueProperties.PAM250[a][b];
1559 public static Hashtable toDssp3State;
1562 toDssp3State = new Hashtable();
1563 toDssp3State.put("H", "H");
1564 toDssp3State.put("E", "E");
1565 toDssp3State.put("C", " ");
1566 toDssp3State.put(" ", " ");
1567 toDssp3State.put("T", " ");
1568 toDssp3State.put("B", "E");
1569 toDssp3State.put("G", "H");
1570 toDssp3State.put("I", "H");
1571 toDssp3State.put("X", " ");
1575 * translate from other dssp secondary structure alphabets to 3-state
1578 * @return ssstring as a three-state secondary structure assignment.
1580 public static String getDssp3state(String ssstring)
1582 if (ssstring == null)
1586 StringBuffer ss = new StringBuffer();
1587 for (int i = 0; i < ssstring.length(); i++)
1589 String ssc = ssstring.substring(i, i + 1);
1590 if (toDssp3State.containsKey(ssc))
1592 ss.append((String) toDssp3State.get(ssc));
1599 return ss.toString();
1603 * Used by getRNASecStrucState
1606 public static Hashtable toRNAssState;
1609 toRNAssState = new Hashtable<String,String>();
1610 toRNAssState.put(")", "(");
1611 toRNAssState.put("(", "(");
1612 toRNAssState.put("]", "[");
1613 toRNAssState.put("[", "[");
1614 toRNAssState.put("{", "{");
1615 toRNAssState.put("}", "{");
1616 toRNAssState.put(">", ">");
1617 toRNAssState.put("<", ">");
1618 toRNAssState.put("A", "A");
1619 toRNAssState.put("a", "A");
1620 toRNAssState.put("B", "B");
1621 toRNAssState.put("b", "B");
1622 toRNAssState.put("C", "C");
1623 toRNAssState.put("c", "C");
1624 toRNAssState.put("D", "D");
1625 toRNAssState.put("d", "D");
1626 toRNAssState.put("E", "E");
1627 toRNAssState.put("e", "E");
1628 toRNAssState.put("F", "F");
1629 toRNAssState.put("f", "F");
1630 toRNAssState.put("G", "G");
1631 toRNAssState.put("g", "G");
1632 toRNAssState.put("H", "H");
1633 toRNAssState.put("h", "H");
1634 toRNAssState.put("I", "I");
1635 toRNAssState.put("i", "I");
1636 toRNAssState.put("J", "J");
1637 toRNAssState.put("j", "J");
1638 toRNAssState.put("K", "K");
1639 toRNAssState.put("k", "K");
1640 toRNAssState.put("L", "L");
1641 toRNAssState.put("l", "L");
1642 toRNAssState.put("M", "M");
1643 toRNAssState.put("m", "M");
1644 toRNAssState.put("N", "N");
1645 toRNAssState.put("n", "N");
1646 toRNAssState.put("O", "O");
1647 toRNAssState.put("o", "O");
1648 toRNAssState.put("P", "P");
1649 toRNAssState.put("p", "P");
1650 toRNAssState.put("Q", "Q");
1651 toRNAssState.put("q", "Q");
1652 toRNAssState.put("R", "R");
1653 toRNAssState.put("r", "R");
1654 toRNAssState.put("S", "S");
1655 toRNAssState.put("s", "S");
1656 toRNAssState.put("T", "T");
1657 toRNAssState.put("t", "T");
1658 toRNAssState.put("U", "U");
1659 toRNAssState.put("u", "U");
1660 toRNAssState.put("V", "V");
1661 toRNAssState.put("v", "V");
1662 toRNAssState.put("W", "W");
1663 toRNAssState.put("w", "W");
1664 toRNAssState.put("X", "X");
1665 toRNAssState.put("x", "X");
1666 toRNAssState.put("Y", "Y");
1667 toRNAssState.put("y", "Y");
1668 toRNAssState.put("Z", "Z");
1669 toRNAssState.put("z", "Z");
1674 * translate to RNA secondary structure representation
1677 * @return ssstring as a RNA-state secondary structure assignment.
1679 public static String getRNASecStrucState(String ssstring)
1681 if (ssstring == null)
1685 StringBuffer ss = new StringBuffer();
1686 for (int i = 0; i < ssstring.length(); i++)
1688 String ssc = ssstring.substring(i, i + 1);
1689 if (toRNAssState.containsKey(ssc))
1691 ss.append((String) toRNAssState.get(ssc));
1698 return ss.toString();
1701 // main method generates perl representation of residue property hash
1703 public static void main(String[] args)
1705 Hashtable aa = new Hashtable();
1706 System.out.println("my %aa = {");
1707 // invert property hashes
1708 Enumeration prop = propHash.keys();
1709 while (prop.hasMoreElements())
1711 String pname = (String) prop.nextElement();
1712 Hashtable phash = (Hashtable) propHash.get(pname);
1713 Enumeration res = phash.keys();
1714 while (res.hasMoreElements())
1716 String rname = (String) res.nextElement();
1717 Vector aprops = (Vector) aa.get(rname);
1720 aprops = new Vector();
1721 aa.put(rname, aprops);
1723 Integer hasprop = (Integer) phash.get(rname);
1724 if (hasprop.intValue() == 1)
1726 aprops.addElement(pname);
1730 Enumeration res = aa.keys();
1731 while (res.hasMoreElements())
1733 String rname = (String) res.nextElement();
1735 System.out.print("'" + rname + "' => [");
1736 Enumeration props = ((Vector) aa.get(rname)).elements();
1737 while (props.hasMoreElements())
1739 System.out.print("'" + (String) props.nextElement() + "'");
1740 if (props.hasMoreElements())
1742 System.out.println(", ");
1745 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1747 System.out.println("};");