2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.schemes;
23 import jalview.analysis.scoremodels.PIDScoreModel;
24 import jalview.api.analysis.ScoreModelI;
27 import java.util.List;
30 public class ResidueProperties
32 public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable();
34 // Stores residue codes/names and colours and other things
35 public static final int[] aaIndex; // aaHash version 2.1.1 and below
37 public static final int[] nucleotideIndex;
39 public static final int[] purinepyrimidineIndex;
41 public static final Hashtable aa3Hash = new Hashtable();
43 public static final Hashtable aa2Triplet = new Hashtable();
45 public static final Hashtable nucleotideName = new Hashtable();
49 aaIndex = new int[255];
50 for (int i = 0; i < 255; i++)
102 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
103 // extend subt. matrices
107 * maximum (gap) index for matrices involving protein alphabet
109 public final static int maxProteinIndex = 23;
112 * maximum (gap) index for matrices involving nucleotide alphabet
114 public final static int maxNucleotideIndex = 10;
118 nucleotideIndex = new int[255];
119 for (int i = 0; i < 255; i++)
121 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
124 nucleotideIndex['A'] = 0;
125 nucleotideIndex['a'] = 0;
126 nucleotideIndex['C'] = 1;
127 nucleotideIndex['c'] = 1;
128 nucleotideIndex['G'] = 2;
129 nucleotideIndex['g'] = 2;
130 nucleotideIndex['T'] = 3;
131 nucleotideIndex['t'] = 3;
132 nucleotideIndex['U'] = 4;
133 nucleotideIndex['u'] = 4;
134 nucleotideIndex['I'] = 5;
135 nucleotideIndex['i'] = 5;
136 nucleotideIndex['X'] = 6;
137 nucleotideIndex['x'] = 6;
138 nucleotideIndex['R'] = 7;
139 nucleotideIndex['r'] = 7;
140 nucleotideIndex['Y'] = 8;
141 nucleotideIndex['y'] = 8;
142 nucleotideIndex['N'] = 9;
143 nucleotideIndex['n'] = 9;
145 nucleotideName.put("A", "Adenine");
146 nucleotideName.put("a", "Adenine");
147 nucleotideName.put("G", "Guanine");
148 nucleotideName.put("g", "Guanine");
149 nucleotideName.put("C", "Cytosine");
150 nucleotideName.put("c", "Cytosine");
151 nucleotideName.put("T", "Thymine");
152 nucleotideName.put("t", "Thymine");
153 nucleotideName.put("U", "Uracil");
154 nucleotideName.put("u", "Uracil");
155 nucleotideName.put("I", "Inosine");
156 nucleotideName.put("i", "Inosine");
157 nucleotideName.put("X", "Xanthine");
158 nucleotideName.put("x", "Xanthine");
159 nucleotideName.put("R", "Unknown Purine");
160 nucleotideName.put("r", "Unknown Purine");
161 nucleotideName.put("Y", "Unknown Pyrimidine");
162 nucleotideName.put("y", "Unknown Pyrimidine");
163 nucleotideName.put("N", "Unknown");
164 nucleotideName.put("n", "Unknown");
165 nucleotideName.put("W", "Weak nucleotide (A or T)");
166 nucleotideName.put("w", "Weak nucleotide (A or T)");
167 nucleotideName.put("S", "Strong nucleotide (G or C)");
168 nucleotideName.put("s", "Strong nucleotide (G or C)");
169 nucleotideName.put("M", "Amino (A or C)");
170 nucleotideName.put("m", "Amino (A or C)");
171 nucleotideName.put("K", "Keto (G or T)");
172 nucleotideName.put("k", "Keto (G or T)");
173 nucleotideName.put("B", "Not A (G or C or T)");
174 nucleotideName.put("b", "Not A (G or C or T)");
175 nucleotideName.put("H", "Not G (A or C or T)");
176 nucleotideName.put("h", "Not G (A or C or T)");
177 nucleotideName.put("D", "Not C (A or G or T)");
178 nucleotideName.put("d", "Not C (A or G or T)");
179 nucleotideName.put("V", "Not T (A or G or C");
180 nucleotideName.put("v", "Not T (A or G or C");
186 purinepyrimidineIndex = new int[255];
187 for (int i = 0; i < 255; i++)
189 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
193 purinepyrimidineIndex['A'] = 0;
194 purinepyrimidineIndex['a'] = 0;
195 purinepyrimidineIndex['C'] = 1;
196 purinepyrimidineIndex['c'] = 1;
197 purinepyrimidineIndex['G'] = 0;
198 purinepyrimidineIndex['g'] = 0;
199 purinepyrimidineIndex['T'] = 1;
200 purinepyrimidineIndex['t'] = 1;
201 purinepyrimidineIndex['U'] = 1;
202 purinepyrimidineIndex['u'] = 1;
203 purinepyrimidineIndex['I'] = 2;
204 purinepyrimidineIndex['i'] = 2;
205 purinepyrimidineIndex['X'] = 2;
206 purinepyrimidineIndex['x'] = 2;
207 purinepyrimidineIndex['R'] = 0;
208 purinepyrimidineIndex['r'] = 0;
209 purinepyrimidineIndex['Y'] = 1;
210 purinepyrimidineIndex['y'] = 1;
211 purinepyrimidineIndex['N'] = 2;
212 purinepyrimidineIndex['n'] = 2;
217 aa3Hash.put("ALA", new Integer(0));
218 aa3Hash.put("ARG", new Integer(1));
219 aa3Hash.put("ASN", new Integer(2));
220 aa3Hash.put("ASP", new Integer(3)); // D
221 aa3Hash.put("CYS", new Integer(4));
222 aa3Hash.put("GLN", new Integer(5)); // Q
223 aa3Hash.put("GLU", new Integer(6)); // E
224 aa3Hash.put("GLY", new Integer(7));
225 aa3Hash.put("HIS", new Integer(8));
226 aa3Hash.put("ILE", new Integer(9));
227 aa3Hash.put("LEU", new Integer(10));
228 aa3Hash.put("LYS", new Integer(11));
229 aa3Hash.put("MET", new Integer(12));
230 aa3Hash.put("PHE", new Integer(13));
231 aa3Hash.put("PRO", new Integer(14));
232 aa3Hash.put("SER", new Integer(15));
233 aa3Hash.put("THR", new Integer(16));
234 aa3Hash.put("TRP", new Integer(17));
235 aa3Hash.put("TYR", new Integer(18));
236 aa3Hash.put("VAL", new Integer(19));
237 // IUB Nomenclature for ambiguous peptides
238 aa3Hash.put("ASX", new Integer(20)); // "B";
239 aa3Hash.put("GLX", new Integer(21)); // X
240 aa3Hash.put("XAA", new Integer(22)); // X unknown
241 aa3Hash.put("-", new Integer(23));
242 aa3Hash.put("*", new Integer(23));
243 aa3Hash.put(".", new Integer(23));
244 aa3Hash.put(" ", new Integer(23));
245 aa3Hash.put("Gap", new Integer(23));
250 aa2Triplet.put("A", "ALA");
251 aa2Triplet.put("a", "ALA");
252 aa2Triplet.put("R", "ARG");
253 aa2Triplet.put("r", "ARG");
254 aa2Triplet.put("N", "ASN");
255 aa2Triplet.put("n", "ASN");
256 aa2Triplet.put("D", "ASP");
257 aa2Triplet.put("d", "ASP");
258 aa2Triplet.put("C", "CYS");
259 aa2Triplet.put("c", "CYS");
260 aa2Triplet.put("Q", "GLN");
261 aa2Triplet.put("q", "GLN");
262 aa2Triplet.put("E", "GLU");
263 aa2Triplet.put("e", "GLU");
264 aa2Triplet.put("G", "GLY");
265 aa2Triplet.put("g", "GLY");
266 aa2Triplet.put("H", "HIS");
267 aa2Triplet.put("h", "HIS");
268 aa2Triplet.put("I", "ILE");
269 aa2Triplet.put("i", "ILE");
270 aa2Triplet.put("L", "LEU");
271 aa2Triplet.put("l", "LEU");
272 aa2Triplet.put("K", "LYS");
273 aa2Triplet.put("k", "LYS");
274 aa2Triplet.put("M", "MET");
275 aa2Triplet.put("m", "MET");
276 aa2Triplet.put("F", "PHE");
277 aa2Triplet.put("f", "PHE");
278 aa2Triplet.put("P", "PRO");
279 aa2Triplet.put("p", "PRO");
280 aa2Triplet.put("S", "SER");
281 aa2Triplet.put("s", "SER");
282 aa2Triplet.put("T", "THR");
283 aa2Triplet.put("t", "THR");
284 aa2Triplet.put("W", "TRP");
285 aa2Triplet.put("w", "TRP");
286 aa2Triplet.put("Y", "TYR");
287 aa2Triplet.put("y", "TYR");
288 aa2Triplet.put("V", "VAL");
289 aa2Triplet.put("v", "VAL");
292 public static final String[] aa =
293 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
294 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
296 public static final Color midBlue = new Color(100, 100, 255);
298 public static final Vector scaleColours = new Vector();
302 scaleColours.addElement(new Color(114, 0, 147));
303 scaleColours.addElement(new Color(156, 0, 98));
304 scaleColours.addElement(new Color(190, 0, 0));
305 scaleColours.addElement(Color.red);
306 scaleColours.addElement(new Color(255, 125, 0));
307 scaleColours.addElement(Color.orange);
308 scaleColours.addElement(new Color(255, 194, 85));
309 scaleColours.addElement(Color.yellow);
310 scaleColours.addElement(new Color(255, 255, 181));
311 scaleColours.addElement(Color.white);
314 public static final Color[] taylor =
315 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
316 new Color(0, 0, 255), // R Blueish-bluey-blue
317 new Color(204, 0, 255), // N Blueish-reddy-blue
318 new Color(255, 0, 0), // D Reddish-reddy-red
319 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
320 new Color(255, 0, 204), // Q Reddish-bluey-red
321 new Color(255, 0, 102), // E Blueish-reddy-red
322 new Color(255, 153, 0), // G Yellowy-reddy-yellow
323 new Color(0, 102, 255), // H Greenish-bluey-blue
324 new Color(102, 255, 0), // I Greenish-yellowy-green
325 new Color(51, 255, 0), // L Yellowish-greeny-green
326 new Color(102, 0, 255), // K Reddish-bluey-blue
327 new Color(0, 255, 0), // M Greenish-greeny-green
328 new Color(0, 255, 102), // F Blueish-greeny-green
329 new Color(255, 204, 0), // P Reddish-yellowy-yellow
330 new Color(255, 51, 0), // S Yellowish-reddy-red
331 new Color(255, 102, 0), // T Reddish-yellowy-red
332 new Color(0, 204, 255), // W Blueish-greeny-green
333 new Color(0, 255, 204), // Y Greenish-bluey-green
334 new Color(153, 255, 0), // V Yellowish-greeny-yellow
343 public static final Color[] nucleotide =
344 { new Color(100, 247, 63), // A
345 new Color(255, 179, 64), // C
346 new Color(235, 65, 60), // G
347 new Color(60, 136, 238), // T
348 new Color(60, 136, 238), // U
349 Color.white, // I (inosine)
350 Color.white, // X (xanthine)
357 // Added for PurinePyrimidineColourScheme
358 public static final Color[] purinepyrimidine =
359 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
360 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
361 Color.white, // all other nucleotides
366 public static final Color[] zappo =
375 midBlue,// Color.red, // H
396 // Dunno where I got these numbers from
397 public static final double[] hyd2 =
423 public static final double[] helix =
424 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
425 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
427 public static final double helixmin = 0.57;
429 public static final double helixmax = 1.51;
431 public static final double[] strand =
432 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
433 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
435 public static final double strandmin = 0.37;
437 public static final double strandmax = 1.7;
439 public static final double[] turn =
440 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
441 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
444 public static final double turnmin = 0.47;
446 public static final double turnmax = 1.56;
448 public static final double[] buried =
449 { 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,
450 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
452 public static final double buriedmin = 0.05;
454 public static final double buriedmax = 4.6;
456 // This is hydropathy index
457 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
458 // 1157, 105-132, 1982
459 public static final double[] hyd =
460 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
461 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
463 public static final double hydmax = 4.5;
465 public static final double hydmin = -3.9;
467 // public static final double hydmax = 1.38;
468 // public static final double hydmin = -2.53;
469 private static final int[][] BLOSUM62 =
471 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
472 -2, 0, -2, -1, 0, -4 },
473 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
474 -2, -3, -1, 0, -1, -4 },
475 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
477 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
478 -3, -3, 4, 1, -1, -4 },
479 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
480 -2, -2, -1, -3, -3, -2, -4 },
481 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
483 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
485 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
486 -3, -3, -1, -2, -1, -4 },
487 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
488 2, -3, 0, 0, -1, -4 },
489 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
490 -1, 3, -3, -3, -1, -4 },
491 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
492 -1, 1, -4, -3, -1, -4 },
493 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
494 -2, -2, 0, 1, -1, -4 },
495 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
496 -1, 1, -3, -1, -1, -4 },
497 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
498 3, -1, -3, -3, -1, -4 },
499 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
500 -4, -3, -2, -2, -1, -2, -4 },
501 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
503 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
504 -2, 0, -1, -1, 0, -4 },
505 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
506 11, 2, -3, -4, -3, -2, -4 },
507 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
508 2, 7, -1, -3, -2, -1, -4 },
509 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
510 -1, 4, -3, -2, -1, -4 },
511 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
512 -3, -3, 4, 1, -1, -4 },
513 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
515 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
516 -2, -1, -1, -1, -1, -1, -4 },
517 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
518 -4, -4, -4, -4, -4, -4, 1 }, };
520 static final int[][] PAM250 =
522 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
524 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
526 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
528 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
530 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
531 -8, 0, -2, -4, -5, -3, -8 },
532 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
534 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
536 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
538 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
540 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
541 -1, 4, -2, -2, -1, -8 },
542 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
543 -1, 2, -3, -3, -1, -8 },
544 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
546 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
547 -2, 2, -2, -2, -1, -8 },
548 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
549 7, -1, -4, -5, -2, -8 },
550 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
552 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
554 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
556 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
557 17, 0, -6, -5, -6, -4, -8 },
558 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
559 10, -2, -3, -4, -2, -8 },
560 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
561 -2, 4, -2, -2, -1, -8 },
562 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
564 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
566 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
567 -2, -1, -1, -1, -1, -8 },
568 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
569 -8, -8, -8, -8, -8, -8, 1 }, };
571 public static final Hashtable ssHash = new Hashtable(); // stores the number
576 ssHash.put("H", Color.magenta);
577 ssHash.put("E", Color.yellow);
578 ssHash.put("-", Color.white);
579 ssHash.put(".", Color.white);
580 ssHash.put("S", Color.cyan);
581 ssHash.put("T", Color.blue);
582 ssHash.put("G", Color.pink);
583 ssHash.put("I", Color.pink);
584 ssHash.put("B", Color.yellow);
588 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
589 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
592 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
593 // Will equate sequences if working with mixed nucleotide sets.
594 // treats T and U identically. R and Y weak equivalence with AG and CTU.
595 // N matches any other base weakly
597 static final int[][] DNA =
599 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
600 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
601 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
602 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
603 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
604 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
605 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
606 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
607 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
608 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
609 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
612 * register matrices in list
616 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
617 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
618 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
622 public static final Color[] pidColours =
623 { midBlue, new Color(153, 153, 255),
625 new Color(204, 204, 255), };
627 public static final float[] pidThresholds =
630 public static Hashtable codonHash = new Hashtable();
632 public static Vector Lys = new Vector();
634 public static Vector Asn = new Vector();
636 public static Vector Gln = new Vector();
638 public static Vector His = new Vector();
640 public static Vector Glu = new Vector();
642 public static Vector Asp = new Vector();
644 public static Vector Tyr = new Vector();
646 public static Vector Thr = new Vector();
648 public static Vector Pro = new Vector();
650 public static Vector Ala = new Vector();
652 public static Vector Ser = new Vector();
654 public static Vector Arg = new Vector();
656 public static Vector Gly = new Vector();
658 public static Vector Trp = new Vector();
660 public static Vector Cys = new Vector();
662 public static Vector Ile = new Vector();
664 public static Vector Met = new Vector();
666 public static Vector Leu = new Vector();
668 public static Vector Val = new Vector();
670 public static Vector Phe = new Vector();
672 public static Vector STOP = new Vector();
676 codonHash.put("K", Lys);
677 codonHash.put("N", Asn);
678 codonHash.put("Q", Gln);
679 codonHash.put("H", His);
680 codonHash.put("E", Glu);
681 codonHash.put("D", Asp);
682 codonHash.put("Y", Tyr);
683 codonHash.put("T", Thr);
684 codonHash.put("P", Pro);
685 codonHash.put("A", Ala);
686 codonHash.put("S", Ser);
687 codonHash.put("R", Arg);
688 codonHash.put("G", Gly);
689 codonHash.put("W", Trp);
690 codonHash.put("C", Cys);
691 codonHash.put("I", Ile);
692 codonHash.put("M", Met);
693 codonHash.put("L", Leu);
694 codonHash.put("V", Val);
695 codonHash.put("F", Phe);
696 codonHash.put("STOP", STOP);
700 * Nucleotide Ambiguity Codes
702 public static final Hashtable<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
705 * Codon triplets with additional symbols for unambiguous codons that include
708 public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
711 * all ambiguity codes for a given base
713 public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
718 * 3.2. Purine (adenine or guanine): R
720 * R is the symbol previously recommended [1].
722 ambiguityCodes.put("R", new String[]
726 * 3.3. Pyrimidine (thymine or cytosine): Y
728 * Y is the symbol previously recommended [1].
730 ambiguityCodes.put("Y", new String[]
733 * 3.4. Adenine or thymine: W
735 * Although several diverse symbols have been used for this pair, (and for
736 * the reciprocal pair G+C), only two symbols have a rational basis, L and
737 * W: L derives from DNA density (light; G+C - heavy - would thus be H); W
738 * derives from the strength of the hydrogen bonding interaction between the
739 * base pairs (weak for A+T: G +C - strong - would thus be S). However, the
740 * system recommended for the three-base series (not-A = B, etc., see below,
741 * section 3.8) rules out H as this would be not-G. W is thus recommended.
743 ambiguityCodes.put("W", new String[]
746 * 3.5. Guanine or cytosine: S
748 * The choice of this symbol is discussed above in section 3.4.
750 ambiguityCodes.put("S", new String[]
753 * 3.6. Adenine or cytosine: M
755 * There are few common features between A and C. The presence of an NH2
756 * group in similar positions on both bases (Fig. 1) makes possible a
757 * logically derived symbol. A and N being ruled out, M (from aMino) is
761 * Fig. 1. Origin of the symbols M and K The four bases are drawn so as to
762 * show the relationship between adenine and cytosine on the one hand, which
763 * both have aMino groups at the ring position most distant from the point
764 * of attachment to the sugar, and between guanine and thymine on the other,
765 * which both have Keto groups at the corresponding position. The ring atoms
766 * are numbered as recommended [24-26], although for the present purpose
767 * this has the disadvantage of giving discordant numbers to the
768 * corresponding positions.
770 ambiguityCodes.put("M", new String[]
773 * 3.7. Guanine or thymine: K By analogy with A and C (section 3.6), both G
774 * and T have Keto groups in similar positions (Fig. 1).
776 ambiguityCodes.put("K", new String[]
779 * 3.8. Adenine or thymine or cytosine: H
781 * Not-G is the most simple means of memorising this combination and symbols
782 * logically related to G were examined. F and H would both be suitable, as
783 * the letters before and after G in the alphabet, but A would have no
784 * equivalent to F. The use of H has historical precedence [2].
786 ambiguityCodes.put("H", new String[]
789 * 3.9. Guanine or cytosine or thymine: B
791 * Not-A as above (section 3.8).
793 ambiguityCodes.put("B", new String[]
796 * 3.10. Guanine or adenine or cytosine: V
798 * Not-T by analogy with not-G (section 3.8) would be U but this is ruled
799 * out to eliminate confusion with uracil. V is the next logical choice.
800 * Note that T and U may in some cases be considered to be synonyms.
802 ambiguityCodes.put("V", new String[]
805 * 3.11. Guanine or adenine or thymine: D
807 * Not-C as above (section 3.8).
809 ambiguityCodes.put("D", new String[]
812 * 3.12. Guanine or adenine or thymine or cytosine: N
814 ambiguityCodes.put("R", new String[]
815 { "G", "A", "T", "C" });
816 // Now build codon translation table
817 codonHash2.put("AAA", "K");
818 codonHash2.put("AAG", "K");
819 codonHash2.put("AAC", "N");
820 codonHash2.put("AAT", "N");
822 codonHash2.put("CAA", "Q");
823 codonHash2.put("CAG", "Q");
824 codonHash2.put("CAC", "H");
825 codonHash2.put("CAT", "H");
827 codonHash2.put("GAA", "E");
828 codonHash2.put("GAG", "E");
829 codonHash2.put("GAC", "D");
830 codonHash2.put("GAT", "D");
832 codonHash2.put("TAC", "Y");
833 codonHash2.put("TAT", "Y");
835 codonHash2.put("ACA", "T");
836 codonHash2.put("ACC", "T");
837 codonHash2.put("ACT", "T");
838 codonHash2.put("ACG", "T");
840 codonHash2.put("CCA", "P");
841 codonHash2.put("CCG", "P");
842 codonHash2.put("CCC", "P");
843 codonHash2.put("CCT", "P");
845 codonHash2.put("GCA", "A");
846 codonHash2.put("GCG", "A");
847 codonHash2.put("GCC", "A");
848 codonHash2.put("GCT", "A");
850 codonHash2.put("TCA", "S");
851 codonHash2.put("TCG", "S");
852 codonHash2.put("TCC", "S");
853 codonHash2.put("TCT", "S");
854 codonHash2.put("AGC", "S");
855 codonHash2.put("AGT", "S");
857 codonHash2.put("AGA", "R");
858 codonHash2.put("AGG", "R");
859 codonHash2.put("CGA", "R");
860 codonHash2.put("CGG", "R");
861 codonHash2.put("CGC", "R");
862 codonHash2.put("CGT", "R");
864 codonHash2.put("GGA", "G");
865 codonHash2.put("GGG", "G");
866 codonHash2.put("GGC", "G");
867 codonHash2.put("GGT", "G");
869 codonHash2.put("TGA", "*");
870 codonHash2.put("TAA", "*");
871 codonHash2.put("TAG", "*");
873 codonHash2.put("TGG", "W");
875 codonHash2.put("TGC", "C");
876 codonHash2.put("TGT", "C");
878 codonHash2.put("ATA", "I");
879 codonHash2.put("ATC", "I");
880 codonHash2.put("ATT", "I");
882 codonHash2.put("ATG", "M");
884 codonHash2.put("CTA", "L");
885 codonHash2.put("CTG", "L");
886 codonHash2.put("CTC", "L");
887 codonHash2.put("CTT", "L");
888 codonHash2.put("TTA", "L");
889 codonHash2.put("TTG", "L");
891 codonHash2.put("GTA", "V");
892 codonHash2.put("GTG", "V");
893 codonHash2.put("GTC", "V");
894 codonHash2.put("GTT", "V");
896 codonHash2.put("TTC", "F");
897 codonHash2.put("TTT", "F");
899 buildAmbiguityCodonSet();
903 * programmatic generation of codons including ambiguity codes
905 public static void buildAmbiguityCodonSet()
907 if (_ambiguityCodes.size() > 0)
910 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
913 // Invert the ambiguity code set
914 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
916 for (String r : acode.getValue())
918 List<String> codesfor = _ambiguityCodes.get(r);
919 if (codesfor == null)
921 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
923 if (!codesfor.contains(acode.getKey()))
925 codesfor.add(acode.getKey());
930 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
931 + acode.getKey() + " in residue " + r);
935 // and programmatically add in the ambiguity codes that yield the same amino
937 String[] unambcodons = codonHash2.keySet().toArray(
938 new String[codonHash2.size()]);
939 for (String codon : unambcodons)
941 String residue = codonHash2.get(codon);
942 String acodon[][] = new String[codon.length()][];
943 for (int i = 0, iSize = codon.length(); i < iSize; i++)
945 String _ac = "" + codon.charAt(i);
946 List<String> acodes = _ambiguityCodes.get(_ac);
949 acodon[i] = acodes.toArray(new String[acodes.size()]);
953 acodon[i] = new String[]
957 // enumerate all combinations and test for veracity of translation
958 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
959 for (int i = 0; i < tpos.length; i++)
963 tpos[acodon.length - 1] = 0;
965 while (tpos[0] < acodon[0].length)
967 // make all codons for this combination
968 char allres[][] = new char[tpos.length][];
971 for (ipos = 0; ipos < tpos.length; ipos++)
973 if (acodon[ipos].length == 0 || tpos[ipos] < 0)
975 _acodon += codon.charAt(ipos);
976 allres[ipos] = new char[]
977 { codon.charAt(ipos) };
981 _acodon += acodon[ipos][tpos[ipos]];
982 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
983 allres[ipos] = new char[altbase.length];
985 for (String ab : altbase)
987 allres[ipos][j++] = ab.charAt(0);
991 // test all codons for this combination
992 for (ipos = 0; ipos < cpos.length; ipos++)
996 boolean valid = true;
1000 for (j = 0; j < cpos.length; j++)
1002 _codon += allres[j][cpos[j]];
1004 String tr = codonHash2.get(_codon);
1005 if (valid = (tr != null && tr.equals(residue)))
1007 // advance to next combination
1008 ipos = acodon.length - 1;
1009 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
1015 } while (valid && cpos[0] < allres[0].length);
1018 // Add this to the set of codons we will translate
1019 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
1021 codonHash2.put(_acodon, residue);
1025 // System.err.println("Rejecting ambiguity codon: " + _acodon
1026 // + " for " + residue);
1029 ipos = acodon.length - 1;
1030 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1042 Lys.addElement("AAA");
1043 Lys.addElement("AAG");
1044 Asn.addElement("AAC");
1045 Asn.addElement("AAT");
1047 Gln.addElement("CAA");
1048 Gln.addElement("CAG");
1049 His.addElement("CAC");
1050 His.addElement("CAT");
1052 Glu.addElement("GAA");
1053 Glu.addElement("GAG");
1054 Asp.addElement("GAC");
1055 Asp.addElement("GAT");
1057 Tyr.addElement("TAC");
1058 Tyr.addElement("TAT");
1060 Thr.addElement("ACA");
1061 Thr.addElement("ACG");
1062 Thr.addElement("ACC");
1063 Thr.addElement("ACT");
1065 Pro.addElement("CCA");
1066 Pro.addElement("CCG");
1067 Pro.addElement("CCC");
1068 Pro.addElement("CCT");
1070 Ala.addElement("GCA");
1071 Ala.addElement("GCG");
1072 Ala.addElement("GCC");
1073 Ala.addElement("GCT");
1075 Ser.addElement("TCA");
1076 Ser.addElement("TCG");
1077 Ser.addElement("TCC");
1078 Ser.addElement("TCT");
1079 Ser.addElement("AGC");
1080 Ser.addElement("AGT");
1082 Arg.addElement("AGA");
1083 Arg.addElement("AGG");
1084 Arg.addElement("CGA");
1085 Arg.addElement("CGG");
1086 Arg.addElement("CGC");
1087 Arg.addElement("CGT");
1089 Gly.addElement("GGA");
1090 Gly.addElement("GGG");
1091 Gly.addElement("GGC");
1092 Gly.addElement("GGT");
1094 STOP.addElement("TGA");
1095 STOP.addElement("TAA");
1096 STOP.addElement("TAG");
1098 Trp.addElement("TGG");
1100 Cys.addElement("TGC");
1101 Cys.addElement("TGT");
1103 Ile.addElement("ATA");
1104 Ile.addElement("ATC");
1105 Ile.addElement("ATT");
1107 Met.addElement("ATG");
1109 Leu.addElement("CTA");
1110 Leu.addElement("CTG");
1111 Leu.addElement("CTC");
1112 Leu.addElement("CTT");
1113 Leu.addElement("TTA");
1114 Leu.addElement("TTG");
1116 Val.addElement("GTA");
1117 Val.addElement("GTG");
1118 Val.addElement("GTC");
1119 Val.addElement("GTT");
1121 Phe.addElement("TTC");
1122 Phe.addElement("TTT");
1125 // Stores residue codes/names and colours and other things
1126 public static Hashtable propHash = new Hashtable();
1128 public static Hashtable hydrophobic = new Hashtable();
1130 public static Hashtable polar = new Hashtable();
1132 public static Hashtable small = new Hashtable();
1134 public static Hashtable positive = new Hashtable();
1136 public static Hashtable negative = new Hashtable();
1138 public static Hashtable charged = new Hashtable();
1140 public static Hashtable aromatic = new Hashtable();
1142 public static Hashtable aliphatic = new Hashtable();
1144 public static Hashtable tiny = new Hashtable();
1146 public static Hashtable proline = new Hashtable();
1150 hydrophobic.put("I", new Integer(1));
1151 hydrophobic.put("L", new Integer(1));
1152 hydrophobic.put("V", new Integer(1));
1153 hydrophobic.put("C", new Integer(1));
1154 hydrophobic.put("A", new Integer(1));
1155 hydrophobic.put("G", new Integer(1));
1156 hydrophobic.put("M", new Integer(1));
1157 hydrophobic.put("F", new Integer(1));
1158 hydrophobic.put("Y", new Integer(1));
1159 hydrophobic.put("W", new Integer(1));
1160 hydrophobic.put("H", new Integer(1));
1161 hydrophobic.put("K", new Integer(1));
1162 hydrophobic.put("X", new Integer(1));
1163 hydrophobic.put("-", new Integer(1));
1164 hydrophobic.put("*", new Integer(1));
1165 hydrophobic.put("R", new Integer(0));
1166 hydrophobic.put("E", new Integer(0));
1167 hydrophobic.put("Q", new Integer(0));
1168 hydrophobic.put("D", new Integer(0));
1169 hydrophobic.put("N", new Integer(0));
1170 hydrophobic.put("S", new Integer(0));
1171 hydrophobic.put("T", new Integer(0));
1172 hydrophobic.put("P", new Integer(0));
1177 polar.put("Y", new Integer(1));
1178 polar.put("W", new Integer(1));
1179 polar.put("H", new Integer(1));
1180 polar.put("K", new Integer(1));
1181 polar.put("R", new Integer(1));
1182 polar.put("E", new Integer(1));
1183 polar.put("Q", new Integer(1));
1184 polar.put("D", new Integer(1));
1185 polar.put("N", new Integer(1));
1186 polar.put("S", new Integer(1));
1187 polar.put("T", new Integer(1));
1188 polar.put("X", new Integer(1));
1189 polar.put("-", new Integer(1));
1190 polar.put("*", new Integer(1));
1191 polar.put("I", new Integer(0));
1192 polar.put("L", new Integer(0));
1193 polar.put("V", new Integer(0));
1194 polar.put("C", new Integer(0));
1195 polar.put("A", new Integer(0));
1196 polar.put("G", new Integer(0));
1197 polar.put("M", new Integer(0));
1198 polar.put("F", new Integer(0));
1199 polar.put("P", new Integer(0));
1204 small.put("I", new Integer(0));
1205 small.put("L", new Integer(0));
1206 small.put("V", new Integer(1));
1207 small.put("C", new Integer(1));
1208 small.put("A", new Integer(1));
1209 small.put("G", new Integer(1));
1210 small.put("M", new Integer(0));
1211 small.put("F", new Integer(0));
1212 small.put("Y", new Integer(0));
1213 small.put("W", new Integer(0));
1214 small.put("H", new Integer(0));
1215 small.put("K", new Integer(0));
1216 small.put("R", new Integer(0));
1217 small.put("E", new Integer(0));
1218 small.put("Q", new Integer(0));
1219 small.put("D", new Integer(1));
1220 small.put("N", new Integer(1));
1221 small.put("S", new Integer(1));
1222 small.put("T", new Integer(1));
1223 small.put("P", new Integer(1));
1224 small.put("-", new Integer(1));
1225 small.put("*", new Integer(1));
1230 positive.put("I", new Integer(0));
1231 positive.put("L", new Integer(0));
1232 positive.put("V", new Integer(0));
1233 positive.put("C", new Integer(0));
1234 positive.put("A", new Integer(0));
1235 positive.put("G", new Integer(0));
1236 positive.put("M", new Integer(0));
1237 positive.put("F", new Integer(0));
1238 positive.put("Y", new Integer(0));
1239 positive.put("W", new Integer(0));
1240 positive.put("H", new Integer(1));
1241 positive.put("K", new Integer(1));
1242 positive.put("R", new Integer(1));
1243 positive.put("E", new Integer(0));
1244 positive.put("Q", new Integer(0));
1245 positive.put("D", new Integer(0));
1246 positive.put("N", new Integer(0));
1247 positive.put("S", new Integer(0));
1248 positive.put("T", new Integer(0));
1249 positive.put("P", new Integer(0));
1250 positive.put("-", new Integer(1));
1251 positive.put("*", new Integer(1));
1256 negative.put("I", new Integer(0));
1257 negative.put("L", new Integer(0));
1258 negative.put("V", new Integer(0));
1259 negative.put("C", new Integer(0));
1260 negative.put("A", new Integer(0));
1261 negative.put("G", new Integer(0));
1262 negative.put("M", new Integer(0));
1263 negative.put("F", new Integer(0));
1264 negative.put("Y", new Integer(0));
1265 negative.put("W", new Integer(0));
1266 negative.put("H", new Integer(0));
1267 negative.put("K", new Integer(0));
1268 negative.put("R", new Integer(0));
1269 negative.put("E", new Integer(1));
1270 negative.put("Q", new Integer(0));
1271 negative.put("D", new Integer(1));
1272 negative.put("N", new Integer(0));
1273 negative.put("S", new Integer(0));
1274 negative.put("T", new Integer(0));
1275 negative.put("P", new Integer(0));
1276 negative.put("-", new Integer(1));
1277 negative.put("*", new Integer(1));
1282 charged.put("I", new Integer(0));
1283 charged.put("L", new Integer(0));
1284 charged.put("V", new Integer(0));
1285 charged.put("C", new Integer(0));
1286 charged.put("A", new Integer(0));
1287 charged.put("G", new Integer(0));
1288 charged.put("M", new Integer(0));
1289 charged.put("F", new Integer(0));
1290 charged.put("Y", new Integer(0));
1291 charged.put("W", new Integer(0));
1292 charged.put("H", new Integer(1));
1293 charged.put("K", new Integer(1));
1294 charged.put("R", new Integer(1));
1295 charged.put("E", new Integer(1));
1296 charged.put("Q", new Integer(0));
1297 charged.put("D", new Integer(1));
1298 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1299 // Alternative would be charged and
1300 // negative (in basic form)?
1301 charged.put("S", new Integer(0));
1302 charged.put("T", new Integer(0));
1303 charged.put("P", new Integer(0));
1304 charged.put("-", new Integer(1));
1305 charged.put("*", new Integer(1));
1310 aromatic.put("I", new Integer(0));
1311 aromatic.put("L", new Integer(0));
1312 aromatic.put("V", new Integer(0));
1313 aromatic.put("C", new Integer(0));
1314 aromatic.put("A", new Integer(0));
1315 aromatic.put("G", new Integer(0));
1316 aromatic.put("M", new Integer(0));
1317 aromatic.put("F", new Integer(1));
1318 aromatic.put("Y", new Integer(1));
1319 aromatic.put("W", new Integer(1));
1320 aromatic.put("H", new Integer(1));
1321 aromatic.put("K", new Integer(0));
1322 aromatic.put("R", new Integer(0));
1323 aromatic.put("E", new Integer(0));
1324 aromatic.put("Q", new Integer(0));
1325 aromatic.put("D", new Integer(0));
1326 aromatic.put("N", new Integer(0));
1327 aromatic.put("S", new Integer(0));
1328 aromatic.put("T", new Integer(0));
1329 aromatic.put("P", new Integer(0));
1330 aromatic.put("-", new Integer(1));
1331 aromatic.put("*", new Integer(1));
1336 aliphatic.put("I", new Integer(1));
1337 aliphatic.put("L", new Integer(1));
1338 aliphatic.put("V", new Integer(1));
1339 aliphatic.put("C", new Integer(0));
1340 aliphatic.put("A", new Integer(0));
1341 aliphatic.put("G", new Integer(0));
1342 aliphatic.put("M", new Integer(0));
1343 aliphatic.put("F", new Integer(0));
1344 aliphatic.put("Y", new Integer(0));
1345 aliphatic.put("W", new Integer(0));
1346 aliphatic.put("H", new Integer(0));
1347 aliphatic.put("K", new Integer(0));
1348 aliphatic.put("R", new Integer(0));
1349 aliphatic.put("E", new Integer(0));
1350 aliphatic.put("Q", new Integer(0));
1351 aliphatic.put("D", new Integer(0));
1352 aliphatic.put("N", new Integer(0));
1353 aliphatic.put("S", new Integer(0));
1354 aliphatic.put("T", new Integer(0));
1355 aliphatic.put("P", new Integer(0));
1356 aliphatic.put("-", new Integer(1));
1357 aliphatic.put("*", new Integer(1));
1362 tiny.put("I", new Integer(0));
1363 tiny.put("L", new Integer(0));
1364 tiny.put("V", new Integer(0));
1365 tiny.put("C", new Integer(0));
1366 tiny.put("A", new Integer(1));
1367 tiny.put("G", new Integer(1));
1368 tiny.put("M", new Integer(0));
1369 tiny.put("F", new Integer(0));
1370 tiny.put("Y", new Integer(0));
1371 tiny.put("W", new Integer(0));
1372 tiny.put("H", new Integer(0));
1373 tiny.put("K", new Integer(0));
1374 tiny.put("R", new Integer(0));
1375 tiny.put("E", new Integer(0));
1376 tiny.put("Q", new Integer(0));
1377 tiny.put("D", new Integer(0));
1378 tiny.put("N", new Integer(0));
1379 tiny.put("S", new Integer(1));
1380 tiny.put("T", new Integer(0));
1381 tiny.put("P", new Integer(0));
1382 tiny.put("-", new Integer(1));
1383 tiny.put("*", new Integer(1));
1388 proline.put("I", new Integer(0));
1389 proline.put("L", new Integer(0));
1390 proline.put("V", new Integer(0));
1391 proline.put("C", new Integer(0));
1392 proline.put("A", new Integer(0));
1393 proline.put("G", new Integer(0));
1394 proline.put("M", new Integer(0));
1395 proline.put("F", new Integer(0));
1396 proline.put("Y", new Integer(0));
1397 proline.put("W", new Integer(0));
1398 proline.put("H", new Integer(0));
1399 proline.put("K", new Integer(0));
1400 proline.put("R", new Integer(0));
1401 proline.put("E", new Integer(0));
1402 proline.put("Q", new Integer(0));
1403 proline.put("D", new Integer(0));
1404 proline.put("N", new Integer(0));
1405 proline.put("S", new Integer(0));
1406 proline.put("T", new Integer(0));
1407 proline.put("P", new Integer(1));
1408 proline.put("-", new Integer(1));
1409 proline.put("*", new Integer(1));
1414 propHash.put("hydrophobic", hydrophobic);
1415 propHash.put("small", small);
1416 propHash.put("positive", positive);
1417 propHash.put("negative", negative);
1418 propHash.put("charged", charged);
1419 propHash.put("aromatic", aromatic);
1420 propHash.put("aliphatic", aliphatic);
1421 propHash.put("tiny", tiny);
1422 propHash.put("proline", proline);
1423 propHash.put("polar", polar);
1427 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1428 for (int i = 0; i < maxProteinIndex; i++)
1430 int maxF = 0, maxP = 0, maxEP = 0;
1440 for (int j = i + 1; j < maxProteinIndex; j++)
1451 propMatrixF[i][j] = 0;
1452 propMatrixPos[i][j] = 0;
1453 propMatrixEpos[i][j] = 0;
1454 for (Enumeration<String> en = (Enumeration<String>) propHash.keys(); en
1455 .hasMoreElements();)
1457 String ph = en.nextElement();
1458 Map<String, Integer> pph = (Map<String, Integer>) propHash
1460 if (pph.get(ic) != null && pph.get(jc) != null)
1462 int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1463 // Still working on these definitions.
1464 propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1465 propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1466 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1467 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1468 propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1469 propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1472 if (maxF < propMatrixF[i][j])
1474 maxF = propMatrixF[i][j];
1476 if (maxP < propMatrixPos[i][j])
1478 maxP = propMatrixPos[i][j];
1480 if (maxEP < propMatrixEpos[i][j])
1482 maxEP = propMatrixEpos[i][j];
1485 propMatrixF[i][i] = maxF;
1486 propMatrixPos[i][i] = maxP;
1487 propMatrixEpos[i][i] = maxEP;
1489 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1490 // scoreMatrices.put("Conservation Pos", new
1491 // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1492 // scoreMatrices.put("Conservation Both", new
1493 // ScoreMatrix("Conservation Both",propMatrixF,0));
1494 // scoreMatrices.put("Conservation EnhPos", new
1495 // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1496 scoreMatrices.put("PID", new PIDScoreModel());
1499 private ResidueProperties()
1503 public static double getHydmax()
1508 public static double getHydmin()
1513 public static double[] getHyd()
1518 public static Hashtable getAA3Hash()
1523 public static int[][] getDNA()
1525 return ResidueProperties.DNA;
1528 public static int[][] getBLOSUM62()
1530 return ResidueProperties.BLOSUM62;
1533 public static int getPAM250(String A1, String A2)
1535 return getPAM250(A1.charAt(0), A2.charAt(0));
1538 public static int getBLOSUM62(char c1, char c2)
1544 int a = aaIndex[c1];
1545 int b = aaIndex[c2];
1547 pog = ResidueProperties.BLOSUM62[a][b];
1548 } catch (Exception e)
1550 // System.out.println("Unknown residue in " + A1 + " " + A2);
1556 public static Vector getCodons(String res)
1558 if (codonHash.containsKey(res))
1560 return (Vector) codonHash.get(res);
1566 public static String codonTranslate(String lccodon)
1570 return _codonTranslate(lccodon);
1572 String cdn = codonHash2.get(lccodon.toUpperCase());
1573 if (cdn != null && cdn.equals("*"))
1580 public static String _codonTranslate(String lccodon)
1582 String codon = lccodon.toUpperCase();
1583 // all base ambiguity codes yield an 'X' amino acid residue
1584 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1588 Enumeration e = codonHash.keys();
1590 while (e.hasMoreElements())
1592 String key = (String) e.nextElement();
1593 Vector tmp = (Vector) codonHash.get(key);
1595 if (tmp.contains(codon))
1604 public static int[][] getDefaultPeptideMatrix()
1606 return ResidueProperties.getBLOSUM62();
1609 public static int[][] getDefaultDnaMatrix()
1611 return ResidueProperties.getDNA();
1615 * get a ScoreMatrix based on its string name
1618 * @return matrix in scoreMatrices with key pwtype or null
1620 public static ScoreMatrix getScoreMatrix(String pwtype)
1622 Object val = scoreMatrices.get(pwtype);
1623 if (val != null && val instanceof ScoreMatrix)
1625 return (ScoreMatrix) val;
1631 * get a ScoreModel based on its string name
1634 * @return scoremodel of type pwtype or null
1636 public static ScoreModelI getScoreModel(String pwtype)
1638 return scoreMatrices.get(pwtype);
1641 public static int getPAM250(char c, char d)
1646 int pog = ResidueProperties.PAM250[a][b];
1651 public static Hashtable toDssp3State;
1654 toDssp3State = new Hashtable();
1655 toDssp3State.put("H", "H");
1656 toDssp3State.put("E", "E");
1657 toDssp3State.put("C", " ");
1658 toDssp3State.put(" ", " ");
1659 toDssp3State.put("T", " ");
1660 toDssp3State.put("B", "E");
1661 toDssp3State.put("G", "H");
1662 toDssp3State.put("I", "H");
1663 toDssp3State.put("X", " ");
1667 * translate from other dssp secondary structure alphabets to 3-state
1670 * @return ssstring as a three-state secondary structure assignment.
1672 public static String getDssp3state(String ssstring)
1674 if (ssstring == null)
1678 StringBuffer ss = new StringBuffer();
1679 for (int i = 0; i < ssstring.length(); i++)
1681 String ssc = ssstring.substring(i, i + 1);
1682 if (toDssp3State.containsKey(ssc))
1684 ss.append((String) toDssp3State.get(ssc));
1691 return ss.toString();
1695 * Used by getRNASecStrucState
1698 public static Hashtable toRNAssState;
1701 toRNAssState = new Hashtable<String, String>();
1702 toRNAssState.put(")", "(");
1703 toRNAssState.put("(", "(");
1704 toRNAssState.put("]", "[");
1705 toRNAssState.put("[", "[");
1706 toRNAssState.put("{", "{");
1707 toRNAssState.put("}", "{");
1708 toRNAssState.put(">", ">");
1709 toRNAssState.put("<", ">");
1710 toRNAssState.put("A", "A");
1711 toRNAssState.put("a", "A");
1712 toRNAssState.put("B", "B");
1713 toRNAssState.put("b", "B");
1714 toRNAssState.put("C", "C");
1715 toRNAssState.put("c", "C");
1716 toRNAssState.put("D", "D");
1717 toRNAssState.put("d", "D");
1718 toRNAssState.put("E", "E");
1719 toRNAssState.put("e", "E");
1720 toRNAssState.put("F", "F");
1721 toRNAssState.put("f", "F");
1722 toRNAssState.put("G", "G");
1723 toRNAssState.put("g", "G");
1724 toRNAssState.put("H", "H");
1725 toRNAssState.put("h", "H");
1726 toRNAssState.put("I", "I");
1727 toRNAssState.put("i", "I");
1728 toRNAssState.put("J", "J");
1729 toRNAssState.put("j", "J");
1730 toRNAssState.put("K", "K");
1731 toRNAssState.put("k", "K");
1732 toRNAssState.put("L", "L");
1733 toRNAssState.put("l", "L");
1734 toRNAssState.put("M", "M");
1735 toRNAssState.put("m", "M");
1736 toRNAssState.put("N", "N");
1737 toRNAssState.put("n", "N");
1738 toRNAssState.put("O", "O");
1739 toRNAssState.put("o", "O");
1740 toRNAssState.put("P", "P");
1741 toRNAssState.put("p", "P");
1742 toRNAssState.put("Q", "Q");
1743 toRNAssState.put("q", "Q");
1744 toRNAssState.put("R", "R");
1745 toRNAssState.put("r", "R");
1746 toRNAssState.put("S", "S");
1747 toRNAssState.put("s", "S");
1748 toRNAssState.put("T", "T");
1749 toRNAssState.put("t", "T");
1750 toRNAssState.put("U", "U");
1751 toRNAssState.put("u", "U");
1752 toRNAssState.put("V", "V");
1753 toRNAssState.put("v", "V");
1754 toRNAssState.put("W", "W");
1755 toRNAssState.put("w", "W");
1756 toRNAssState.put("X", "X");
1757 toRNAssState.put("x", "X");
1758 toRNAssState.put("Y", "Y");
1759 toRNAssState.put("y", "Y");
1760 toRNAssState.put("Z", "Z");
1761 toRNAssState.put("z", "Z");
1766 * translate to RNA secondary structure representation
1769 * @return ssstring as a RNA-state secondary structure assignment.
1771 public static String getRNASecStrucState(String ssstring)
1773 if (ssstring == null)
1777 StringBuffer ss = new StringBuffer();
1778 for (int i = 0; i < ssstring.length(); i++)
1780 String ssc = ssstring.substring(i, i + 1);
1781 if (toRNAssState.containsKey(ssc))
1783 ss.append((String) toRNAssState.get(ssc));
1790 return ss.toString();
1793 // main method generates perl representation of residue property hash
1795 public static void main(String[] args)
1797 Hashtable aa = new Hashtable();
1798 System.out.println("my %aa = {");
1799 // invert property hashes
1800 Enumeration prop = propHash.keys();
1801 while (prop.hasMoreElements())
1803 String pname = (String) prop.nextElement();
1804 Hashtable phash = (Hashtable) propHash.get(pname);
1805 Enumeration res = phash.keys();
1806 while (res.hasMoreElements())
1808 String rname = (String) res.nextElement();
1809 Vector aprops = (Vector) aa.get(rname);
1812 aprops = new Vector();
1813 aa.put(rname, aprops);
1815 Integer hasprop = (Integer) phash.get(rname);
1816 if (hasprop.intValue() == 1)
1818 aprops.addElement(pname);
1822 Enumeration res = aa.keys();
1823 while (res.hasMoreElements())
1825 String rname = (String) res.nextElement();
1827 System.out.print("'" + rname + "' => [");
1828 Enumeration props = ((Vector) aa.get(rname)).elements();
1829 while (props.hasMoreElements())
1831 System.out.print("'" + (String) props.nextElement() + "'");
1832 if (props.hasMoreElements())
1834 System.out.println(", ");
1837 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1839 System.out.println("};");