2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
3 * Copyright (C) 2014 The Jalview Authors
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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemes;
21 import jalview.analysis.scoremodels.PIDScoreModel;
22 import jalview.api.analysis.ScoreModelI;
25 import java.util.List;
28 public class ResidueProperties
30 public static Hashtable<String,ScoreModelI> scoreMatrices = new Hashtable();
32 // Stores residue codes/names and colours and other things
33 public static final int[] aaIndex; // aaHash version 2.1.1 and below
35 public static final int[] nucleotideIndex;
37 public static final int[] purinepyrimidineIndex;
39 public static final Hashtable aa3Hash = new Hashtable();
41 public static final Hashtable aa2Triplet = new Hashtable();
43 public static final Hashtable nucleotideName = new Hashtable();
47 aaIndex = new int[255];
48 for (int i = 0; i < 255; i++)
100 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
101 // extend subt. matrices
105 * maximum (gap) index for matrices involving protein alphabet
107 public final static int maxProteinIndex = 23;
110 * maximum (gap) index for matrices involving nucleotide alphabet
112 public final static int maxNucleotideIndex = 10;
116 nucleotideIndex = new int[255];
117 for (int i = 0; i < 255; i++)
119 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
122 nucleotideIndex['A'] = 0;
123 nucleotideIndex['a'] = 0;
124 nucleotideIndex['C'] = 1;
125 nucleotideIndex['c'] = 1;
126 nucleotideIndex['G'] = 2;
127 nucleotideIndex['g'] = 2;
128 nucleotideIndex['T'] = 3;
129 nucleotideIndex['t'] = 3;
130 nucleotideIndex['U'] = 4;
131 nucleotideIndex['u'] = 4;
132 nucleotideIndex['I'] = 5;
133 nucleotideIndex['i'] = 5;
134 nucleotideIndex['X'] = 6;
135 nucleotideIndex['x'] = 6;
136 nucleotideIndex['R'] = 7;
137 nucleotideIndex['r'] = 7;
138 nucleotideIndex['Y'] = 8;
139 nucleotideIndex['y'] = 8;
140 nucleotideIndex['N'] = 9;
141 nucleotideIndex['n'] = 9;
143 nucleotideName.put("A", "Adenine");
144 nucleotideName.put("a", "Adenine");
145 nucleotideName.put("G", "Guanine");
146 nucleotideName.put("g", "Guanine");
147 nucleotideName.put("C", "Cytosine");
148 nucleotideName.put("c", "Cytosine");
149 nucleotideName.put("T", "Thymine");
150 nucleotideName.put("t", "Thymine");
151 nucleotideName.put("U", "Uracil");
152 nucleotideName.put("u", "Uracil");
153 nucleotideName.put("I", "Inosine");
154 nucleotideName.put("i", "Inosine");
155 nucleotideName.put("X", "Xanthine");
156 nucleotideName.put("x", "Xanthine");
157 nucleotideName.put("R", "Unknown Purine");
158 nucleotideName.put("r", "Unknown Purine");
159 nucleotideName.put("Y", "Unknown Pyrimidine");
160 nucleotideName.put("y", "Unknown Pyrimidine");
161 nucleotideName.put("N", "Unknown");
162 nucleotideName.put("n", "Unknown");
163 nucleotideName.put("W", "Weak nucleotide (A or T)");
164 nucleotideName.put("w", "Weak nucleotide (A or T)");
165 nucleotideName.put("S", "Strong nucleotide (G or C)");
166 nucleotideName.put("s", "Strong nucleotide (G or C)");
167 nucleotideName.put("M", "Amino (A or C)");
168 nucleotideName.put("m", "Amino (A or C)");
169 nucleotideName.put("K", "Keto (G or T)");
170 nucleotideName.put("k", "Keto (G or T)");
171 nucleotideName.put("B", "Not A (G or C or T)");
172 nucleotideName.put("b", "Not A (G or C or T)");
173 nucleotideName.put("H", "Not G (A or C or T)");
174 nucleotideName.put("h", "Not G (A or C or T)");
175 nucleotideName.put("D", "Not C (A or G or T)");
176 nucleotideName.put("d", "Not C (A or G or T)");
177 nucleotideName.put("V", "Not T (A or G or C");
178 nucleotideName.put("v", "Not T (A or G or C");
184 purinepyrimidineIndex = new int[255];
185 for (int i = 0; i < 255; i++)
187 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
191 purinepyrimidineIndex['A'] = 0;
192 purinepyrimidineIndex['a'] = 0;
193 purinepyrimidineIndex['C'] = 1;
194 purinepyrimidineIndex['c'] = 1;
195 purinepyrimidineIndex['G'] = 0;
196 purinepyrimidineIndex['g'] = 0;
197 purinepyrimidineIndex['T'] = 1;
198 purinepyrimidineIndex['t'] = 1;
199 purinepyrimidineIndex['U'] = 1;
200 purinepyrimidineIndex['u'] = 1;
201 purinepyrimidineIndex['I'] = 2;
202 purinepyrimidineIndex['i'] = 2;
203 purinepyrimidineIndex['X'] = 2;
204 purinepyrimidineIndex['x'] = 2;
205 purinepyrimidineIndex['R'] = 0;
206 purinepyrimidineIndex['r'] = 0;
207 purinepyrimidineIndex['Y'] = 1;
208 purinepyrimidineIndex['y'] = 1;
209 purinepyrimidineIndex['N'] = 2;
210 purinepyrimidineIndex['n'] = 2;
215 aa3Hash.put("ALA", new Integer(0));
216 aa3Hash.put("ARG", new Integer(1));
217 aa3Hash.put("ASN", new Integer(2));
218 aa3Hash.put("ASP", new Integer(3)); // D
219 aa3Hash.put("CYS", new Integer(4));
220 aa3Hash.put("GLN", new Integer(5)); // Q
221 aa3Hash.put("GLU", new Integer(6)); // E
222 aa3Hash.put("GLY", new Integer(7));
223 aa3Hash.put("HIS", new Integer(8));
224 aa3Hash.put("ILE", new Integer(9));
225 aa3Hash.put("LEU", new Integer(10));
226 aa3Hash.put("LYS", new Integer(11));
227 aa3Hash.put("MET", new Integer(12));
228 aa3Hash.put("PHE", new Integer(13));
229 aa3Hash.put("PRO", new Integer(14));
230 aa3Hash.put("SER", new Integer(15));
231 aa3Hash.put("THR", new Integer(16));
232 aa3Hash.put("TRP", new Integer(17));
233 aa3Hash.put("TYR", new Integer(18));
234 aa3Hash.put("VAL", new Integer(19));
235 // IUB Nomenclature for ambiguous peptides
236 aa3Hash.put("ASX", new Integer(20)); // "B";
237 aa3Hash.put("GLX", new Integer(21)); // X
238 aa3Hash.put("XAA", new Integer(22)); // X unknown
239 aa3Hash.put("-", new Integer(23));
240 aa3Hash.put("*", new Integer(23));
241 aa3Hash.put(".", new Integer(23));
242 aa3Hash.put(" ", new Integer(23));
243 aa3Hash.put("Gap", new Integer(23));
248 aa2Triplet.put("A", "ALA");
249 aa2Triplet.put("a", "ALA");
250 aa2Triplet.put("R", "ARG");
251 aa2Triplet.put("r", "ARG");
252 aa2Triplet.put("N", "ASN");
253 aa2Triplet.put("n", "ASN");
254 aa2Triplet.put("D", "ASP");
255 aa2Triplet.put("d", "ASP");
256 aa2Triplet.put("C", "CYS");
257 aa2Triplet.put("c", "CYS");
258 aa2Triplet.put("Q", "GLN");
259 aa2Triplet.put("q", "GLN");
260 aa2Triplet.put("E", "GLU");
261 aa2Triplet.put("e", "GLU");
262 aa2Triplet.put("G", "GLY");
263 aa2Triplet.put("g", "GLY");
264 aa2Triplet.put("H", "HIS");
265 aa2Triplet.put("h", "HIS");
266 aa2Triplet.put("I", "ILE");
267 aa2Triplet.put("i", "ILE");
268 aa2Triplet.put("L", "LEU");
269 aa2Triplet.put("l", "LEU");
270 aa2Triplet.put("K", "LYS");
271 aa2Triplet.put("k", "LYS");
272 aa2Triplet.put("M", "MET");
273 aa2Triplet.put("m", "MET");
274 aa2Triplet.put("F", "PHE");
275 aa2Triplet.put("f", "PHE");
276 aa2Triplet.put("P", "PRO");
277 aa2Triplet.put("p", "PRO");
278 aa2Triplet.put("S", "SER");
279 aa2Triplet.put("s", "SER");
280 aa2Triplet.put("T", "THR");
281 aa2Triplet.put("t", "THR");
282 aa2Triplet.put("W", "TRP");
283 aa2Triplet.put("w", "TRP");
284 aa2Triplet.put("Y", "TYR");
285 aa2Triplet.put("y", "TYR");
286 aa2Triplet.put("V", "VAL");
287 aa2Triplet.put("v", "VAL");
290 public static final String[] aa =
291 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
292 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
294 public static final Color midBlue = new Color(100, 100, 255);
296 public static final Vector scaleColours = new Vector();
300 scaleColours.addElement(new Color(114, 0, 147));
301 scaleColours.addElement(new Color(156, 0, 98));
302 scaleColours.addElement(new Color(190, 0, 0));
303 scaleColours.addElement(Color.red);
304 scaleColours.addElement(new Color(255, 125, 0));
305 scaleColours.addElement(Color.orange);
306 scaleColours.addElement(new Color(255, 194, 85));
307 scaleColours.addElement(Color.yellow);
308 scaleColours.addElement(new Color(255, 255, 181));
309 scaleColours.addElement(Color.white);
312 public static final Color[] taylor =
313 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
314 new Color(0, 0, 255), // R Blueish-bluey-blue
315 new Color(204, 0, 255), // N Blueish-reddy-blue
316 new Color(255, 0, 0), // D Reddish-reddy-red
317 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
318 new Color(255, 0, 204), // Q Reddish-bluey-red
319 new Color(255, 0, 102), // E Blueish-reddy-red
320 new Color(255, 153, 0), // G Yellowy-reddy-yellow
321 new Color(0, 102, 255), // H Greenish-bluey-blue
322 new Color(102, 255, 0), // I Greenish-yellowy-green
323 new Color(51, 255, 0), // L Yellowish-greeny-green
324 new Color(102, 0, 255), // K Reddish-bluey-blue
325 new Color(0, 255, 0), // M Greenish-greeny-green
326 new Color(0, 255, 102), // F Blueish-greeny-green
327 new Color(255, 204, 0), // P Reddish-yellowy-yellow
328 new Color(255, 51, 0), // S Yellowish-reddy-red
329 new Color(255, 102, 0), // T Reddish-yellowy-red
330 new Color(0, 204, 255), // W Blueish-greeny-green
331 new Color(0, 255, 204), // Y Greenish-bluey-green
332 new Color(153, 255, 0), // V Yellowish-greeny-yellow
341 public static final Color[] nucleotide =
342 { new Color(100, 247, 63), // A
343 new Color(255, 179, 64), // C
344 new Color(235, 65, 60), // G
345 new Color(60, 136, 238), // T
346 new Color(60, 136, 238), // U
347 Color.white, // I (inosine)
348 Color.white, // X (xanthine)
355 // Added for PurinePyrimidineColourScheme
356 public static final Color[] purinepyrimidine =
357 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
358 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
359 Color.white, // all other nucleotides
364 public static final Color[] zappo =
373 midBlue,// Color.red, // H
394 // Dunno where I got these numbers from
395 public static final double[] hyd2 =
421 public static final double[] helix =
422 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
423 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
425 public static final double helixmin = 0.57;
427 public static final double helixmax = 1.51;
429 public static final double[] strand =
430 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
431 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
433 public static final double strandmin = 0.37;
435 public static final double strandmax = 1.7;
437 public static final double[] turn =
438 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
439 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
442 public static final double turnmin = 0.47;
444 public static final double turnmax = 1.56;
446 public static final double[] buried =
447 { 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,
448 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
450 public static final double buriedmin = 0.05;
452 public static final double buriedmax = 4.6;
454 // This is hydropathy index
455 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
456 // 1157, 105-132, 1982
457 public static final double[] hyd =
458 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
459 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
461 public static final double hydmax = 4.5;
463 public static final double hydmin = -3.9;
465 // public static final double hydmax = 1.38;
466 // public static final double hydmin = -2.53;
467 private static final int[][] BLOSUM62 =
469 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
470 -2, 0, -2, -1, 0, -4 },
471 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
472 -2, -3, -1, 0, -1, -4 },
473 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
475 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
476 -3, -3, 4, 1, -1, -4 },
477 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
478 -2, -2, -1, -3, -3, -2, -4 },
479 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
481 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
483 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
484 -3, -3, -1, -2, -1, -4 },
485 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
486 2, -3, 0, 0, -1, -4 },
487 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
488 -1, 3, -3, -3, -1, -4 },
489 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
490 -1, 1, -4, -3, -1, -4 },
491 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
492 -2, -2, 0, 1, -1, -4 },
493 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
494 -1, 1, -3, -1, -1, -4 },
495 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
496 3, -1, -3, -3, -1, -4 },
497 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
498 -4, -3, -2, -2, -1, -2, -4 },
499 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
501 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
502 -2, 0, -1, -1, 0, -4 },
503 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
504 11, 2, -3, -4, -3, -2, -4 },
505 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
506 2, 7, -1, -3, -2, -1, -4 },
507 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
508 -1, 4, -3, -2, -1, -4 },
509 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
510 -3, -3, 4, 1, -1, -4 },
511 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
513 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
514 -2, -1, -1, -1, -1, -1, -4 },
515 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
516 -4, -4, -4, -4, -4, -4, 1 }, };
518 static final int[][] PAM250 =
520 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
522 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
524 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
526 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
528 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
529 -8, 0, -2, -4, -5, -3, -8 },
530 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
532 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
534 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
536 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
538 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
539 -1, 4, -2, -2, -1, -8 },
540 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
541 -1, 2, -3, -3, -1, -8 },
542 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
544 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
545 -2, 2, -2, -2, -1, -8 },
546 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
547 7, -1, -4, -5, -2, -8 },
548 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
550 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
552 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
554 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
555 17, 0, -6, -5, -6, -4, -8 },
556 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
557 10, -2, -3, -4, -2, -8 },
558 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
559 -2, 4, -2, -2, -1, -8 },
560 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
562 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
564 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
565 -2, -1, -1, -1, -1, -8 },
566 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
567 -8, -8, -8, -8, -8, -8, 1 }, };
569 public static final Hashtable ssHash = new Hashtable(); // stores the number
574 ssHash.put("H", Color.magenta);
575 ssHash.put("E", Color.yellow);
576 ssHash.put("-", Color.white);
577 ssHash.put(".", Color.white);
578 ssHash.put("S", Color.cyan);
579 ssHash.put("T", Color.blue);
580 ssHash.put("G", Color.pink);
581 ssHash.put("I", Color.pink);
582 ssHash.put("B", Color.yellow);
586 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
587 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
590 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
591 // Will equate sequences if working with mixed nucleotide sets.
592 // treats T and U identically. R and Y weak equivalence with AG and CTU.
593 // N matches any other base weakly
595 static final int[][] DNA =
597 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
598 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
599 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
600 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
601 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
602 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
603 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
604 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
605 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
606 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
607 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
610 * register matrices in list
614 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
615 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
616 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
620 public static final Color[] pidColours =
621 { midBlue, new Color(153, 153, 255),
623 new Color(204, 204, 255), };
625 public static final float[] pidThresholds =
628 public static Hashtable codonHash = new Hashtable();
630 public static Vector Lys = new Vector();
632 public static Vector Asn = new Vector();
634 public static Vector Gln = new Vector();
636 public static Vector His = new Vector();
638 public static Vector Glu = new Vector();
640 public static Vector Asp = new Vector();
642 public static Vector Tyr = new Vector();
644 public static Vector Thr = new Vector();
646 public static Vector Pro = new Vector();
648 public static Vector Ala = new Vector();
650 public static Vector Ser = new Vector();
652 public static Vector Arg = new Vector();
654 public static Vector Gly = new Vector();
656 public static Vector Trp = new Vector();
658 public static Vector Cys = new Vector();
660 public static Vector Ile = new Vector();
662 public static Vector Met = new Vector();
664 public static Vector Leu = new Vector();
666 public static Vector Val = new Vector();
668 public static Vector Phe = new Vector();
670 public static Vector STOP = new Vector();
674 codonHash.put("K", Lys);
675 codonHash.put("N", Asn);
676 codonHash.put("Q", Gln);
677 codonHash.put("H", His);
678 codonHash.put("E", Glu);
679 codonHash.put("D", Asp);
680 codonHash.put("Y", Tyr);
681 codonHash.put("T", Thr);
682 codonHash.put("P", Pro);
683 codonHash.put("A", Ala);
684 codonHash.put("S", Ser);
685 codonHash.put("R", Arg);
686 codonHash.put("G", Gly);
687 codonHash.put("W", Trp);
688 codonHash.put("C", Cys);
689 codonHash.put("I", Ile);
690 codonHash.put("M", Met);
691 codonHash.put("L", Leu);
692 codonHash.put("V", Val);
693 codonHash.put("F", Phe);
694 codonHash.put("STOP", STOP);
698 * Nucleotide Ambiguity Codes
700 public static final Hashtable<String,String[]> ambiguityCodes=new Hashtable<String,String[]>();
702 * Codon triplets with additional symbols for unambiguous codons that include ambiguity codes
704 public static final Hashtable<String,String> codonHash2 = new Hashtable<String,String>();
707 * all ambiguity codes for a given base
709 public final static Hashtable<String,List<String>> _ambiguityCodes = new Hashtable<String,List<String>>();
715 * 3.2. Purine (adenine or guanine): R
717 * R is the symbol previously recommended [1].
719 ambiguityCodes.put("R", new String[]
723 * 3.3. Pyrimidine (thymine or cytosine): Y
725 * Y is the symbol previously recommended [1].
727 ambiguityCodes.put("Y", new String[]
730 * 3.4. Adenine or thymine: W
732 * Although several diverse symbols have been used for this pair, (and for
733 * the reciprocal pair G+C), only two symbols have a rational basis, L and
734 * W: L derives from DNA density (light; G+C - heavy - would thus be H); W
735 * derives from the strength of the hydrogen bonding interaction between the
736 * base pairs (weak for A+T: G +C - strong - would thus be S). However, the
737 * system recommended for the three-base series (not-A = B, etc., see below,
738 * section 3.8) rules out H as this would be not-G. W is thus recommended.
740 ambiguityCodes.put("W", new String[]
743 * 3.5. Guanine or cytosine: S
745 * The choice of this symbol is discussed above in section 3.4.
747 ambiguityCodes.put("S", new String[]
750 * 3.6. Adenine or cytosine: M
752 * There are few common features between A and C. The presence of an NH2
753 * group in similar positions on both bases (Fig. 1) makes possible a
754 * logically derived symbol. A and N being ruled out, M (from aMino) is
758 * Fig. 1. Origin of the symbols M and K The four bases are drawn so as to
759 * show the relationship between adenine and cytosine on the one hand, which
760 * both have aMino groups at the ring position most distant from the point
761 * of attachment to the sugar, and between guanine and thymine on the other,
762 * which both have Keto groups at the corresponding position. The ring atoms
763 * are numbered as recommended [24-26], although for the present purpose
764 * this has the disadvantage of giving discordant numbers to the
765 * corresponding positions.
767 ambiguityCodes.put("M", new String[]
770 * 3.7. Guanine or thymine: K By analogy with A and C (section 3.6), both G
771 * and T have Keto groups in similar positions (Fig. 1).
773 ambiguityCodes.put("K", new String[]
776 * 3.8. Adenine or thymine or cytosine: H
778 * Not-G is the most simple means of memorising this combination and symbols
779 * logically related to G were examined. F and H would both be suitable, as
780 * the letters before and after G in the alphabet, but A would have no
781 * equivalent to F. The use of H has historical precedence [2].
783 ambiguityCodes.put("H", new String[]
786 * 3.9. Guanine or cytosine or thymine: B
788 * Not-A as above (section 3.8).
790 ambiguityCodes.put("B", new String[]
793 * 3.10. Guanine or adenine or cytosine: V
795 * Not-T by analogy with not-G (section 3.8) would be U but this is ruled
796 * out to eliminate confusion with uracil. V is the next logical choice.
797 * Note that T and U may in some cases be considered to be synonyms.
799 ambiguityCodes.put("V", new String[]
802 * 3.11. Guanine or adenine or thymine: D
804 * Not-C as above (section 3.8).
806 ambiguityCodes.put("D", new String[]
809 * 3.12. Guanine or adenine or thymine or cytosine: N
811 ambiguityCodes.put("R", new String[]
812 { "G", "A", "T", "C" });
813 // Now build codon translation table
814 codonHash2.put("AAA", "K");
815 codonHash2.put("AAG", "K");
816 codonHash2.put("AAC", "N");
817 codonHash2.put("AAT", "N");
819 codonHash2.put("CAA", "Q");
820 codonHash2.put("CAG", "Q");
821 codonHash2.put("CAC", "H");
822 codonHash2.put("CAT", "H");
824 codonHash2.put("GAA", "E");
825 codonHash2.put("GAG", "E");
826 codonHash2.put("GAC", "D");
827 codonHash2.put("GAT", "D");
829 codonHash2.put("TAC", "Y");
830 codonHash2.put("TAT", "Y");
832 codonHash2.put("ACA", "T");
833 codonHash2.put("ACC", "T");
834 codonHash2.put("ACT", "T");
835 codonHash2.put("ACG", "T");
837 codonHash2.put("CCA", "P");
838 codonHash2.put("CCG", "P");
839 codonHash2.put("CCC", "P");
840 codonHash2.put("CCT", "P");
842 codonHash2.put("GCA", "A");
843 codonHash2.put("GCG", "A");
844 codonHash2.put("GCC", "A");
845 codonHash2.put("GCT", "A");
847 codonHash2.put("TCA", "S");
848 codonHash2.put("TCG", "S");
849 codonHash2.put("TCC", "S");
850 codonHash2.put("TCT", "S");
851 codonHash2.put("AGC", "S");
852 codonHash2.put("AGT", "S");
854 codonHash2.put("AGA", "R");
855 codonHash2.put("AGG", "R");
856 codonHash2.put("CGA", "R");
857 codonHash2.put("CGG", "R");
858 codonHash2.put("CGC", "R");
859 codonHash2.put("CGT", "R");
861 codonHash2.put("GGA", "G");
862 codonHash2.put("GGG", "G");
863 codonHash2.put("GGC", "G");
864 codonHash2.put("GGT", "G");
866 codonHash2.put("TGA", "*");
867 codonHash2.put("TAA", "*");
868 codonHash2.put("TAG", "*");
870 codonHash2.put("TGG", "W");
872 codonHash2.put("TGC", "C");
873 codonHash2.put("TGT", "C");
875 codonHash2.put("ATA", "I");
876 codonHash2.put("ATC", "I");
877 codonHash2.put("ATT", "I");
879 codonHash2.put("ATG", "M");
881 codonHash2.put("CTA", "L");
882 codonHash2.put("CTG", "L");
883 codonHash2.put("CTC", "L");
884 codonHash2.put("CTT", "L");
885 codonHash2.put("TTA", "L");
886 codonHash2.put("TTG", "L");
888 codonHash2.put("GTA", "V");
889 codonHash2.put("GTG", "V");
890 codonHash2.put("GTC", "V");
891 codonHash2.put("GTT", "V");
893 codonHash2.put("TTC", "F");
894 codonHash2.put("TTT", "F");
896 buildAmbiguityCodonSet();
900 * programmatic generation of codons including ambiguity codes
902 public static void buildAmbiguityCodonSet()
904 if (_ambiguityCodes.size() > 0)
907 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
910 // Invert the ambiguity code set
911 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
913 for (String r : acode.getValue())
915 List<String> codesfor = _ambiguityCodes.get(r);
916 if (codesfor == null)
918 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
920 if (!codesfor.contains(acode.getKey()))
922 codesfor.add(acode.getKey());
927 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
928 + acode.getKey() + " in residue " + r);
932 // and programmatically add in the ambiguity codes that yield the same amino
934 String[] unambcodons = codonHash2.keySet().toArray(new String[codonHash2.size()]);
935 for (String codon : unambcodons)
937 String residue = codonHash2.get(codon);
938 String acodon[][] = new String[codon.length()][];
939 for (int i = 0, iSize = codon.length(); i < iSize; i++)
941 String _ac = "" + codon.charAt(i);
942 List<String> acodes = _ambiguityCodes.get(_ac);
945 acodon[i] = acodes.toArray(new String[acodes.size()]);
949 acodon[i] = new String[]
953 // enumerate all combinations and test for veracity of translation
954 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
955 for (int i = 0; i < tpos.length; i++)
959 tpos[acodon.length - 1] = 0;
961 while (tpos[0] < acodon[0].length)
963 // make all codons for this combination
964 char allres[][] = new char[tpos.length][];
967 for (ipos = 0; ipos < tpos.length; ipos++)
969 if (acodon[ipos].length==0 || tpos[ipos] < 0)
971 _acodon += codon.charAt(ipos);
972 allres[ipos] = new char[]
973 { codon.charAt(ipos) };
977 _acodon += acodon[ipos][tpos[ipos]];
978 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
979 allres[ipos] = new char[altbase.length];
981 for (String ab : altbase)
983 allres[ipos][j++] = ab.charAt(0);
987 // test all codons for this combination
988 for (ipos = 0; ipos < cpos.length; ipos++)
992 boolean valid = true;
996 for (j = 0; j < cpos.length; j++)
998 _codon += allres[j][cpos[j]];
1000 String tr = codonHash2.get(_codon);
1001 if (valid = (tr!=null && tr.equals(residue)))
1003 // advance to next combination
1004 ipos = acodon.length - 1;
1005 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
1011 } while (valid && cpos[0] < allres[0].length);
1014 // Add this to the set of codons we will translate
1015 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
1017 codonHash2.put(_acodon, residue);
1021 // System.err.println("Rejecting ambiguity codon: " + _acodon
1022 // + " for " + residue);
1025 ipos = acodon.length - 1;
1026 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1038 Lys.addElement("AAA");
1039 Lys.addElement("AAG");
1040 Asn.addElement("AAC");
1041 Asn.addElement("AAT");
1043 Gln.addElement("CAA");
1044 Gln.addElement("CAG");
1045 His.addElement("CAC");
1046 His.addElement("CAT");
1048 Glu.addElement("GAA");
1049 Glu.addElement("GAG");
1050 Asp.addElement("GAC");
1051 Asp.addElement("GAT");
1053 Tyr.addElement("TAC");
1054 Tyr.addElement("TAT");
1056 Thr.addElement("ACA");
1057 Thr.addElement("ACG");
1058 Thr.addElement("ACC");
1059 Thr.addElement("ACT");
1061 Pro.addElement("CCA");
1062 Pro.addElement("CCG");
1063 Pro.addElement("CCC");
1064 Pro.addElement("CCT");
1066 Ala.addElement("GCA");
1067 Ala.addElement("GCG");
1068 Ala.addElement("GCC");
1069 Ala.addElement("GCT");
1071 Ser.addElement("TCA");
1072 Ser.addElement("TCG");
1073 Ser.addElement("TCC");
1074 Ser.addElement("TCT");
1075 Ser.addElement("AGC");
1076 Ser.addElement("AGT");
1078 Arg.addElement("AGA");
1079 Arg.addElement("AGG");
1080 Arg.addElement("CGA");
1081 Arg.addElement("CGG");
1082 Arg.addElement("CGC");
1083 Arg.addElement("CGT");
1085 Gly.addElement("GGA");
1086 Gly.addElement("GGG");
1087 Gly.addElement("GGC");
1088 Gly.addElement("GGT");
1090 STOP.addElement("TGA");
1091 STOP.addElement("TAA");
1092 STOP.addElement("TAG");
1094 Trp.addElement("TGG");
1096 Cys.addElement("TGC");
1097 Cys.addElement("TGT");
1099 Ile.addElement("ATA");
1100 Ile.addElement("ATC");
1101 Ile.addElement("ATT");
1103 Met.addElement("ATG");
1105 Leu.addElement("CTA");
1106 Leu.addElement("CTG");
1107 Leu.addElement("CTC");
1108 Leu.addElement("CTT");
1109 Leu.addElement("TTA");
1110 Leu.addElement("TTG");
1112 Val.addElement("GTA");
1113 Val.addElement("GTG");
1114 Val.addElement("GTC");
1115 Val.addElement("GTT");
1117 Phe.addElement("TTC");
1118 Phe.addElement("TTT");
1121 // Stores residue codes/names and colours and other things
1122 public static Hashtable propHash = new Hashtable();
1124 public static Hashtable hydrophobic = new Hashtable();
1126 public static Hashtable polar = new Hashtable();
1128 public static Hashtable small = new Hashtable();
1130 public static Hashtable positive = new Hashtable();
1132 public static Hashtable negative = new Hashtable();
1134 public static Hashtable charged = new Hashtable();
1136 public static Hashtable aromatic = new Hashtable();
1138 public static Hashtable aliphatic = new Hashtable();
1140 public static Hashtable tiny = new Hashtable();
1142 public static Hashtable proline = new Hashtable();
1146 hydrophobic.put("I", new Integer(1));
1147 hydrophobic.put("L", new Integer(1));
1148 hydrophobic.put("V", new Integer(1));
1149 hydrophobic.put("C", new Integer(1));
1150 hydrophobic.put("A", new Integer(1));
1151 hydrophobic.put("G", new Integer(1));
1152 hydrophobic.put("M", new Integer(1));
1153 hydrophobic.put("F", new Integer(1));
1154 hydrophobic.put("Y", new Integer(1));
1155 hydrophobic.put("W", new Integer(1));
1156 hydrophobic.put("H", new Integer(1));
1157 hydrophobic.put("K", new Integer(1));
1158 hydrophobic.put("X", new Integer(1));
1159 hydrophobic.put("-", new Integer(1));
1160 hydrophobic.put("*", new Integer(1));
1161 hydrophobic.put("R", new Integer(0));
1162 hydrophobic.put("E", new Integer(0));
1163 hydrophobic.put("Q", new Integer(0));
1164 hydrophobic.put("D", new Integer(0));
1165 hydrophobic.put("N", new Integer(0));
1166 hydrophobic.put("S", new Integer(0));
1167 hydrophobic.put("T", new Integer(0));
1168 hydrophobic.put("P", new Integer(0));
1173 polar.put("Y", new Integer(1));
1174 polar.put("W", new Integer(1));
1175 polar.put("H", new Integer(1));
1176 polar.put("K", new Integer(1));
1177 polar.put("R", new Integer(1));
1178 polar.put("E", new Integer(1));
1179 polar.put("Q", new Integer(1));
1180 polar.put("D", new Integer(1));
1181 polar.put("N", new Integer(1));
1182 polar.put("S", new Integer(1));
1183 polar.put("T", new Integer(1));
1184 polar.put("X", new Integer(1));
1185 polar.put("-", new Integer(1));
1186 polar.put("*", new Integer(1));
1187 polar.put("I", new Integer(0));
1188 polar.put("L", new Integer(0));
1189 polar.put("V", new Integer(0));
1190 polar.put("C", new Integer(0));
1191 polar.put("A", new Integer(0));
1192 polar.put("G", new Integer(0));
1193 polar.put("M", new Integer(0));
1194 polar.put("F", new Integer(0));
1195 polar.put("P", new Integer(0));
1200 small.put("I", new Integer(0));
1201 small.put("L", new Integer(0));
1202 small.put("V", new Integer(1));
1203 small.put("C", new Integer(1));
1204 small.put("A", new Integer(1));
1205 small.put("G", new Integer(1));
1206 small.put("M", new Integer(0));
1207 small.put("F", new Integer(0));
1208 small.put("Y", new Integer(0));
1209 small.put("W", new Integer(0));
1210 small.put("H", new Integer(0));
1211 small.put("K", new Integer(0));
1212 small.put("R", new Integer(0));
1213 small.put("E", new Integer(0));
1214 small.put("Q", new Integer(0));
1215 small.put("D", new Integer(1));
1216 small.put("N", new Integer(1));
1217 small.put("S", new Integer(1));
1218 small.put("T", new Integer(1));
1219 small.put("P", new Integer(1));
1220 small.put("-", new Integer(1));
1221 small.put("*", new Integer(1));
1226 positive.put("I", new Integer(0));
1227 positive.put("L", new Integer(0));
1228 positive.put("V", new Integer(0));
1229 positive.put("C", new Integer(0));
1230 positive.put("A", new Integer(0));
1231 positive.put("G", new Integer(0));
1232 positive.put("M", new Integer(0));
1233 positive.put("F", new Integer(0));
1234 positive.put("Y", new Integer(0));
1235 positive.put("W", new Integer(0));
1236 positive.put("H", new Integer(1));
1237 positive.put("K", new Integer(1));
1238 positive.put("R", new Integer(1));
1239 positive.put("E", new Integer(0));
1240 positive.put("Q", new Integer(0));
1241 positive.put("D", new Integer(0));
1242 positive.put("N", new Integer(0));
1243 positive.put("S", new Integer(0));
1244 positive.put("T", new Integer(0));
1245 positive.put("P", new Integer(0));
1246 positive.put("-", new Integer(1));
1247 positive.put("*", new Integer(1));
1252 negative.put("I", new Integer(0));
1253 negative.put("L", new Integer(0));
1254 negative.put("V", new Integer(0));
1255 negative.put("C", new Integer(0));
1256 negative.put("A", new Integer(0));
1257 negative.put("G", new Integer(0));
1258 negative.put("M", new Integer(0));
1259 negative.put("F", new Integer(0));
1260 negative.put("Y", new Integer(0));
1261 negative.put("W", new Integer(0));
1262 negative.put("H", new Integer(0));
1263 negative.put("K", new Integer(0));
1264 negative.put("R", new Integer(0));
1265 negative.put("E", new Integer(1));
1266 negative.put("Q", new Integer(0));
1267 negative.put("D", new Integer(1));
1268 negative.put("N", new Integer(0));
1269 negative.put("S", new Integer(0));
1270 negative.put("T", new Integer(0));
1271 negative.put("P", new Integer(0));
1272 negative.put("-", new Integer(1));
1273 negative.put("*", new Integer(1));
1278 charged.put("I", new Integer(0));
1279 charged.put("L", new Integer(0));
1280 charged.put("V", new Integer(0));
1281 charged.put("C", new Integer(0));
1282 charged.put("A", new Integer(0));
1283 charged.put("G", new Integer(0));
1284 charged.put("M", new Integer(0));
1285 charged.put("F", new Integer(0));
1286 charged.put("Y", new Integer(0));
1287 charged.put("W", new Integer(0));
1288 charged.put("H", new Integer(1));
1289 charged.put("K", new Integer(1));
1290 charged.put("R", new Integer(1));
1291 charged.put("E", new Integer(1));
1292 charged.put("Q", new Integer(0));
1293 charged.put("D", new Integer(1));
1294 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1295 // Alternative would be charged and
1296 // negative (in basic form)?
1297 charged.put("S", new Integer(0));
1298 charged.put("T", new Integer(0));
1299 charged.put("P", new Integer(0));
1300 charged.put("-", new Integer(1));
1301 charged.put("*", new Integer(1));
1306 aromatic.put("I", new Integer(0));
1307 aromatic.put("L", new Integer(0));
1308 aromatic.put("V", new Integer(0));
1309 aromatic.put("C", new Integer(0));
1310 aromatic.put("A", new Integer(0));
1311 aromatic.put("G", new Integer(0));
1312 aromatic.put("M", new Integer(0));
1313 aromatic.put("F", new Integer(1));
1314 aromatic.put("Y", new Integer(1));
1315 aromatic.put("W", new Integer(1));
1316 aromatic.put("H", new Integer(1));
1317 aromatic.put("K", new Integer(0));
1318 aromatic.put("R", new Integer(0));
1319 aromatic.put("E", new Integer(0));
1320 aromatic.put("Q", new Integer(0));
1321 aromatic.put("D", new Integer(0));
1322 aromatic.put("N", new Integer(0));
1323 aromatic.put("S", new Integer(0));
1324 aromatic.put("T", new Integer(0));
1325 aromatic.put("P", new Integer(0));
1326 aromatic.put("-", new Integer(1));
1327 aromatic.put("*", new Integer(1));
1332 aliphatic.put("I", new Integer(1));
1333 aliphatic.put("L", new Integer(1));
1334 aliphatic.put("V", new Integer(1));
1335 aliphatic.put("C", new Integer(0));
1336 aliphatic.put("A", new Integer(0));
1337 aliphatic.put("G", new Integer(0));
1338 aliphatic.put("M", new Integer(0));
1339 aliphatic.put("F", new Integer(0));
1340 aliphatic.put("Y", new Integer(0));
1341 aliphatic.put("W", new Integer(0));
1342 aliphatic.put("H", new Integer(0));
1343 aliphatic.put("K", new Integer(0));
1344 aliphatic.put("R", new Integer(0));
1345 aliphatic.put("E", new Integer(0));
1346 aliphatic.put("Q", new Integer(0));
1347 aliphatic.put("D", new Integer(0));
1348 aliphatic.put("N", new Integer(0));
1349 aliphatic.put("S", new Integer(0));
1350 aliphatic.put("T", new Integer(0));
1351 aliphatic.put("P", new Integer(0));
1352 aliphatic.put("-", new Integer(1));
1353 aliphatic.put("*", new Integer(1));
1358 tiny.put("I", new Integer(0));
1359 tiny.put("L", new Integer(0));
1360 tiny.put("V", new Integer(0));
1361 tiny.put("C", new Integer(0));
1362 tiny.put("A", new Integer(1));
1363 tiny.put("G", new Integer(1));
1364 tiny.put("M", new Integer(0));
1365 tiny.put("F", new Integer(0));
1366 tiny.put("Y", new Integer(0));
1367 tiny.put("W", new Integer(0));
1368 tiny.put("H", new Integer(0));
1369 tiny.put("K", new Integer(0));
1370 tiny.put("R", new Integer(0));
1371 tiny.put("E", new Integer(0));
1372 tiny.put("Q", new Integer(0));
1373 tiny.put("D", new Integer(0));
1374 tiny.put("N", new Integer(0));
1375 tiny.put("S", new Integer(1));
1376 tiny.put("T", new Integer(0));
1377 tiny.put("P", new Integer(0));
1378 tiny.put("-", new Integer(1));
1379 tiny.put("*", new Integer(1));
1384 proline.put("I", new Integer(0));
1385 proline.put("L", new Integer(0));
1386 proline.put("V", new Integer(0));
1387 proline.put("C", new Integer(0));
1388 proline.put("A", new Integer(0));
1389 proline.put("G", new Integer(0));
1390 proline.put("M", new Integer(0));
1391 proline.put("F", new Integer(0));
1392 proline.put("Y", new Integer(0));
1393 proline.put("W", new Integer(0));
1394 proline.put("H", new Integer(0));
1395 proline.put("K", new Integer(0));
1396 proline.put("R", new Integer(0));
1397 proline.put("E", new Integer(0));
1398 proline.put("Q", new Integer(0));
1399 proline.put("D", new Integer(0));
1400 proline.put("N", new Integer(0));
1401 proline.put("S", new Integer(0));
1402 proline.put("T", new Integer(0));
1403 proline.put("P", new Integer(1));
1404 proline.put("-", new Integer(1));
1405 proline.put("*", new Integer(1));
1410 propHash.put("hydrophobic", hydrophobic);
1411 propHash.put("small", small);
1412 propHash.put("positive", positive);
1413 propHash.put("negative", negative);
1414 propHash.put("charged", charged);
1415 propHash.put("aromatic", aromatic);
1416 propHash.put("aliphatic", aliphatic);
1417 propHash.put("tiny", tiny);
1418 propHash.put("proline", proline);
1419 propHash.put("polar", polar);
1423 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex],
1424 propMatrixPos = new int[maxProteinIndex][maxProteinIndex],
1425 propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1426 for (int i=0;i<maxProteinIndex;i++)
1428 int maxF=0,maxP=0,maxEP=0;
1434 for (int j=i+1;j<maxProteinIndex; j++)
1441 propMatrixF[i][j]=0;
1442 propMatrixPos[i][j]=0;
1443 propMatrixEpos[i][j]=0;
1444 for (Enumeration<String> en= (Enumeration<String>)propHash.keys(); en.hasMoreElements(); )
1446 String ph = en.nextElement();
1447 Map<String,Integer> pph=(Map<String,Integer>)propHash.get(ph);
1448 if (pph.get(ic)!=null && pph.get(jc)!=null) {
1449 int icp=pph.get(ic).intValue(),jcp=pph.get(jc).intValue();
1450 // Still working on these definitions.
1451 propMatrixPos[i][j] += icp == jcp && icp>0 ? 2 : 0;
1452 propMatrixPos[j][i] += icp == jcp && icp>0 ? 2 : 0;
1453 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1454 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1455 propMatrixEpos[i][j] += icp == jcp ? (1+icp * 2) : 0;
1456 propMatrixEpos[j][i] += icp == jcp ? (1+icp * 2) : 0;
1458 if (maxF<propMatrixF[i][j])
1460 maxF=propMatrixF[i][j];
1462 if (maxP<propMatrixPos[i][j])
1464 maxP=propMatrixPos[i][j];
1466 if (maxEP<propMatrixEpos[i][j])
1468 maxEP=propMatrixEpos[i][j];
1471 propMatrixF[i][i]=maxF;
1472 propMatrixPos[i][i]=maxP;
1473 propMatrixEpos[i][i]=maxEP;
1475 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1476 //scoreMatrices.put("Conservation Pos", new ScoreMatrix("Conservation Pos",propMatrixPos,0));
1477 //scoreMatrices.put("Conservation Both", new ScoreMatrix("Conservation Both",propMatrixF,0));
1478 //scoreMatrices.put("Conservation EnhPos", new ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1479 scoreMatrices.put("PID", new PIDScoreModel());
1482 private ResidueProperties()
1486 public static double getHydmax()
1491 public static double getHydmin()
1496 public static double[] getHyd()
1501 public static Hashtable getAA3Hash()
1506 public static int[][] getDNA()
1508 return ResidueProperties.DNA;
1511 public static int[][] getBLOSUM62()
1513 return ResidueProperties.BLOSUM62;
1516 public static int getPAM250(String A1, String A2)
1518 return getPAM250(A1.charAt(0), A2.charAt(0));
1521 public static int getBLOSUM62(char c1, char c2)
1527 int a = aaIndex[c1];
1528 int b = aaIndex[c2];
1530 pog = ResidueProperties.BLOSUM62[a][b];
1531 } catch (Exception e)
1533 // System.out.println("Unknown residue in " + A1 + " " + A2);
1539 public static Vector getCodons(String res)
1541 if (codonHash.containsKey(res))
1543 return (Vector) codonHash.get(res);
1549 public static String codonTranslate(String lccodon)
1553 return _codonTranslate(lccodon);
1555 String cdn = codonHash2.get(lccodon.toUpperCase());
1556 if (cdn!=null && cdn.equals("*"))
1562 public static String _codonTranslate(String lccodon)
1564 String codon = lccodon.toUpperCase();
1565 // all base ambiguity codes yield an 'X' amino acid residue
1566 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1570 Enumeration e = codonHash.keys();
1572 while (e.hasMoreElements())
1574 String key = (String) e.nextElement();
1575 Vector tmp = (Vector) codonHash.get(key);
1577 if (tmp.contains(codon))
1586 public static int[][] getDefaultPeptideMatrix()
1588 return ResidueProperties.getBLOSUM62();
1591 public static int[][] getDefaultDnaMatrix()
1593 return ResidueProperties.getDNA();
1597 * get a ScoreMatrix based on its string name
1600 * @return matrix in scoreMatrices with key pwtype or null
1602 public static ScoreMatrix getScoreMatrix(String pwtype)
1604 Object val = scoreMatrices.get(pwtype);
1605 if (val != null && val instanceof ScoreMatrix)
1607 return (ScoreMatrix) val;
1612 * get a ScoreModel based on its string name
1615 * @return scoremodel of type pwtype or null
1617 public static ScoreModelI getScoreModel(String pwtype)
1619 return scoreMatrices.get(pwtype);
1622 public static int getPAM250(char c, char d)
1627 int pog = ResidueProperties.PAM250[a][b];
1632 public static Hashtable toDssp3State;
1635 toDssp3State = new Hashtable();
1636 toDssp3State.put("H", "H");
1637 toDssp3State.put("E", "E");
1638 toDssp3State.put("C", " ");
1639 toDssp3State.put(" ", " ");
1640 toDssp3State.put("T", " ");
1641 toDssp3State.put("B", "E");
1642 toDssp3State.put("G", "H");
1643 toDssp3State.put("I", "H");
1644 toDssp3State.put("X", " ");
1648 * translate from other dssp secondary structure alphabets to 3-state
1651 * @return ssstring as a three-state secondary structure assignment.
1653 public static String getDssp3state(String ssstring)
1655 if (ssstring == null)
1659 StringBuffer ss = new StringBuffer();
1660 for (int i = 0; i < ssstring.length(); i++)
1662 String ssc = ssstring.substring(i, i + 1);
1663 if (toDssp3State.containsKey(ssc))
1665 ss.append((String) toDssp3State.get(ssc));
1672 return ss.toString();
1676 * Used by getRNASecStrucState
1679 public static Hashtable toRNAssState;
1682 toRNAssState = new Hashtable();
1683 toRNAssState.put(")", "S");
1684 toRNAssState.put("(", "S");
1688 * translate to RNA secondary structure representation
1691 * @return ssstring as a RNA-state secondary structure assignment.
1693 public static String getRNASecStrucState(String ssstring)
1695 if (ssstring == null)
1699 StringBuffer ss = new StringBuffer();
1700 for (int i = 0; i < ssstring.length(); i++)
1702 String ssc = ssstring.substring(i, i + 1);
1703 if (toRNAssState.containsKey(ssc))
1705 ss.append((String) toRNAssState.get(ssc));
1712 return ss.toString();
1715 // main method generates perl representation of residue property hash
1717 public static void main(String[] args)
1719 Hashtable aa = new Hashtable();
1720 System.out.println("my %aa = {");
1721 // invert property hashes
1722 Enumeration prop = propHash.keys();
1723 while (prop.hasMoreElements())
1725 String pname = (String) prop.nextElement();
1726 Hashtable phash = (Hashtable) propHash.get(pname);
1727 Enumeration res = phash.keys();
1728 while (res.hasMoreElements())
1730 String rname = (String) res.nextElement();
1731 Vector aprops = (Vector) aa.get(rname);
1734 aprops = new Vector();
1735 aa.put(rname, aprops);
1737 Integer hasprop = (Integer) phash.get(rname);
1738 if (hasprop.intValue() == 1)
1740 aprops.addElement(pname);
1744 Enumeration res = aa.keys();
1745 while (res.hasMoreElements())
1747 String rname = (String) res.nextElement();
1749 System.out.print("'" + rname + "' => [");
1750 Enumeration props = ((Vector) aa.get(rname)).elements();
1751 while (props.hasMoreElements())
1753 System.out.print("'" + (String) props.nextElement() + "'");
1754 if (props.hasMoreElements())
1756 System.out.println(", ");
1759 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1761 System.out.println("};");