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[]>();
704 * Codon triplets with additional symbols for unambiguous codons that include ambiguity codes
706 public static final Hashtable<String,String> codonHash2 = new Hashtable<String,String>();
709 * all ambiguity codes for a given base
711 public final static Hashtable<String,List<String>> _ambiguityCodes = new Hashtable<String,List<String>>();
717 * 3.2. Purine (adenine or guanine): R
719 * R is the symbol previously recommended [1].
721 ambiguityCodes.put("R", new String[]
725 * 3.3. Pyrimidine (thymine or cytosine): Y
727 * Y is the symbol previously recommended [1].
729 ambiguityCodes.put("Y", new String[]
732 * 3.4. Adenine or thymine: W
734 * Although several diverse symbols have been used for this pair, (and for
735 * the reciprocal pair G+C), only two symbols have a rational basis, L and
736 * W: L derives from DNA density (light; G+C - heavy - would thus be H); W
737 * derives from the strength of the hydrogen bonding interaction between the
738 * base pairs (weak for A+T: G +C - strong - would thus be S). However, the
739 * system recommended for the three-base series (not-A = B, etc., see below,
740 * section 3.8) rules out H as this would be not-G. W is thus recommended.
742 ambiguityCodes.put("W", new String[]
745 * 3.5. Guanine or cytosine: S
747 * The choice of this symbol is discussed above in section 3.4.
749 ambiguityCodes.put("S", new String[]
752 * 3.6. Adenine or cytosine: M
754 * There are few common features between A and C. The presence of an NH2
755 * group in similar positions on both bases (Fig. 1) makes possible a
756 * logically derived symbol. A and N being ruled out, M (from aMino) is
760 * Fig. 1. Origin of the symbols M and K The four bases are drawn so as to
761 * show the relationship between adenine and cytosine on the one hand, which
762 * both have aMino groups at the ring position most distant from the point
763 * of attachment to the sugar, and between guanine and thymine on the other,
764 * which both have Keto groups at the corresponding position. The ring atoms
765 * are numbered as recommended [24-26], although for the present purpose
766 * this has the disadvantage of giving discordant numbers to the
767 * corresponding positions.
769 ambiguityCodes.put("M", new String[]
772 * 3.7. Guanine or thymine: K By analogy with A and C (section 3.6), both G
773 * and T have Keto groups in similar positions (Fig. 1).
775 ambiguityCodes.put("K", new String[]
778 * 3.8. Adenine or thymine or cytosine: H
780 * Not-G is the most simple means of memorising this combination and symbols
781 * logically related to G were examined. F and H would both be suitable, as
782 * the letters before and after G in the alphabet, but A would have no
783 * equivalent to F. The use of H has historical precedence [2].
785 ambiguityCodes.put("H", new String[]
788 * 3.9. Guanine or cytosine or thymine: B
790 * Not-A as above (section 3.8).
792 ambiguityCodes.put("B", new String[]
795 * 3.10. Guanine or adenine or cytosine: V
797 * Not-T by analogy with not-G (section 3.8) would be U but this is ruled
798 * out to eliminate confusion with uracil. V is the next logical choice.
799 * Note that T and U may in some cases be considered to be synonyms.
801 ambiguityCodes.put("V", new String[]
804 * 3.11. Guanine or adenine or thymine: D
806 * Not-C as above (section 3.8).
808 ambiguityCodes.put("D", new String[]
811 * 3.12. Guanine or adenine or thymine or cytosine: N
813 ambiguityCodes.put("R", new String[]
814 { "G", "A", "T", "C" });
815 // Now build codon translation table
816 codonHash2.put("AAA", "K");
817 codonHash2.put("AAG", "K");
818 codonHash2.put("AAC", "N");
819 codonHash2.put("AAT", "N");
821 codonHash2.put("CAA", "Q");
822 codonHash2.put("CAG", "Q");
823 codonHash2.put("CAC", "H");
824 codonHash2.put("CAT", "H");
826 codonHash2.put("GAA", "E");
827 codonHash2.put("GAG", "E");
828 codonHash2.put("GAC", "D");
829 codonHash2.put("GAT", "D");
831 codonHash2.put("TAC", "Y");
832 codonHash2.put("TAT", "Y");
834 codonHash2.put("ACA", "T");
835 codonHash2.put("ACC", "T");
836 codonHash2.put("ACT", "T");
837 codonHash2.put("ACG", "T");
839 codonHash2.put("CCA", "P");
840 codonHash2.put("CCG", "P");
841 codonHash2.put("CCC", "P");
842 codonHash2.put("CCT", "P");
844 codonHash2.put("GCA", "A");
845 codonHash2.put("GCG", "A");
846 codonHash2.put("GCC", "A");
847 codonHash2.put("GCT", "A");
849 codonHash2.put("TCA", "S");
850 codonHash2.put("TCG", "S");
851 codonHash2.put("TCC", "S");
852 codonHash2.put("TCT", "S");
853 codonHash2.put("AGC", "S");
854 codonHash2.put("AGT", "S");
856 codonHash2.put("AGA", "R");
857 codonHash2.put("AGG", "R");
858 codonHash2.put("CGA", "R");
859 codonHash2.put("CGG", "R");
860 codonHash2.put("CGC", "R");
861 codonHash2.put("CGT", "R");
863 codonHash2.put("GGA", "G");
864 codonHash2.put("GGG", "G");
865 codonHash2.put("GGC", "G");
866 codonHash2.put("GGT", "G");
868 codonHash2.put("TGA", "*");
869 codonHash2.put("TAA", "*");
870 codonHash2.put("TAG", "*");
872 codonHash2.put("TGG", "W");
874 codonHash2.put("TGC", "C");
875 codonHash2.put("TGT", "C");
877 codonHash2.put("ATA", "I");
878 codonHash2.put("ATC", "I");
879 codonHash2.put("ATT", "I");
881 codonHash2.put("ATG", "M");
883 codonHash2.put("CTA", "L");
884 codonHash2.put("CTG", "L");
885 codonHash2.put("CTC", "L");
886 codonHash2.put("CTT", "L");
887 codonHash2.put("TTA", "L");
888 codonHash2.put("TTG", "L");
890 codonHash2.put("GTA", "V");
891 codonHash2.put("GTG", "V");
892 codonHash2.put("GTC", "V");
893 codonHash2.put("GTT", "V");
895 codonHash2.put("TTC", "F");
896 codonHash2.put("TTT", "F");
898 buildAmbiguityCodonSet();
902 * programmatic generation of codons including ambiguity codes
904 public static void buildAmbiguityCodonSet()
906 if (_ambiguityCodes.size() > 0)
909 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
912 // Invert the ambiguity code set
913 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
915 for (String r : acode.getValue())
917 List<String> codesfor = _ambiguityCodes.get(r);
918 if (codesfor == null)
920 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
922 if (!codesfor.contains(acode.getKey()))
924 codesfor.add(acode.getKey());
929 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
930 + acode.getKey() + " in residue " + r);
934 // and programmatically add in the ambiguity codes that yield the same amino
936 String[] unambcodons = codonHash2.keySet().toArray(new String[codonHash2.size()]);
937 for (String codon : unambcodons)
939 String residue = codonHash2.get(codon);
940 String acodon[][] = new String[codon.length()][];
941 for (int i = 0, iSize = codon.length(); i < iSize; i++)
943 String _ac = "" + codon.charAt(i);
944 List<String> acodes = _ambiguityCodes.get(_ac);
947 acodon[i] = acodes.toArray(new String[acodes.size()]);
951 acodon[i] = new String[]
955 // enumerate all combinations and test for veracity of translation
956 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
957 for (int i = 0; i < tpos.length; i++)
961 tpos[acodon.length - 1] = 0;
963 while (tpos[0] < acodon[0].length)
965 // make all codons for this combination
966 char allres[][] = new char[tpos.length][];
969 for (ipos = 0; ipos < tpos.length; ipos++)
971 if (acodon[ipos].length==0 || tpos[ipos] < 0)
973 _acodon += codon.charAt(ipos);
974 allres[ipos] = new char[]
975 { codon.charAt(ipos) };
979 _acodon += acodon[ipos][tpos[ipos]];
980 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
981 allres[ipos] = new char[altbase.length];
983 for (String ab : altbase)
985 allres[ipos][j++] = ab.charAt(0);
989 // test all codons for this combination
990 for (ipos = 0; ipos < cpos.length; ipos++)
994 boolean valid = true;
998 for (j = 0; j < cpos.length; j++)
1000 _codon += allres[j][cpos[j]];
1002 String tr = codonHash2.get(_codon);
1003 if (valid = (tr!=null && tr.equals(residue)))
1005 // advance to next combination
1006 ipos = acodon.length - 1;
1007 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
1013 } while (valid && cpos[0] < allres[0].length);
1016 // Add this to the set of codons we will translate
1017 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
1019 codonHash2.put(_acodon, residue);
1023 // System.err.println("Rejecting ambiguity codon: " + _acodon
1024 // + " for " + residue);
1027 ipos = acodon.length - 1;
1028 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1040 Lys.addElement("AAA");
1041 Lys.addElement("AAG");
1042 Asn.addElement("AAC");
1043 Asn.addElement("AAT");
1045 Gln.addElement("CAA");
1046 Gln.addElement("CAG");
1047 His.addElement("CAC");
1048 His.addElement("CAT");
1050 Glu.addElement("GAA");
1051 Glu.addElement("GAG");
1052 Asp.addElement("GAC");
1053 Asp.addElement("GAT");
1055 Tyr.addElement("TAC");
1056 Tyr.addElement("TAT");
1058 Thr.addElement("ACA");
1059 Thr.addElement("ACG");
1060 Thr.addElement("ACC");
1061 Thr.addElement("ACT");
1063 Pro.addElement("CCA");
1064 Pro.addElement("CCG");
1065 Pro.addElement("CCC");
1066 Pro.addElement("CCT");
1068 Ala.addElement("GCA");
1069 Ala.addElement("GCG");
1070 Ala.addElement("GCC");
1071 Ala.addElement("GCT");
1073 Ser.addElement("TCA");
1074 Ser.addElement("TCG");
1075 Ser.addElement("TCC");
1076 Ser.addElement("TCT");
1077 Ser.addElement("AGC");
1078 Ser.addElement("AGT");
1080 Arg.addElement("AGA");
1081 Arg.addElement("AGG");
1082 Arg.addElement("CGA");
1083 Arg.addElement("CGG");
1084 Arg.addElement("CGC");
1085 Arg.addElement("CGT");
1087 Gly.addElement("GGA");
1088 Gly.addElement("GGG");
1089 Gly.addElement("GGC");
1090 Gly.addElement("GGT");
1092 STOP.addElement("TGA");
1093 STOP.addElement("TAA");
1094 STOP.addElement("TAG");
1096 Trp.addElement("TGG");
1098 Cys.addElement("TGC");
1099 Cys.addElement("TGT");
1101 Ile.addElement("ATA");
1102 Ile.addElement("ATC");
1103 Ile.addElement("ATT");
1105 Met.addElement("ATG");
1107 Leu.addElement("CTA");
1108 Leu.addElement("CTG");
1109 Leu.addElement("CTC");
1110 Leu.addElement("CTT");
1111 Leu.addElement("TTA");
1112 Leu.addElement("TTG");
1114 Val.addElement("GTA");
1115 Val.addElement("GTG");
1116 Val.addElement("GTC");
1117 Val.addElement("GTT");
1119 Phe.addElement("TTC");
1120 Phe.addElement("TTT");
1123 // Stores residue codes/names and colours and other things
1124 public static Hashtable propHash = new Hashtable();
1126 public static Hashtable hydrophobic = new Hashtable();
1128 public static Hashtable polar = new Hashtable();
1130 public static Hashtable small = new Hashtable();
1132 public static Hashtable positive = new Hashtable();
1134 public static Hashtable negative = new Hashtable();
1136 public static Hashtable charged = new Hashtable();
1138 public static Hashtable aromatic = new Hashtable();
1140 public static Hashtable aliphatic = new Hashtable();
1142 public static Hashtable tiny = new Hashtable();
1144 public static Hashtable proline = new Hashtable();
1148 hydrophobic.put("I", new Integer(1));
1149 hydrophobic.put("L", new Integer(1));
1150 hydrophobic.put("V", new Integer(1));
1151 hydrophobic.put("C", new Integer(1));
1152 hydrophobic.put("A", new Integer(1));
1153 hydrophobic.put("G", new Integer(1));
1154 hydrophobic.put("M", new Integer(1));
1155 hydrophobic.put("F", new Integer(1));
1156 hydrophobic.put("Y", new Integer(1));
1157 hydrophobic.put("W", new Integer(1));
1158 hydrophobic.put("H", new Integer(1));
1159 hydrophobic.put("K", new Integer(1));
1160 hydrophobic.put("X", new Integer(1));
1161 hydrophobic.put("-", new Integer(1));
1162 hydrophobic.put("*", new Integer(1));
1163 hydrophobic.put("R", new Integer(0));
1164 hydrophobic.put("E", new Integer(0));
1165 hydrophobic.put("Q", new Integer(0));
1166 hydrophobic.put("D", new Integer(0));
1167 hydrophobic.put("N", new Integer(0));
1168 hydrophobic.put("S", new Integer(0));
1169 hydrophobic.put("T", new Integer(0));
1170 hydrophobic.put("P", new Integer(0));
1175 polar.put("Y", new Integer(1));
1176 polar.put("W", new Integer(1));
1177 polar.put("H", new Integer(1));
1178 polar.put("K", new Integer(1));
1179 polar.put("R", new Integer(1));
1180 polar.put("E", new Integer(1));
1181 polar.put("Q", new Integer(1));
1182 polar.put("D", new Integer(1));
1183 polar.put("N", new Integer(1));
1184 polar.put("S", new Integer(1));
1185 polar.put("T", new Integer(1));
1186 polar.put("X", new Integer(1));
1187 polar.put("-", new Integer(1));
1188 polar.put("*", new Integer(1));
1189 polar.put("I", new Integer(0));
1190 polar.put("L", new Integer(0));
1191 polar.put("V", new Integer(0));
1192 polar.put("C", new Integer(0));
1193 polar.put("A", new Integer(0));
1194 polar.put("G", new Integer(0));
1195 polar.put("M", new Integer(0));
1196 polar.put("F", new Integer(0));
1197 polar.put("P", new Integer(0));
1202 small.put("I", new Integer(0));
1203 small.put("L", new Integer(0));
1204 small.put("V", new Integer(1));
1205 small.put("C", new Integer(1));
1206 small.put("A", new Integer(1));
1207 small.put("G", new Integer(1));
1208 small.put("M", new Integer(0));
1209 small.put("F", new Integer(0));
1210 small.put("Y", new Integer(0));
1211 small.put("W", new Integer(0));
1212 small.put("H", new Integer(0));
1213 small.put("K", new Integer(0));
1214 small.put("R", new Integer(0));
1215 small.put("E", new Integer(0));
1216 small.put("Q", new Integer(0));
1217 small.put("D", new Integer(1));
1218 small.put("N", new Integer(1));
1219 small.put("S", new Integer(1));
1220 small.put("T", new Integer(1));
1221 small.put("P", new Integer(1));
1222 small.put("-", new Integer(1));
1223 small.put("*", new Integer(1));
1228 positive.put("I", new Integer(0));
1229 positive.put("L", new Integer(0));
1230 positive.put("V", new Integer(0));
1231 positive.put("C", new Integer(0));
1232 positive.put("A", new Integer(0));
1233 positive.put("G", new Integer(0));
1234 positive.put("M", new Integer(0));
1235 positive.put("F", new Integer(0));
1236 positive.put("Y", new Integer(0));
1237 positive.put("W", new Integer(0));
1238 positive.put("H", new Integer(1));
1239 positive.put("K", new Integer(1));
1240 positive.put("R", new Integer(1));
1241 positive.put("E", new Integer(0));
1242 positive.put("Q", new Integer(0));
1243 positive.put("D", new Integer(0));
1244 positive.put("N", new Integer(0));
1245 positive.put("S", new Integer(0));
1246 positive.put("T", new Integer(0));
1247 positive.put("P", new Integer(0));
1248 positive.put("-", new Integer(1));
1249 positive.put("*", new Integer(1));
1254 negative.put("I", new Integer(0));
1255 negative.put("L", new Integer(0));
1256 negative.put("V", new Integer(0));
1257 negative.put("C", new Integer(0));
1258 negative.put("A", new Integer(0));
1259 negative.put("G", new Integer(0));
1260 negative.put("M", new Integer(0));
1261 negative.put("F", new Integer(0));
1262 negative.put("Y", new Integer(0));
1263 negative.put("W", new Integer(0));
1264 negative.put("H", new Integer(0));
1265 negative.put("K", new Integer(0));
1266 negative.put("R", new Integer(0));
1267 negative.put("E", new Integer(1));
1268 negative.put("Q", new Integer(0));
1269 negative.put("D", new Integer(1));
1270 negative.put("N", new Integer(0));
1271 negative.put("S", new Integer(0));
1272 negative.put("T", new Integer(0));
1273 negative.put("P", new Integer(0));
1274 negative.put("-", new Integer(1));
1275 negative.put("*", new Integer(1));
1280 charged.put("I", new Integer(0));
1281 charged.put("L", new Integer(0));
1282 charged.put("V", new Integer(0));
1283 charged.put("C", new Integer(0));
1284 charged.put("A", new Integer(0));
1285 charged.put("G", new Integer(0));
1286 charged.put("M", new Integer(0));
1287 charged.put("F", new Integer(0));
1288 charged.put("Y", new Integer(0));
1289 charged.put("W", new Integer(0));
1290 charged.put("H", new Integer(1));
1291 charged.put("K", new Integer(1));
1292 charged.put("R", new Integer(1));
1293 charged.put("E", new Integer(1));
1294 charged.put("Q", new Integer(0));
1295 charged.put("D", new Integer(1));
1296 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1297 // Alternative would be charged and
1298 // negative (in basic form)?
1299 charged.put("S", new Integer(0));
1300 charged.put("T", new Integer(0));
1301 charged.put("P", new Integer(0));
1302 charged.put("-", new Integer(1));
1303 charged.put("*", new Integer(1));
1308 aromatic.put("I", new Integer(0));
1309 aromatic.put("L", new Integer(0));
1310 aromatic.put("V", new Integer(0));
1311 aromatic.put("C", new Integer(0));
1312 aromatic.put("A", new Integer(0));
1313 aromatic.put("G", new Integer(0));
1314 aromatic.put("M", new Integer(0));
1315 aromatic.put("F", new Integer(1));
1316 aromatic.put("Y", new Integer(1));
1317 aromatic.put("W", new Integer(1));
1318 aromatic.put("H", new Integer(1));
1319 aromatic.put("K", new Integer(0));
1320 aromatic.put("R", new Integer(0));
1321 aromatic.put("E", new Integer(0));
1322 aromatic.put("Q", new Integer(0));
1323 aromatic.put("D", new Integer(0));
1324 aromatic.put("N", new Integer(0));
1325 aromatic.put("S", new Integer(0));
1326 aromatic.put("T", new Integer(0));
1327 aromatic.put("P", new Integer(0));
1328 aromatic.put("-", new Integer(1));
1329 aromatic.put("*", new Integer(1));
1334 aliphatic.put("I", new Integer(1));
1335 aliphatic.put("L", new Integer(1));
1336 aliphatic.put("V", new Integer(1));
1337 aliphatic.put("C", new Integer(0));
1338 aliphatic.put("A", new Integer(0));
1339 aliphatic.put("G", new Integer(0));
1340 aliphatic.put("M", new Integer(0));
1341 aliphatic.put("F", new Integer(0));
1342 aliphatic.put("Y", new Integer(0));
1343 aliphatic.put("W", new Integer(0));
1344 aliphatic.put("H", new Integer(0));
1345 aliphatic.put("K", new Integer(0));
1346 aliphatic.put("R", new Integer(0));
1347 aliphatic.put("E", new Integer(0));
1348 aliphatic.put("Q", new Integer(0));
1349 aliphatic.put("D", new Integer(0));
1350 aliphatic.put("N", new Integer(0));
1351 aliphatic.put("S", new Integer(0));
1352 aliphatic.put("T", new Integer(0));
1353 aliphatic.put("P", new Integer(0));
1354 aliphatic.put("-", new Integer(1));
1355 aliphatic.put("*", new Integer(1));
1360 tiny.put("I", new Integer(0));
1361 tiny.put("L", new Integer(0));
1362 tiny.put("V", new Integer(0));
1363 tiny.put("C", new Integer(0));
1364 tiny.put("A", new Integer(1));
1365 tiny.put("G", new Integer(1));
1366 tiny.put("M", new Integer(0));
1367 tiny.put("F", new Integer(0));
1368 tiny.put("Y", new Integer(0));
1369 tiny.put("W", new Integer(0));
1370 tiny.put("H", new Integer(0));
1371 tiny.put("K", new Integer(0));
1372 tiny.put("R", new Integer(0));
1373 tiny.put("E", new Integer(0));
1374 tiny.put("Q", new Integer(0));
1375 tiny.put("D", new Integer(0));
1376 tiny.put("N", new Integer(0));
1377 tiny.put("S", new Integer(1));
1378 tiny.put("T", new Integer(0));
1379 tiny.put("P", new Integer(0));
1380 tiny.put("-", new Integer(1));
1381 tiny.put("*", new Integer(1));
1386 proline.put("I", new Integer(0));
1387 proline.put("L", new Integer(0));
1388 proline.put("V", new Integer(0));
1389 proline.put("C", new Integer(0));
1390 proline.put("A", new Integer(0));
1391 proline.put("G", new Integer(0));
1392 proline.put("M", new Integer(0));
1393 proline.put("F", new Integer(0));
1394 proline.put("Y", new Integer(0));
1395 proline.put("W", new Integer(0));
1396 proline.put("H", new Integer(0));
1397 proline.put("K", new Integer(0));
1398 proline.put("R", new Integer(0));
1399 proline.put("E", new Integer(0));
1400 proline.put("Q", new Integer(0));
1401 proline.put("D", new Integer(0));
1402 proline.put("N", new Integer(0));
1403 proline.put("S", new Integer(0));
1404 proline.put("T", new Integer(0));
1405 proline.put("P", new Integer(1));
1406 proline.put("-", new Integer(1));
1407 proline.put("*", new Integer(1));
1412 propHash.put("hydrophobic", hydrophobic);
1413 propHash.put("small", small);
1414 propHash.put("positive", positive);
1415 propHash.put("negative", negative);
1416 propHash.put("charged", charged);
1417 propHash.put("aromatic", aromatic);
1418 propHash.put("aliphatic", aliphatic);
1419 propHash.put("tiny", tiny);
1420 propHash.put("proline", proline);
1421 propHash.put("polar", polar);
1425 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex],
1426 propMatrixPos = new int[maxProteinIndex][maxProteinIndex],
1427 propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1428 for (int i=0;i<maxProteinIndex;i++)
1430 int maxF=0,maxP=0,maxEP=0;
1436 for (int j=i+1;j<maxProteinIndex; j++)
1443 propMatrixF[i][j]=0;
1444 propMatrixPos[i][j]=0;
1445 propMatrixEpos[i][j]=0;
1446 for (Enumeration<String> en= (Enumeration<String>)propHash.keys(); en.hasMoreElements(); )
1448 String ph = en.nextElement();
1449 Map<String,Integer> pph=(Map<String,Integer>)propHash.get(ph);
1450 if (pph.get(ic)!=null && pph.get(jc)!=null) {
1451 int icp=pph.get(ic).intValue(),jcp=pph.get(jc).intValue();
1452 // Still working on these definitions.
1453 propMatrixPos[i][j] += icp == jcp && icp>0 ? 2 : 0;
1454 propMatrixPos[j][i] += icp == jcp && icp>0 ? 2 : 0;
1455 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1456 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1457 propMatrixEpos[i][j] += icp == jcp ? (1+icp * 2) : 0;
1458 propMatrixEpos[j][i] += icp == jcp ? (1+icp * 2) : 0;
1460 if (maxF<propMatrixF[i][j])
1462 maxF=propMatrixF[i][j];
1464 if (maxP<propMatrixPos[i][j])
1466 maxP=propMatrixPos[i][j];
1468 if (maxEP<propMatrixEpos[i][j])
1470 maxEP=propMatrixEpos[i][j];
1473 propMatrixF[i][i]=maxF;
1474 propMatrixPos[i][i]=maxP;
1475 propMatrixEpos[i][i]=maxEP;
1477 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1478 //scoreMatrices.put("Conservation Pos", new ScoreMatrix("Conservation Pos",propMatrixPos,0));
1479 //scoreMatrices.put("Conservation Both", new ScoreMatrix("Conservation Both",propMatrixF,0));
1480 //scoreMatrices.put("Conservation EnhPos", new ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1481 scoreMatrices.put("PID", new PIDScoreModel());
1484 private ResidueProperties()
1488 public static double getHydmax()
1493 public static double getHydmin()
1498 public static double[] getHyd()
1503 public static Hashtable getAA3Hash()
1508 public static int[][] getDNA()
1510 return ResidueProperties.DNA;
1513 public static int[][] getBLOSUM62()
1515 return ResidueProperties.BLOSUM62;
1518 public static int getPAM250(String A1, String A2)
1520 return getPAM250(A1.charAt(0), A2.charAt(0));
1523 public static int getBLOSUM62(char c1, char c2)
1529 int a = aaIndex[c1];
1530 int b = aaIndex[c2];
1532 pog = ResidueProperties.BLOSUM62[a][b];
1533 } catch (Exception e)
1535 // System.out.println("Unknown residue in " + A1 + " " + A2);
1541 public static Vector getCodons(String res)
1543 if (codonHash.containsKey(res))
1545 return (Vector) codonHash.get(res);
1551 public static String codonTranslate(String lccodon)
1555 return _codonTranslate(lccodon);
1557 String cdn = codonHash2.get(lccodon.toUpperCase());
1558 if (cdn!=null && cdn.equals("*"))
1564 public static String _codonTranslate(String lccodon)
1566 String codon = lccodon.toUpperCase();
1567 // all base ambiguity codes yield an 'X' amino acid residue
1568 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1572 Enumeration e = codonHash.keys();
1574 while (e.hasMoreElements())
1576 String key = (String) e.nextElement();
1577 Vector tmp = (Vector) codonHash.get(key);
1579 if (tmp.contains(codon))
1588 public static int[][] getDefaultPeptideMatrix()
1590 return ResidueProperties.getBLOSUM62();
1593 public static int[][] getDefaultDnaMatrix()
1595 return ResidueProperties.getDNA();
1599 * get a ScoreMatrix based on its string name
1602 * @return matrix in scoreMatrices with key pwtype or null
1604 public static ScoreMatrix getScoreMatrix(String pwtype)
1606 Object val = scoreMatrices.get(pwtype);
1607 if (val != null && val instanceof ScoreMatrix)
1609 return (ScoreMatrix) val;
1614 * get a ScoreModel based on its string name
1617 * @return scoremodel of type pwtype or null
1619 public static ScoreModelI getScoreModel(String pwtype)
1621 return scoreMatrices.get(pwtype);
1624 public static int getPAM250(char c, char d)
1629 int pog = ResidueProperties.PAM250[a][b];
1634 public static Hashtable toDssp3State;
1637 toDssp3State = new Hashtable();
1638 toDssp3State.put("H", "H");
1639 toDssp3State.put("E", "E");
1640 toDssp3State.put("C", " ");
1641 toDssp3State.put(" ", " ");
1642 toDssp3State.put("T", " ");
1643 toDssp3State.put("B", "E");
1644 toDssp3State.put("G", "H");
1645 toDssp3State.put("I", "H");
1646 toDssp3State.put("X", " ");
1650 * translate from other dssp secondary structure alphabets to 3-state
1653 * @return ssstring as a three-state secondary structure assignment.
1655 public static String getDssp3state(String ssstring)
1657 if (ssstring == null)
1661 StringBuffer ss = new StringBuffer();
1662 for (int i = 0; i < ssstring.length(); i++)
1664 String ssc = ssstring.substring(i, i + 1);
1665 if (toDssp3State.containsKey(ssc))
1667 ss.append((String) toDssp3State.get(ssc));
1674 return ss.toString();
1678 * Used by getRNASecStrucState
1681 public static Hashtable toRNAssState;
1684 toRNAssState = new Hashtable<String,String>();
1685 toRNAssState.put(")", "(");
1686 toRNAssState.put("(", "(");
1687 toRNAssState.put("]", "[");
1688 toRNAssState.put("[", "[");
1689 toRNAssState.put("{", "{");
1690 toRNAssState.put("}", "{");
1691 toRNAssState.put(">", ">");
1692 toRNAssState.put("<", ">");
1693 toRNAssState.put("A", "A");
1694 toRNAssState.put("a", "A");
1695 toRNAssState.put("B", "B");
1696 toRNAssState.put("b", "B");
1697 toRNAssState.put("C", "C");
1698 toRNAssState.put("c", "C");
1699 toRNAssState.put("D", "D");
1700 toRNAssState.put("d", "D");
1701 toRNAssState.put("E", "E");
1702 toRNAssState.put("e", "E");
1703 toRNAssState.put("F", "F");
1704 toRNAssState.put("f", "F");
1705 toRNAssState.put("G", "G");
1706 toRNAssState.put("g", "G");
1707 toRNAssState.put("H", "H");
1708 toRNAssState.put("h", "H");
1709 toRNAssState.put("I", "I");
1710 toRNAssState.put("i", "I");
1711 toRNAssState.put("J", "J");
1712 toRNAssState.put("j", "J");
1713 toRNAssState.put("K", "K");
1714 toRNAssState.put("k", "K");
1715 toRNAssState.put("L", "L");
1716 toRNAssState.put("l", "L");
1717 toRNAssState.put("M", "M");
1718 toRNAssState.put("m", "M");
1719 toRNAssState.put("N", "N");
1720 toRNAssState.put("n", "N");
1721 toRNAssState.put("O", "O");
1722 toRNAssState.put("o", "O");
1723 toRNAssState.put("P", "P");
1724 toRNAssState.put("p", "P");
1725 toRNAssState.put("Q", "Q");
1726 toRNAssState.put("q", "Q");
1727 toRNAssState.put("R", "R");
1728 toRNAssState.put("r", "R");
1729 toRNAssState.put("S", "S");
1730 toRNAssState.put("s", "S");
1731 toRNAssState.put("T", "T");
1732 toRNAssState.put("t", "T");
1733 toRNAssState.put("U", "U");
1734 toRNAssState.put("u", "U");
1735 toRNAssState.put("V", "V");
1736 toRNAssState.put("v", "V");
1737 toRNAssState.put("W", "W");
1738 toRNAssState.put("w", "W");
1739 toRNAssState.put("X", "X");
1740 toRNAssState.put("x", "X");
1741 toRNAssState.put("Y", "Y");
1742 toRNAssState.put("y", "Y");
1743 toRNAssState.put("Z", "Z");
1744 toRNAssState.put("z", "Z");
1749 * translate to RNA secondary structure representation
1752 * @return ssstring as a RNA-state secondary structure assignment.
1754 public static String getRNASecStrucState(String ssstring)
1756 if (ssstring == null)
1760 StringBuffer ss = new StringBuffer();
1761 for (int i = 0; i < ssstring.length(); i++)
1763 String ssc = ssstring.substring(i, i + 1);
1764 if (toRNAssState.containsKey(ssc))
1766 ss.append((String) toRNAssState.get(ssc));
1773 return ss.toString();
1776 // main method generates perl representation of residue property hash
1778 public static void main(String[] args)
1780 Hashtable aa = new Hashtable();
1781 System.out.println("my %aa = {");
1782 // invert property hashes
1783 Enumeration prop = propHash.keys();
1784 while (prop.hasMoreElements())
1786 String pname = (String) prop.nextElement();
1787 Hashtable phash = (Hashtable) propHash.get(pname);
1788 Enumeration res = phash.keys();
1789 while (res.hasMoreElements())
1791 String rname = (String) res.nextElement();
1792 Vector aprops = (Vector) aa.get(rname);
1795 aprops = new Vector();
1796 aa.put(rname, aprops);
1798 Integer hasprop = (Integer) phash.get(rname);
1799 if (hasprop.intValue() == 1)
1801 aprops.addElement(pname);
1805 Enumeration res = aa.keys();
1806 while (res.hasMoreElements())
1808 String rname = (String) res.nextElement();
1810 System.out.print("'" + rname + "' => [");
1811 Enumeration props = ((Vector) aa.get(rname)).elements();
1812 while (props.hasMoreElements())
1814 System.out.print("'" + (String) props.nextElement() + "'");
1815 if (props.hasMoreElements())
1817 System.out.println(", ");
1820 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1822 System.out.println("};");