2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, 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;
24 public class ResidueProperties
26 public static Hashtable scoreMatrices = new Hashtable();
28 // Stores residue codes/names and colours and other things
29 public static final int[] aaIndex; // aaHash version 2.1.1 and below
31 public static final int[] nucleotideIndex;
33 public static final Hashtable aa3Hash = new Hashtable();
35 public static final Hashtable aa2Triplet = new Hashtable();
37 public static final Hashtable nucleotideName = new Hashtable();
41 aaIndex = new int[255];
42 for (int i = 0; i < 255; i++)
94 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
95 // extend subt. matrices
99 * maximum (gap) index for matrices involving protein alphabet
101 public final static int maxProteinIndex=23;
103 * maximum (gap) index for matrices involving nucleotide alphabet
105 public final static int maxNucleotideIndex=10;
109 nucleotideIndex = new int[255];
110 for (int i = 0; i < 255; i++)
112 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
115 nucleotideIndex['A'] = 0;
116 nucleotideIndex['a'] = 0;
117 nucleotideIndex['C'] = 1;
118 nucleotideIndex['c'] = 1;
119 nucleotideIndex['G'] = 2;
120 nucleotideIndex['g'] = 2;
121 nucleotideIndex['T'] = 3;
122 nucleotideIndex['t'] = 3;
123 nucleotideIndex['U'] = 4;
124 nucleotideIndex['u'] = 4;
125 nucleotideIndex['I'] = 5;
126 nucleotideIndex['i'] = 5;
127 nucleotideIndex['X'] = 6;
128 nucleotideIndex['x'] = 6;
129 nucleotideIndex['R'] = 7;
130 nucleotideIndex['r'] = 7;
131 nucleotideIndex['Y'] = 8;
132 nucleotideIndex['y'] = 8;
133 nucleotideIndex['N'] = 9;
134 nucleotideIndex['n'] = 9;
136 nucleotideName.put("A", "Adenine");
137 nucleotideName.put("a", "Adenine");
138 nucleotideName.put("G", "Guanine");
139 nucleotideName.put("g", "Guanine");
140 nucleotideName.put("C", "Cytosine");
141 nucleotideName.put("c", "Cytosine");
142 nucleotideName.put("T", "Thymine");
143 nucleotideName.put("t", "Thymine");
144 nucleotideName.put("U", "Uracil");
145 nucleotideName.put("u", "Uracil");
146 nucleotideName.put("I", "Inosine");
147 nucleotideName.put("i", "Inosine");
148 nucleotideName.put("X", "Xanthine");
149 nucleotideName.put("x", "Xanthine");
150 nucleotideName.put("R", "Unknown Purine");
151 nucleotideName.put("r", "Unknown Purine");
152 nucleotideName.put("Y", "Unknown Pyrimidine");
153 nucleotideName.put("y", "Unknown Pyrimidine");
154 nucleotideName.put("N", "Unknown");
155 nucleotideName.put("n", "Unknown");
160 aa3Hash.put("ALA", new Integer(0));
161 aa3Hash.put("ARG", new Integer(1));
162 aa3Hash.put("ASN", new Integer(2));
163 aa3Hash.put("ASP", new Integer(3)); // D
164 aa3Hash.put("CYS", new Integer(4));
165 aa3Hash.put("GLN", new Integer(5)); // Q
166 aa3Hash.put("GLU", new Integer(6)); // E
167 aa3Hash.put("GLY", new Integer(7));
168 aa3Hash.put("HIS", new Integer(8));
169 aa3Hash.put("ILE", new Integer(9));
170 aa3Hash.put("LEU", new Integer(10));
171 aa3Hash.put("LYS", new Integer(11));
172 aa3Hash.put("MET", new Integer(12));
173 aa3Hash.put("PHE", new Integer(13));
174 aa3Hash.put("PRO", new Integer(14));
175 aa3Hash.put("SER", new Integer(15));
176 aa3Hash.put("THR", new Integer(16));
177 aa3Hash.put("TRP", new Integer(17));
178 aa3Hash.put("TYR", new Integer(18));
179 aa3Hash.put("VAL", new Integer(19));
180 // IUB Nomenclature for ambiguous peptides
181 aa3Hash.put("ASX", new Integer(20)); // "B";
182 aa3Hash.put("GLX", new Integer(21)); // X
183 aa3Hash.put("XAA", new Integer(22)); // X unknown
184 aa3Hash.put("-", new Integer(23));
185 aa3Hash.put("*", new Integer(23));
186 aa3Hash.put(".", new Integer(23));
187 aa3Hash.put(" ", new Integer(23));
188 aa3Hash.put("Gap", new Integer(23));
193 aa2Triplet.put("A", "ALA");
194 aa2Triplet.put("a", "ALA");
195 aa2Triplet.put("R", "ARG");
196 aa2Triplet.put("r", "ARG");
197 aa2Triplet.put("N", "ASN");
198 aa2Triplet.put("n", "ASN");
199 aa2Triplet.put("D", "ASP");
200 aa2Triplet.put("d", "ASP");
201 aa2Triplet.put("C", "CYS");
202 aa2Triplet.put("c", "CYS");
203 aa2Triplet.put("Q", "GLN");
204 aa2Triplet.put("q", "GLN");
205 aa2Triplet.put("E", "GLU");
206 aa2Triplet.put("e", "GLU");
207 aa2Triplet.put("G", "GLY");
208 aa2Triplet.put("g", "GLY");
209 aa2Triplet.put("H", "HIS");
210 aa2Triplet.put("h", "HIS");
211 aa2Triplet.put("I", "ILE");
212 aa2Triplet.put("i", "ILE");
213 aa2Triplet.put("L", "LEU");
214 aa2Triplet.put("l", "LEU");
215 aa2Triplet.put("K", "LYS");
216 aa2Triplet.put("k", "LYS");
217 aa2Triplet.put("M", "MET");
218 aa2Triplet.put("m", "MET");
219 aa2Triplet.put("F", "PHE");
220 aa2Triplet.put("f", "PHE");
221 aa2Triplet.put("P", "PRO");
222 aa2Triplet.put("p", "PRO");
223 aa2Triplet.put("S", "SER");
224 aa2Triplet.put("s", "SER");
225 aa2Triplet.put("T", "THR");
226 aa2Triplet.put("t", "THR");
227 aa2Triplet.put("W", "TRP");
228 aa2Triplet.put("w", "TRP");
229 aa2Triplet.put("Y", "TYR");
230 aa2Triplet.put("y", "TYR");
231 aa2Triplet.put("V", "VAL");
232 aa2Triplet.put("v", "VAL");
235 public static final String[] aa =
236 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
237 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
239 public static final Color midBlue = new Color(100, 100, 255);
241 public static final Vector scaleColours = new Vector();
245 scaleColours.addElement(new Color(114, 0, 147));
246 scaleColours.addElement(new Color(156, 0, 98));
247 scaleColours.addElement(new Color(190, 0, 0));
248 scaleColours.addElement(Color.red);
249 scaleColours.addElement(new Color(255, 125, 0));
250 scaleColours.addElement(Color.orange);
251 scaleColours.addElement(new Color(255, 194, 85));
252 scaleColours.addElement(Color.yellow);
253 scaleColours.addElement(new Color(255, 255, 181));
254 scaleColours.addElement(Color.white);
257 public static final Color[] taylor =
258 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
259 new Color(0, 0, 255), // R Blueish-bluey-blue
260 new Color(204, 0, 255), // N Blueish-reddy-blue
261 new Color(255, 0, 0), // D Reddish-reddy-red
262 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
263 new Color(255, 0, 204), // Q Reddish-bluey-red
264 new Color(255, 0, 102), // E Blueish-reddy-red
265 new Color(255, 153, 0), // G Yellowy-reddy-yellow
266 new Color(0, 102, 255), // H Greenish-bluey-blue
267 new Color(102, 255, 0), // I Greenish-yellowy-green
268 new Color(51, 255, 0), // L Yellowish-greeny-green
269 new Color(102, 0, 255), // K Reddish-bluey-blue
270 new Color(0, 255, 0), // M Greenish-greeny-green
271 new Color(0, 255, 102), // F Blueish-greeny-green
272 new Color(255, 204, 0), // P Reddish-yellowy-yellow
273 new Color(255, 51, 0), // S Yellowish-reddy-red
274 new Color(255, 102, 0), // T Reddish-yellowy-red
275 new Color(0, 204, 255), // W Blueish-greeny-green
276 new Color(0, 255, 204), // Y Greenish-bluey-green
277 new Color(153, 255, 0), // V Yellowish-greeny-yellow
286 public static final Color[] nucleotide =
287 { new Color(100, 247, 63), // A
288 new Color(255, 179, 64), // C
289 new Color(235, 65, 60), // G
290 new Color(60, 136, 238), // T
291 new Color(60, 136, 238), // U
301 public static final Color[] zappo =
310 midBlue,// Color.red, // H
331 // Dunno where I got these numbers from
332 public static final double[] hyd2 =
358 public static final double[] helix =
359 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
360 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
362 public static final double helixmin = 0.57;
364 public static final double helixmax = 1.51;
366 public static final double[] strand =
367 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
368 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
370 public static final double strandmin = 0.37;
372 public static final double strandmax = 1.7;
374 public static final double[] turn =
375 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
376 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
379 public static final double turnmin = 0.47;
381 public static final double turnmax = 1.56;
383 public static final double[] buried =
384 { 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,
385 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
387 public static final double buriedmin = 0.05;
389 public static final double buriedmax = 4.6;
391 // This is hydropathy index
392 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
393 // 1157, 105-132, 1982
394 public static final double[] hyd =
395 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
396 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
398 public static final double hydmax = 4.5;
400 public static final double hydmin = -3.9;
402 // public static final double hydmax = 1.38;
403 // public static final double hydmin = -2.53;
404 private static final int[][] BLOSUM62 =
406 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
407 -2, 0, -2, -1, 0, -4 },
408 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
409 -2, -3, -1, 0, -1, -4 },
410 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
412 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
413 -3, -3, 4, 1, -1, -4 },
414 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
415 -2, -2, -1, -3, -3, -2, -4 },
416 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
418 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
420 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
421 -3, -3, -1, -2, -1, -4 },
422 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
423 2, -3, 0, 0, -1, -4 },
424 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
425 -1, 3, -3, -3, -1, -4 },
426 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
427 -1, 1, -4, -3, -1, -4 },
428 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
429 -2, -2, 0, 1, -1, -4 },
430 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
431 -1, 1, -3, -1, -1, -4 },
432 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
433 3, -1, -3, -3, -1, -4 },
434 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
435 -4, -3, -2, -2, -1, -2, -4 },
436 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
438 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
439 -2, 0, -1, -1, 0, -4 },
440 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
441 11, 2, -3, -4, -3, -2, -4 },
442 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
443 2, 7, -1, -3, -2, -1, -4 },
444 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
445 -1, 4, -3, -2, -1, -4 },
446 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
447 -3, -3, 4, 1, -1, -4 },
448 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
450 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
451 -2, -1, -1, -1, -1, -1, -4 },
452 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
453 -4, -4, -4, -4, -4, -4, 1 }, };
455 static final int[][] PAM250 =
457 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
459 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
461 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
463 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
465 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
466 -8, 0, -2, -4, -5, -3, -8 },
467 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
469 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
471 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
473 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
475 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
476 -1, 4, -2, -2, -1, -8 },
477 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
478 -1, 2, -3, -3, -1, -8 },
479 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
481 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
482 -2, 2, -2, -2, -1, -8 },
483 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
484 7, -1, -4, -5, -2, -8 },
485 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
487 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
489 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
491 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
492 17, 0, -6, -5, -6, -4, -8 },
493 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
494 10, -2, -3, -4, -2, -8 },
495 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
496 -2, 4, -2, -2, -1, -8 },
497 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
499 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
501 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
502 -2, -1, -1, -1, -1, -8 },
503 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
504 -8, -8, -8, -8, -8, -8, 1 }, };
506 public static final Hashtable ssHash = new Hashtable(); // stores the number
511 ssHash.put("H", Color.magenta);
512 ssHash.put("E", Color.yellow);
513 ssHash.put("-", Color.white);
514 ssHash.put(".", Color.white);
515 ssHash.put("S", Color.cyan);
516 ssHash.put("T", Color.blue);
517 ssHash.put("G", Color.pink);
518 ssHash.put("I", Color.pink);
519 ssHash.put("B", Color.yellow);
523 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
524 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
527 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
528 // Will equate sequences if working with mixed nucleotide sets.
529 // treats T and U identically. R and Y weak equivalence with AG and CTU.
530 // N matches any other base weakly
532 static final int[][] DNA =
534 { 10, -8, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
535 { -8, 10, -8, -8, 10, 1, 1, -8, 1, 1, 1 }, // T
536 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
537 { -8, -8, -8, 10, -8, 1, 1, 1, -8, 1, 1 }, // G
538 { -8, 10, -8, -8, 10, 1, 1, -8, 1, 1, 1 }, // U
539 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
540 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
541 { -8, -8, 1, 1, -8, 0, 0, 10, 0, 1, 1 }, // R
542 { 1, 1, -8, -8, 1, 0, 0, 0, 10, 1, 1 }, // Y
543 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
544 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
547 * register matrices in list
551 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
552 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
553 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
557 public static final Color[] pidColours =
558 { midBlue, new Color(153, 153, 255),
560 new Color(204, 204, 255), };
562 public static final float[] pidThresholds =
565 public static Hashtable codonHash = new Hashtable();
567 public static Vector Lys = new Vector();
569 public static Vector Asn = new Vector();
571 public static Vector Gln = new Vector();
573 public static Vector His = new Vector();
575 public static Vector Glu = new Vector();
577 public static Vector Asp = new Vector();
579 public static Vector Tyr = new Vector();
581 public static Vector Thr = new Vector();
583 public static Vector Pro = new Vector();
585 public static Vector Ala = new Vector();
587 public static Vector Ser = new Vector();
589 public static Vector Arg = new Vector();
591 public static Vector Gly = new Vector();
593 public static Vector Trp = new Vector();
595 public static Vector Cys = new Vector();
597 public static Vector Ile = new Vector();
599 public static Vector Met = new Vector();
601 public static Vector Leu = new Vector();
603 public static Vector Val = new Vector();
605 public static Vector Phe = new Vector();
607 public static Vector STOP = new Vector();
611 codonHash.put("K", Lys);
612 codonHash.put("N", Asn);
613 codonHash.put("Q", Gln);
614 codonHash.put("H", His);
615 codonHash.put("E", Glu);
616 codonHash.put("D", Asp);
617 codonHash.put("Y", Tyr);
618 codonHash.put("T", Thr);
619 codonHash.put("P", Pro);
620 codonHash.put("A", Ala);
621 codonHash.put("S", Ser);
622 codonHash.put("R", Arg);
623 codonHash.put("G", Gly);
624 codonHash.put("W", Trp);
625 codonHash.put("C", Cys);
626 codonHash.put("I", Ile);
627 codonHash.put("M", Met);
628 codonHash.put("L", Leu);
629 codonHash.put("V", Val);
630 codonHash.put("F", Phe);
631 codonHash.put("STOP", STOP);
634 public static Hashtable codonHash2 = new Hashtable();
638 codonHash2.put("AAA", "K");
639 codonHash2.put("AAG", "K");
640 codonHash2.put("AAC", "N");
641 codonHash2.put("AAT", "N");
643 codonHash2.put("CAA", "E");
644 codonHash2.put("CAG", "E");
645 codonHash2.put("CAC", "H");
646 codonHash2.put("CAT", "H");
648 codonHash2.put("GAA", "Q");
649 codonHash2.put("GAG", "Q");
650 codonHash2.put("GAC", "D");
651 codonHash2.put("GAT", "D");
653 codonHash2.put("TAC", "Y");
654 codonHash2.put("TAT", "Y");
656 codonHash2.put("ACA", "T");
657 codonHash2.put("AAG", "T");
658 codonHash2.put("ACC", "T");
659 codonHash2.put("ACT", "T");
661 codonHash2.put("CCA", "P");
662 codonHash2.put("CCG", "P");
663 codonHash2.put("CCC", "P");
664 codonHash2.put("CCT", "P");
666 codonHash2.put("GCA", "A");
667 codonHash2.put("GCG", "A");
668 codonHash2.put("GCC", "A");
669 codonHash2.put("GCT", "A");
671 codonHash2.put("TCA", "S");
672 codonHash2.put("TCG", "S");
673 codonHash2.put("TCC", "S");
674 codonHash2.put("TCT", "S");
675 codonHash2.put("AGC", "S");
676 codonHash2.put("AGT", "S");
678 codonHash2.put("AGA", "R");
679 codonHash2.put("AGG", "R");
680 codonHash2.put("CGA", "R");
681 codonHash2.put("CGG", "R");
682 codonHash2.put("CGC", "R");
683 codonHash2.put("CGT", "R");
685 codonHash2.put("GGA", "G");
686 codonHash2.put("GGG", "G");
687 codonHash2.put("GGC", "G");
688 codonHash2.put("GGT", "G");
690 codonHash2.put("TGA", "*");
691 codonHash2.put("TAA", "*");
692 codonHash2.put("TAG", "*");
694 codonHash2.put("TGG", "W");
696 codonHash2.put("TGC", "C");
697 codonHash2.put("TGT", "C");
699 codonHash2.put("ATA", "I");
700 codonHash2.put("ATC", "I");
701 codonHash2.put("ATT", "I");
703 codonHash2.put("ATG", "M");
705 codonHash2.put("CTA", "L");
706 codonHash2.put("CTG", "L");
707 codonHash2.put("CTC", "L");
708 codonHash2.put("CTT", "L");
709 codonHash2.put("TTA", "L");
710 codonHash2.put("TTG", "L");
712 codonHash2.put("GTA", "V");
713 codonHash2.put("GTG", "V");
714 codonHash2.put("GTC", "V");
715 codonHash2.put("GTT", "V");
717 codonHash2.put("TTC", "F");
718 codonHash2.put("TTT", "F");
723 Lys.addElement("AAA");
724 Lys.addElement("AAG");
725 Asn.addElement("AAC");
726 Asn.addElement("AAT");
728 Gln.addElement("CAA");
729 Gln.addElement("CAG");
730 His.addElement("CAC");
731 His.addElement("CAT");
733 Glu.addElement("GAA");
734 Glu.addElement("GAG");
735 Asp.addElement("GAC");
736 Asp.addElement("GAT");
738 Tyr.addElement("TAC");
739 Tyr.addElement("TAT");
741 Thr.addElement("ACA");
742 Thr.addElement("ACG");
743 Thr.addElement("ACC");
744 Thr.addElement("ACT");
746 Pro.addElement("CCA");
747 Pro.addElement("CCG");
748 Pro.addElement("CCC");
749 Pro.addElement("CCT");
751 Ala.addElement("GCA");
752 Ala.addElement("GCG");
753 Ala.addElement("GCC");
754 Ala.addElement("GCT");
756 Ser.addElement("TCA");
757 Ser.addElement("TCG");
758 Ser.addElement("TCC");
759 Ser.addElement("TCT");
760 Ser.addElement("AGC");
761 Ser.addElement("AGT");
763 Arg.addElement("AGA");
764 Arg.addElement("AGG");
765 Arg.addElement("CGA");
766 Arg.addElement("CGG");
767 Arg.addElement("CGC");
768 Arg.addElement("CGT");
770 Gly.addElement("GGA");
771 Gly.addElement("GGG");
772 Gly.addElement("GGC");
773 Gly.addElement("GGT");
775 STOP.addElement("TGA");
776 STOP.addElement("TAA");
777 STOP.addElement("TAG");
779 Trp.addElement("TGG");
781 Cys.addElement("TGC");
782 Cys.addElement("TGT");
784 Ile.addElement("ATA");
785 Ile.addElement("ATC");
786 Ile.addElement("ATT");
788 Met.addElement("ATG");
790 Leu.addElement("CTA");
791 Leu.addElement("CTG");
792 Leu.addElement("CTC");
793 Leu.addElement("CTT");
794 Leu.addElement("TTA");
795 Leu.addElement("TTG");
797 Val.addElement("GTA");
798 Val.addElement("GTG");
799 Val.addElement("GTC");
800 Val.addElement("GTT");
802 Phe.addElement("TTC");
803 Phe.addElement("TTT");
806 // Stores residue codes/names and colours and other things
807 public static Hashtable propHash = new Hashtable();
809 public static Hashtable hydrophobic = new Hashtable();
811 public static Hashtable polar = new Hashtable();
813 public static Hashtable small = new Hashtable();
815 public static Hashtable positive = new Hashtable();
817 public static Hashtable negative = new Hashtable();
819 public static Hashtable charged = new Hashtable();
821 public static Hashtable aromatic = new Hashtable();
823 public static Hashtable aliphatic = new Hashtable();
825 public static Hashtable tiny = new Hashtable();
827 public static Hashtable proline = new Hashtable();
831 hydrophobic.put("I", new Integer(1));
832 hydrophobic.put("L", new Integer(1));
833 hydrophobic.put("V", new Integer(1));
834 hydrophobic.put("C", new Integer(1));
835 hydrophobic.put("A", new Integer(1));
836 hydrophobic.put("G", new Integer(1));
837 hydrophobic.put("M", new Integer(1));
838 hydrophobic.put("F", new Integer(1));
839 hydrophobic.put("Y", new Integer(1));
840 hydrophobic.put("W", new Integer(1));
841 hydrophobic.put("H", new Integer(1));
842 hydrophobic.put("K", new Integer(1));
843 hydrophobic.put("X", new Integer(1));
844 hydrophobic.put("-", new Integer(1));
845 hydrophobic.put("*", new Integer(1));
846 hydrophobic.put("R", new Integer(0));
847 hydrophobic.put("E", new Integer(0));
848 hydrophobic.put("Q", new Integer(0));
849 hydrophobic.put("D", new Integer(0));
850 hydrophobic.put("N", new Integer(0));
851 hydrophobic.put("S", new Integer(0));
852 hydrophobic.put("T", new Integer(0));
853 hydrophobic.put("P", new Integer(0));
858 polar.put("Y", new Integer(1));
859 polar.put("W", new Integer(1));
860 polar.put("H", new Integer(1));
861 polar.put("K", new Integer(1));
862 polar.put("R", new Integer(1));
863 polar.put("E", new Integer(1));
864 polar.put("Q", new Integer(1));
865 polar.put("D", new Integer(1));
866 polar.put("N", new Integer(1));
867 polar.put("S", new Integer(1));
868 polar.put("T", new Integer(1));
869 polar.put("X", new Integer(1));
870 polar.put("-", new Integer(1));
871 polar.put("*", new Integer(1));
872 polar.put("I", new Integer(0));
873 polar.put("L", new Integer(0));
874 polar.put("V", new Integer(0));
875 polar.put("C", new Integer(0));
876 polar.put("A", new Integer(0));
877 polar.put("G", new Integer(0));
878 polar.put("M", new Integer(0));
879 polar.put("F", new Integer(0));
880 polar.put("P", new Integer(0));
885 small.put("I", new Integer(0));
886 small.put("L", new Integer(0));
887 small.put("V", new Integer(1));
888 small.put("C", new Integer(1));
889 small.put("A", new Integer(1));
890 small.put("G", new Integer(1));
891 small.put("M", new Integer(0));
892 small.put("F", new Integer(0));
893 small.put("Y", new Integer(0));
894 small.put("W", new Integer(0));
895 small.put("H", new Integer(0));
896 small.put("K", new Integer(0));
897 small.put("R", new Integer(0));
898 small.put("E", new Integer(0));
899 small.put("Q", new Integer(0));
900 small.put("D", new Integer(1));
901 small.put("N", new Integer(1));
902 small.put("S", new Integer(1));
903 small.put("T", new Integer(1));
904 small.put("P", new Integer(1));
905 small.put("-", new Integer(1));
906 small.put("*", new Integer(1));
911 positive.put("I", new Integer(0));
912 positive.put("L", new Integer(0));
913 positive.put("V", new Integer(0));
914 positive.put("C", new Integer(0));
915 positive.put("A", new Integer(0));
916 positive.put("G", new Integer(0));
917 positive.put("M", new Integer(0));
918 positive.put("F", new Integer(0));
919 positive.put("Y", new Integer(0));
920 positive.put("W", new Integer(0));
921 positive.put("H", new Integer(1));
922 positive.put("K", new Integer(1));
923 positive.put("R", new Integer(1));
924 positive.put("E", new Integer(0));
925 positive.put("Q", new Integer(0));
926 positive.put("D", new Integer(0));
927 positive.put("N", new Integer(0));
928 positive.put("S", new Integer(0));
929 positive.put("T", new Integer(0));
930 positive.put("P", new Integer(0));
931 positive.put("-", new Integer(1));
932 positive.put("*", new Integer(1));
937 negative.put("I", new Integer(0));
938 negative.put("L", new Integer(0));
939 negative.put("V", new Integer(0));
940 negative.put("C", new Integer(0));
941 negative.put("A", new Integer(0));
942 negative.put("G", new Integer(0));
943 negative.put("M", new Integer(0));
944 negative.put("F", new Integer(0));
945 negative.put("Y", new Integer(0));
946 negative.put("W", new Integer(0));
947 negative.put("H", new Integer(0));
948 negative.put("K", new Integer(0));
949 negative.put("R", new Integer(0));
950 negative.put("E", new Integer(1));
951 negative.put("Q", new Integer(0));
952 negative.put("D", new Integer(1));
953 negative.put("N", new Integer(0));
954 negative.put("S", new Integer(0));
955 negative.put("T", new Integer(0));
956 negative.put("P", new Integer(0));
957 negative.put("-", new Integer(1));
958 negative.put("*", new Integer(1));
963 charged.put("I", new Integer(0));
964 charged.put("L", new Integer(0));
965 charged.put("V", new Integer(0));
966 charged.put("C", new Integer(0));
967 charged.put("A", new Integer(0));
968 charged.put("G", new Integer(0));
969 charged.put("M", new Integer(0));
970 charged.put("F", new Integer(0));
971 charged.put("Y", new Integer(0));
972 charged.put("W", new Integer(0));
973 charged.put("H", new Integer(1));
974 charged.put("K", new Integer(1));
975 charged.put("R", new Integer(1));
976 charged.put("E", new Integer(1));
977 charged.put("Q", new Integer(0));
978 charged.put("D", new Integer(1));
979 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
980 // Alternative would be charged and
981 // negative (in basic form)?
982 charged.put("S", new Integer(0));
983 charged.put("T", new Integer(0));
984 charged.put("P", new Integer(0));
985 charged.put("-", new Integer(1));
986 charged.put("*", new Integer(1));
991 aromatic.put("I", new Integer(0));
992 aromatic.put("L", new Integer(0));
993 aromatic.put("V", new Integer(0));
994 aromatic.put("C", new Integer(0));
995 aromatic.put("A", new Integer(0));
996 aromatic.put("G", new Integer(0));
997 aromatic.put("M", new Integer(0));
998 aromatic.put("F", new Integer(1));
999 aromatic.put("Y", new Integer(1));
1000 aromatic.put("W", new Integer(1));
1001 aromatic.put("H", new Integer(1));
1002 aromatic.put("K", new Integer(0));
1003 aromatic.put("R", new Integer(0));
1004 aromatic.put("E", new Integer(0));
1005 aromatic.put("Q", new Integer(0));
1006 aromatic.put("D", new Integer(0));
1007 aromatic.put("N", new Integer(0));
1008 aromatic.put("S", new Integer(0));
1009 aromatic.put("T", new Integer(0));
1010 aromatic.put("P", new Integer(0));
1011 aromatic.put("-", new Integer(1));
1012 aromatic.put("*", new Integer(1));
1017 aliphatic.put("I", new Integer(1));
1018 aliphatic.put("L", new Integer(1));
1019 aliphatic.put("V", new Integer(1));
1020 aliphatic.put("C", new Integer(0));
1021 aliphatic.put("A", new Integer(0));
1022 aliphatic.put("G", new Integer(0));
1023 aliphatic.put("M", new Integer(0));
1024 aliphatic.put("F", new Integer(0));
1025 aliphatic.put("Y", new Integer(0));
1026 aliphatic.put("W", new Integer(0));
1027 aliphatic.put("H", new Integer(0));
1028 aliphatic.put("K", new Integer(0));
1029 aliphatic.put("R", new Integer(0));
1030 aliphatic.put("E", new Integer(0));
1031 aliphatic.put("Q", new Integer(0));
1032 aliphatic.put("D", new Integer(0));
1033 aliphatic.put("N", new Integer(0));
1034 aliphatic.put("S", new Integer(0));
1035 aliphatic.put("T", new Integer(0));
1036 aliphatic.put("P", new Integer(0));
1037 aliphatic.put("-", new Integer(1));
1038 aliphatic.put("*", new Integer(1));
1043 tiny.put("I", new Integer(0));
1044 tiny.put("L", new Integer(0));
1045 tiny.put("V", new Integer(0));
1046 tiny.put("C", new Integer(0));
1047 tiny.put("A", new Integer(1));
1048 tiny.put("G", new Integer(1));
1049 tiny.put("M", new Integer(0));
1050 tiny.put("F", new Integer(0));
1051 tiny.put("Y", new Integer(0));
1052 tiny.put("W", new Integer(0));
1053 tiny.put("H", new Integer(0));
1054 tiny.put("K", new Integer(0));
1055 tiny.put("R", new Integer(0));
1056 tiny.put("E", new Integer(0));
1057 tiny.put("Q", new Integer(0));
1058 tiny.put("D", new Integer(0));
1059 tiny.put("N", new Integer(0));
1060 tiny.put("S", new Integer(1));
1061 tiny.put("T", new Integer(0));
1062 tiny.put("P", new Integer(0));
1063 tiny.put("-", new Integer(1));
1064 tiny.put("*", new Integer(1));
1069 proline.put("I", new Integer(0));
1070 proline.put("L", new Integer(0));
1071 proline.put("V", new Integer(0));
1072 proline.put("C", new Integer(0));
1073 proline.put("A", new Integer(0));
1074 proline.put("G", new Integer(0));
1075 proline.put("M", new Integer(0));
1076 proline.put("F", new Integer(0));
1077 proline.put("Y", new Integer(0));
1078 proline.put("W", new Integer(0));
1079 proline.put("H", new Integer(0));
1080 proline.put("K", new Integer(0));
1081 proline.put("R", new Integer(0));
1082 proline.put("E", new Integer(0));
1083 proline.put("Q", new Integer(0));
1084 proline.put("D", new Integer(0));
1085 proline.put("N", new Integer(0));
1086 proline.put("S", new Integer(0));
1087 proline.put("T", new Integer(0));
1088 proline.put("P", new Integer(1));
1089 proline.put("-", new Integer(1));
1090 proline.put("*", new Integer(1));
1095 propHash.put("hydrophobic", hydrophobic);
1096 propHash.put("small", small);
1097 propHash.put("positive", positive);
1098 propHash.put("negative", negative);
1099 propHash.put("charged", charged);
1100 propHash.put("aromatic", aromatic);
1101 propHash.put("aliphatic", aliphatic);
1102 propHash.put("tiny", tiny);
1103 propHash.put("proline", proline);
1104 propHash.put("polar", polar);
1107 private ResidueProperties()
1111 public static double getHydmax()
1116 public static double getHydmin()
1121 public static double[] getHyd()
1126 public static Hashtable getAA3Hash()
1131 public static int[][] getDNA()
1133 return ResidueProperties.DNA;
1136 public static int[][] getBLOSUM62()
1138 return ResidueProperties.BLOSUM62;
1141 public static int getPAM250(String A1, String A2)
1143 return getPAM250(A1.charAt(0), A2.charAt(0));
1146 public static int getBLOSUM62(char c1, char c2)
1152 int a = aaIndex[c1];
1153 int b = aaIndex[c2];
1155 pog = ResidueProperties.BLOSUM62[a][b];
1156 } catch (Exception e)
1158 // System.out.println("Unknown residue in " + A1 + " " + A2);
1164 public static Vector getCodons(String res)
1166 if (codonHash.containsKey(res))
1168 return (Vector) codonHash.get(res);
1174 public static String codonTranslate(String lccodon)
1176 String codon = lccodon.toUpperCase();
1177 // all base ambiguity codes yield an 'X' amino acid residue
1178 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1182 Enumeration e = codonHash.keys();
1184 while (e.hasMoreElements())
1186 String key = (String) e.nextElement();
1187 Vector tmp = (Vector) codonHash.get(key);
1189 if (tmp.contains(codon))
1198 public static int[][] getDefaultPeptideMatrix()
1200 return ResidueProperties.getBLOSUM62();
1203 public static int[][] getDefaultDnaMatrix()
1205 return ResidueProperties.getDNA();
1209 * get a ScoreMatrix based on its string name
1212 * @return matrix in scoreMatrices with key pwtype or null
1214 public static ScoreMatrix getScoreMatrix(String pwtype)
1216 Object val = scoreMatrices.get(pwtype);
1219 return (ScoreMatrix) val;
1224 public static int getPAM250(char c, char d)
1229 int pog = ResidueProperties.PAM250[a][b];
1234 public static Hashtable toDssp3State;
1237 toDssp3State = new Hashtable();
1238 toDssp3State.put("H", "H");
1239 toDssp3State.put("E", "E");
1240 toDssp3State.put("C", " ");
1241 toDssp3State.put(" ", " ");
1242 toDssp3State.put("T", " ");
1243 toDssp3State.put("B", "E");
1244 toDssp3State.put("G", "H");
1245 toDssp3State.put("I", "H");
1246 toDssp3State.put("X", " ");
1250 * translate from other dssp secondary structure alphabets to 3-state
1253 * @return ssstring as a three-state secondary structure assignment.
1255 public static String getDssp3state(String ssstring)
1257 if (ssstring == null)
1261 StringBuffer ss = new StringBuffer();
1262 for (int i = 0; i < ssstring.length(); i++)
1264 String ssc = ssstring.substring(i, i + 1);
1265 if (toDssp3State.containsKey(ssc))
1267 ss.append((String) toDssp3State.get(ssc));
1274 return ss.toString();
1277 // main method generates perl representation of residue property hash
1279 public static void main(String[] args)
1281 Hashtable aa = new Hashtable();
1282 System.out.println("my %aa = {");
1283 // invert property hashes
1284 Enumeration prop = propHash.keys();
1285 while (prop.hasMoreElements())
1287 String pname = (String) prop.nextElement();
1288 Hashtable phash = (Hashtable) propHash.get(pname);
1289 Enumeration res = phash.keys();
1290 while (res.hasMoreElements())
1292 String rname = (String) res.nextElement();
1293 Vector aprops = (Vector) aa.get(rname);
1296 aprops = new Vector();
1297 aa.put(rname, aprops);
1299 Integer hasprop = (Integer) phash.get(rname);
1300 if (hasprop.intValue() == 1)
1302 aprops.addElement(pname);
1306 Enumeration res = aa.keys();
1307 while (res.hasMoreElements())
1309 String rname = (String) res.nextElement();
1311 System.out.print("'" + rname + "' => [");
1312 Enumeration props = ((Vector) aa.get(rname)).elements();
1313 while (props.hasMoreElements())
1315 System.out.print("'" + (String) props.nextElement() + "'");
1316 if (props.hasMoreElements())
1318 System.out.println(", ");
1321 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1323 System.out.println("};");