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.FeatureScoreModel;
24 import jalview.analysis.scoremodels.PIDScoreModel;
25 import jalview.api.analysis.ScoreModelI;
27 import java.awt.Color;
28 import java.util.ArrayList;
29 import java.util.Enumeration;
30 import java.util.HashMap;
31 import java.util.Hashtable;
32 import java.util.List;
34 import java.util.Vector;
36 public class ResidueProperties
38 public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable();
40 // Stores residue codes/names and colours and other things
41 public static final int[] aaIndex; // aaHash version 2.1.1 and below
43 public static final int[] nucleotideIndex;
45 public static final int[] purinepyrimidineIndex;
47 public static final Map<String, Integer> aa3Hash = new HashMap<String, Integer>();
49 public static final Map<String, String> aa2Triplet = new HashMap<String, String>();
51 public static final Map<String, String> nucleotideName = new HashMap<String, String>();
55 aaIndex = new int[255];
56 for (int i = 0; i < 255; i++)
108 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
109 // extend subt. matrices
113 * maximum (gap) index for matrices involving protein alphabet
115 public final static int maxProteinIndex = 23;
118 * maximum (gap) index for matrices involving nucleotide alphabet
120 public final static int maxNucleotideIndex = 10;
124 nucleotideIndex = new int[255];
125 for (int i = 0; i < 255; i++)
127 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
130 nucleotideIndex['A'] = 0;
131 nucleotideIndex['a'] = 0;
132 nucleotideIndex['C'] = 1;
133 nucleotideIndex['c'] = 1;
134 nucleotideIndex['G'] = 2;
135 nucleotideIndex['g'] = 2;
136 nucleotideIndex['T'] = 3;
137 nucleotideIndex['t'] = 3;
138 nucleotideIndex['U'] = 4;
139 nucleotideIndex['u'] = 4;
140 nucleotideIndex['I'] = 5;
141 nucleotideIndex['i'] = 5;
142 nucleotideIndex['X'] = 6;
143 nucleotideIndex['x'] = 6;
144 nucleotideIndex['R'] = 7;
145 nucleotideIndex['r'] = 7;
146 nucleotideIndex['Y'] = 8;
147 nucleotideIndex['y'] = 8;
148 nucleotideIndex['N'] = 9;
149 nucleotideIndex['n'] = 9;
151 nucleotideName.put("A", "Adenine");
152 nucleotideName.put("a", "Adenine");
153 nucleotideName.put("G", "Guanine");
154 nucleotideName.put("g", "Guanine");
155 nucleotideName.put("C", "Cytosine");
156 nucleotideName.put("c", "Cytosine");
157 nucleotideName.put("T", "Thymine");
158 nucleotideName.put("t", "Thymine");
159 nucleotideName.put("U", "Uracil");
160 nucleotideName.put("u", "Uracil");
161 nucleotideName.put("I", "Inosine");
162 nucleotideName.put("i", "Inosine");
163 nucleotideName.put("X", "Xanthine");
164 nucleotideName.put("x", "Xanthine");
165 nucleotideName.put("R", "Unknown Purine");
166 nucleotideName.put("r", "Unknown Purine");
167 nucleotideName.put("Y", "Unknown Pyrimidine");
168 nucleotideName.put("y", "Unknown Pyrimidine");
169 nucleotideName.put("N", "Unknown");
170 nucleotideName.put("n", "Unknown");
171 nucleotideName.put("W", "Weak nucleotide (A or T)");
172 nucleotideName.put("w", "Weak nucleotide (A or T)");
173 nucleotideName.put("S", "Strong nucleotide (G or C)");
174 nucleotideName.put("s", "Strong nucleotide (G or C)");
175 nucleotideName.put("M", "Amino (A or C)");
176 nucleotideName.put("m", "Amino (A or C)");
177 nucleotideName.put("K", "Keto (G or T)");
178 nucleotideName.put("k", "Keto (G or T)");
179 nucleotideName.put("B", "Not A (G or C or T)");
180 nucleotideName.put("b", "Not A (G or C or T)");
181 nucleotideName.put("H", "Not G (A or C or T)");
182 nucleotideName.put("h", "Not G (A or C or T)");
183 nucleotideName.put("D", "Not C (A or G or T)");
184 nucleotideName.put("d", "Not C (A or G or T)");
185 nucleotideName.put("V", "Not T (A or G or C");
186 nucleotideName.put("v", "Not T (A or G or C");
192 purinepyrimidineIndex = new int[255];
193 for (int i = 0; i < 255; i++)
195 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
199 purinepyrimidineIndex['A'] = 0;
200 purinepyrimidineIndex['a'] = 0;
201 purinepyrimidineIndex['C'] = 1;
202 purinepyrimidineIndex['c'] = 1;
203 purinepyrimidineIndex['G'] = 0;
204 purinepyrimidineIndex['g'] = 0;
205 purinepyrimidineIndex['T'] = 1;
206 purinepyrimidineIndex['t'] = 1;
207 purinepyrimidineIndex['U'] = 1;
208 purinepyrimidineIndex['u'] = 1;
209 purinepyrimidineIndex['I'] = 2;
210 purinepyrimidineIndex['i'] = 2;
211 purinepyrimidineIndex['X'] = 2;
212 purinepyrimidineIndex['x'] = 2;
213 purinepyrimidineIndex['R'] = 0;
214 purinepyrimidineIndex['r'] = 0;
215 purinepyrimidineIndex['Y'] = 1;
216 purinepyrimidineIndex['y'] = 1;
217 purinepyrimidineIndex['N'] = 2;
218 purinepyrimidineIndex['n'] = 2;
223 aa3Hash.put("ALA", new Integer(0));
224 aa3Hash.put("ARG", new Integer(1));
225 aa3Hash.put("ASN", new Integer(2));
226 aa3Hash.put("ASP", new Integer(3)); // D
227 aa3Hash.put("CYS", new Integer(4));
228 aa3Hash.put("GLN", new Integer(5)); // Q
229 aa3Hash.put("GLU", new Integer(6)); // E
230 aa3Hash.put("GLY", new Integer(7));
231 aa3Hash.put("HIS", new Integer(8));
232 aa3Hash.put("ILE", new Integer(9));
233 aa3Hash.put("LEU", new Integer(10));
234 aa3Hash.put("LYS", new Integer(11));
235 aa3Hash.put("MET", new Integer(12));
236 aa3Hash.put("PHE", new Integer(13));
237 aa3Hash.put("PRO", new Integer(14));
238 aa3Hash.put("SER", new Integer(15));
239 aa3Hash.put("THR", new Integer(16));
240 aa3Hash.put("TRP", new Integer(17));
241 aa3Hash.put("TYR", new Integer(18));
242 aa3Hash.put("VAL", new Integer(19));
243 // IUB Nomenclature for ambiguous peptides
244 aa3Hash.put("ASX", new Integer(20)); // "B";
245 aa3Hash.put("GLX", new Integer(21)); // X
246 aa3Hash.put("XAA", new Integer(22)); // X unknown
247 aa3Hash.put("-", new Integer(23));
248 aa3Hash.put("*", new Integer(23));
249 aa3Hash.put(".", new Integer(23));
250 aa3Hash.put(" ", new Integer(23));
251 aa3Hash.put("Gap", new Integer(23));
256 aa2Triplet.put("A", "ALA");
257 aa2Triplet.put("a", "ALA");
258 aa2Triplet.put("R", "ARG");
259 aa2Triplet.put("r", "ARG");
260 aa2Triplet.put("N", "ASN");
261 aa2Triplet.put("n", "ASN");
262 aa2Triplet.put("D", "ASP");
263 aa2Triplet.put("d", "ASP");
264 aa2Triplet.put("C", "CYS");
265 aa2Triplet.put("c", "CYS");
266 aa2Triplet.put("Q", "GLN");
267 aa2Triplet.put("q", "GLN");
268 aa2Triplet.put("E", "GLU");
269 aa2Triplet.put("e", "GLU");
270 aa2Triplet.put("G", "GLY");
271 aa2Triplet.put("g", "GLY");
272 aa2Triplet.put("H", "HIS");
273 aa2Triplet.put("h", "HIS");
274 aa2Triplet.put("I", "ILE");
275 aa2Triplet.put("i", "ILE");
276 aa2Triplet.put("L", "LEU");
277 aa2Triplet.put("l", "LEU");
278 aa2Triplet.put("K", "LYS");
279 aa2Triplet.put("k", "LYS");
280 aa2Triplet.put("M", "MET");
281 aa2Triplet.put("m", "MET");
282 aa2Triplet.put("F", "PHE");
283 aa2Triplet.put("f", "PHE");
284 aa2Triplet.put("P", "PRO");
285 aa2Triplet.put("p", "PRO");
286 aa2Triplet.put("S", "SER");
287 aa2Triplet.put("s", "SER");
288 aa2Triplet.put("T", "THR");
289 aa2Triplet.put("t", "THR");
290 aa2Triplet.put("W", "TRP");
291 aa2Triplet.put("w", "TRP");
292 aa2Triplet.put("Y", "TYR");
293 aa2Triplet.put("y", "TYR");
294 aa2Triplet.put("V", "VAL");
295 aa2Triplet.put("v", "VAL");
298 public static final String[] aa =
299 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
300 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
302 public static final Color midBlue = new Color(100, 100, 255);
304 public static final Vector scaleColours = new Vector();
308 scaleColours.addElement(new Color(114, 0, 147));
309 scaleColours.addElement(new Color(156, 0, 98));
310 scaleColours.addElement(new Color(190, 0, 0));
311 scaleColours.addElement(Color.red);
312 scaleColours.addElement(new Color(255, 125, 0));
313 scaleColours.addElement(Color.orange);
314 scaleColours.addElement(new Color(255, 194, 85));
315 scaleColours.addElement(Color.yellow);
316 scaleColours.addElement(new Color(255, 255, 181));
317 scaleColours.addElement(Color.white);
320 public static final Color[] taylor =
321 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
322 new Color(0, 0, 255), // R Blueish-bluey-blue
323 new Color(204, 0, 255), // N Blueish-reddy-blue
324 new Color(255, 0, 0), // D Reddish-reddy-red
325 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
326 new Color(255, 0, 204), // Q Reddish-bluey-red
327 new Color(255, 0, 102), // E Blueish-reddy-red
328 new Color(255, 153, 0), // G Yellowy-reddy-yellow
329 new Color(0, 102, 255), // H Greenish-bluey-blue
330 new Color(102, 255, 0), // I Greenish-yellowy-green
331 new Color(51, 255, 0), // L Yellowish-greeny-green
332 new Color(102, 0, 255), // K Reddish-bluey-blue
333 new Color(0, 255, 0), // M Greenish-greeny-green
334 new Color(0, 255, 102), // F Blueish-greeny-green
335 new Color(255, 204, 0), // P Reddish-yellowy-yellow
336 new Color(255, 51, 0), // S Yellowish-reddy-red
337 new Color(255, 102, 0), // T Reddish-yellowy-red
338 new Color(0, 204, 255), // W Blueish-greeny-green
339 new Color(0, 255, 204), // Y Greenish-bluey-green
340 new Color(153, 255, 0), // V Yellowish-greeny-yellow
349 public static final Color[] nucleotide =
350 { new Color(100, 247, 63), // A
351 new Color(255, 179, 64), // C
352 new Color(235, 65, 60), // G
353 new Color(60, 136, 238), // T
354 new Color(60, 136, 238), // U
355 Color.white, // I (inosine)
356 Color.white, // X (xanthine)
363 // Added for PurinePyrimidineColourScheme
364 public static final Color[] purinepyrimidine =
365 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
366 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
367 Color.white, // all other nucleotides
372 public static final Color[] zappo =
381 midBlue,// Color.red, // H
402 // Dunno where I got these numbers from
403 public static final double[] hyd2 =
429 public static final double[] helix =
430 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
431 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
433 public static final double helixmin = 0.57;
435 public static final double helixmax = 1.51;
437 public static final double[] strand =
438 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
439 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
441 public static final double strandmin = 0.37;
443 public static final double strandmax = 1.7;
445 public static final double[] turn =
446 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
447 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
450 public static final double turnmin = 0.47;
452 public static final double turnmax = 1.56;
454 public static final double[] buried =
455 { 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,
456 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
458 public static final double buriedmin = 0.05;
460 public static final double buriedmax = 4.6;
462 // This is hydropathy index
463 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
464 // 1157, 105-132, 1982
465 public static final double[] hyd =
466 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
467 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
469 public static final double hydmax = 4.5;
471 public static final double hydmin = -3.9;
473 // public static final double hydmax = 1.38;
474 // public static final double hydmin = -2.53;
475 private static final int[][] BLOSUM62 =
477 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
478 -2, 0, -2, -1, 0, -4 },
479 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
480 -2, -3, -1, 0, -1, -4 },
481 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
483 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
484 -3, -3, 4, 1, -1, -4 },
485 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
486 -2, -2, -1, -3, -3, -2, -4 },
487 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
489 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
491 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
492 -3, -3, -1, -2, -1, -4 },
493 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
494 2, -3, 0, 0, -1, -4 },
495 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
496 -1, 3, -3, -3, -1, -4 },
497 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
498 -1, 1, -4, -3, -1, -4 },
499 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
500 -2, -2, 0, 1, -1, -4 },
501 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
502 -1, 1, -3, -1, -1, -4 },
503 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
504 3, -1, -3, -3, -1, -4 },
505 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
506 -4, -3, -2, -2, -1, -2, -4 },
507 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
509 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
510 -2, 0, -1, -1, 0, -4 },
511 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
512 11, 2, -3, -4, -3, -2, -4 },
513 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
514 2, 7, -1, -3, -2, -1, -4 },
515 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
516 -1, 4, -3, -2, -1, -4 },
517 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
518 -3, -3, 4, 1, -1, -4 },
519 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
521 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
522 -2, -1, -1, -1, -1, -1, -4 },
523 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
524 -4, -4, -4, -4, -4, -4, 1 }, };
526 static final int[][] PAM250 =
528 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
530 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
532 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
534 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
536 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
537 -8, 0, -2, -4, -5, -3, -8 },
538 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
540 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
542 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
544 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
546 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
547 -1, 4, -2, -2, -1, -8 },
548 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
549 -1, 2, -3, -3, -1, -8 },
550 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
552 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
553 -2, 2, -2, -2, -1, -8 },
554 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
555 7, -1, -4, -5, -2, -8 },
556 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
558 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
560 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
562 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
563 17, 0, -6, -5, -6, -4, -8 },
564 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
565 10, -2, -3, -4, -2, -8 },
566 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
567 -2, 4, -2, -2, -1, -8 },
568 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
570 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
572 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
573 -2, -1, -1, -1, -1, -8 },
574 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
575 -8, -8, -8, -8, -8, -8, 1 }, };
577 public static final Hashtable ssHash = new Hashtable(); // stores the number
582 ssHash.put("H", Color.magenta);
583 ssHash.put("E", Color.yellow);
584 ssHash.put("-", Color.white);
585 ssHash.put(".", Color.white);
586 ssHash.put("S", Color.cyan);
587 ssHash.put("T", Color.blue);
588 ssHash.put("G", Color.pink);
589 ssHash.put("I", Color.pink);
590 ssHash.put("B", Color.yellow);
594 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
595 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
598 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
599 // Will equate sequences if working with mixed nucleotide sets.
600 // treats T and U identically. R and Y weak equivalence with AG and CTU.
601 // N matches any other base weakly
603 static final int[][] DNA =
605 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
606 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
607 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
608 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
609 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
610 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
611 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
612 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
613 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
614 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
615 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
618 * register matrices in list
622 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
623 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
624 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
628 public static final Color[] pidColours =
629 { midBlue, new Color(153, 153, 255),
631 new Color(204, 204, 255), };
633 public static final float[] pidThresholds =
636 public static Hashtable codonHash = new Hashtable();
638 public static Vector Lys = new Vector();
640 public static Vector Asn = new Vector();
642 public static Vector Gln = new Vector();
644 public static Vector His = new Vector();
646 public static Vector Glu = new Vector();
648 public static Vector Asp = new Vector();
650 public static Vector Tyr = new Vector();
652 public static Vector Thr = new Vector();
654 public static Vector Pro = new Vector();
656 public static Vector Ala = new Vector();
658 public static Vector Ser = new Vector();
660 public static Vector Arg = new Vector();
662 public static Vector Gly = new Vector();
664 public static Vector Trp = new Vector();
666 public static Vector Cys = new Vector();
668 public static Vector Ile = new Vector();
670 public static Vector Met = new Vector();
672 public static Vector Leu = new Vector();
674 public static Vector Val = new Vector();
676 public static Vector Phe = new Vector();
678 public static List<String> STOP = new ArrayList<String>();
680 public static String START = "ATG";
684 codonHash.put("K", Lys);
685 codonHash.put("N", Asn);
686 codonHash.put("Q", Gln);
687 codonHash.put("H", His);
688 codonHash.put("E", Glu);
689 codonHash.put("D", Asp);
690 codonHash.put("Y", Tyr);
691 codonHash.put("T", Thr);
692 codonHash.put("P", Pro);
693 codonHash.put("A", Ala);
694 codonHash.put("S", Ser);
695 codonHash.put("R", Arg);
696 codonHash.put("G", Gly);
697 codonHash.put("W", Trp);
698 codonHash.put("C", Cys);
699 codonHash.put("I", Ile);
700 codonHash.put("M", Met);
701 codonHash.put("L", Leu);
702 codonHash.put("V", Val);
703 codonHash.put("F", Phe);
704 codonHash.put("STOP", STOP);
708 * Nucleotide Ambiguity Codes
710 public static final Hashtable<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
713 * Codon triplets with additional symbols for unambiguous codons that include
716 public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
719 * all ambiguity codes for a given base
721 public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
726 * 3.2. Purine (adenine or guanine): R
728 * R is the symbol previously recommended [1].
730 ambiguityCodes.put("R", new String[]
734 * 3.3. Pyrimidine (thymine or cytosine): Y
736 * Y is the symbol previously recommended [1].
738 ambiguityCodes.put("Y", new String[]
741 * 3.4. Adenine or thymine: W
743 * Although several diverse symbols have been used for this pair, (and for
744 * the reciprocal pair G+C), only two symbols have a rational basis, L and
745 * W: L derives from DNA density (light; G+C - heavy - would thus be H); W
746 * derives from the strength of the hydrogen bonding interaction between the
747 * base pairs (weak for A+T: G +C - strong - would thus be S). However, the
748 * system recommended for the three-base series (not-A = B, etc., see below,
749 * section 3.8) rules out H as this would be not-G. W is thus recommended.
751 ambiguityCodes.put("W", new String[]
754 * 3.5. Guanine or cytosine: S
756 * The choice of this symbol is discussed above in section 3.4.
758 ambiguityCodes.put("S", new String[]
761 * 3.6. Adenine or cytosine: M
763 * There are few common features between A and C. The presence of an NH2
764 * group in similar positions on both bases (Fig. 1) makes possible a
765 * logically derived symbol. A and N being ruled out, M (from aMino) is
769 * Fig. 1. Origin of the symbols M and K The four bases are drawn so as to
770 * show the relationship between adenine and cytosine on the one hand, which
771 * both have aMino groups at the ring position most distant from the point
772 * of attachment to the sugar, and between guanine and thymine on the other,
773 * which both have Keto groups at the corresponding position. The ring atoms
774 * are numbered as recommended [24-26], although for the present purpose
775 * this has the disadvantage of giving discordant numbers to the
776 * corresponding positions.
778 ambiguityCodes.put("M", new String[]
781 * 3.7. Guanine or thymine: K By analogy with A and C (section 3.6), both G
782 * and T have Keto groups in similar positions (Fig. 1).
784 ambiguityCodes.put("K", new String[]
787 * 3.8. Adenine or thymine or cytosine: H
789 * Not-G is the most simple means of memorising this combination and symbols
790 * logically related to G were examined. F and H would both be suitable, as
791 * the letters before and after G in the alphabet, but A would have no
792 * equivalent to F. The use of H has historical precedence [2].
794 ambiguityCodes.put("H", new String[]
797 * 3.9. Guanine or cytosine or thymine: B
799 * Not-A as above (section 3.8).
801 ambiguityCodes.put("B", new String[]
804 * 3.10. Guanine or adenine or cytosine: V
806 * Not-T by analogy with not-G (section 3.8) would be U but this is ruled
807 * out to eliminate confusion with uracil. V is the next logical choice.
808 * Note that T and U may in some cases be considered to be synonyms.
810 ambiguityCodes.put("V", new String[]
813 * 3.11. Guanine or adenine or thymine: D
815 * Not-C as above (section 3.8).
817 ambiguityCodes.put("D", new String[]
820 * 3.12. Guanine or adenine or thymine or cytosine: N
822 ambiguityCodes.put("R", new String[]
823 { "G", "A", "T", "C" });
824 // Now build codon translation table
825 codonHash2.put("AAA", "K");
826 codonHash2.put("AAG", "K");
827 codonHash2.put("AAC", "N");
828 codonHash2.put("AAT", "N");
830 codonHash2.put("CAA", "Q");
831 codonHash2.put("CAG", "Q");
832 codonHash2.put("CAC", "H");
833 codonHash2.put("CAT", "H");
835 codonHash2.put("GAA", "E");
836 codonHash2.put("GAG", "E");
837 codonHash2.put("GAC", "D");
838 codonHash2.put("GAT", "D");
840 codonHash2.put("TAC", "Y");
841 codonHash2.put("TAT", "Y");
843 codonHash2.put("ACA", "T");
844 codonHash2.put("ACC", "T");
845 codonHash2.put("ACT", "T");
846 codonHash2.put("ACG", "T");
848 codonHash2.put("CCA", "P");
849 codonHash2.put("CCG", "P");
850 codonHash2.put("CCC", "P");
851 codonHash2.put("CCT", "P");
853 codonHash2.put("GCA", "A");
854 codonHash2.put("GCG", "A");
855 codonHash2.put("GCC", "A");
856 codonHash2.put("GCT", "A");
858 codonHash2.put("TCA", "S");
859 codonHash2.put("TCG", "S");
860 codonHash2.put("TCC", "S");
861 codonHash2.put("TCT", "S");
862 codonHash2.put("AGC", "S");
863 codonHash2.put("AGT", "S");
865 codonHash2.put("AGA", "R");
866 codonHash2.put("AGG", "R");
867 codonHash2.put("CGA", "R");
868 codonHash2.put("CGG", "R");
869 codonHash2.put("CGC", "R");
870 codonHash2.put("CGT", "R");
872 codonHash2.put("GGA", "G");
873 codonHash2.put("GGG", "G");
874 codonHash2.put("GGC", "G");
875 codonHash2.put("GGT", "G");
877 codonHash2.put("TGA", "*");
878 codonHash2.put("TAA", "*");
879 codonHash2.put("TAG", "*");
881 codonHash2.put("TGG", "W");
883 codonHash2.put("TGC", "C");
884 codonHash2.put("TGT", "C");
886 codonHash2.put("ATA", "I");
887 codonHash2.put("ATC", "I");
888 codonHash2.put("ATT", "I");
890 codonHash2.put("ATG", "M");
892 codonHash2.put("CTA", "L");
893 codonHash2.put("CTG", "L");
894 codonHash2.put("CTC", "L");
895 codonHash2.put("CTT", "L");
896 codonHash2.put("TTA", "L");
897 codonHash2.put("TTG", "L");
899 codonHash2.put("GTA", "V");
900 codonHash2.put("GTG", "V");
901 codonHash2.put("GTC", "V");
902 codonHash2.put("GTT", "V");
904 codonHash2.put("TTC", "F");
905 codonHash2.put("TTT", "F");
907 buildAmbiguityCodonSet();
911 * programmatic generation of codons including ambiguity codes
913 public static void buildAmbiguityCodonSet()
915 if (_ambiguityCodes.size() > 0)
918 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
921 // Invert the ambiguity code set
922 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
924 for (String r : acode.getValue())
926 List<String> codesfor = _ambiguityCodes.get(r);
927 if (codesfor == null)
929 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
931 if (!codesfor.contains(acode.getKey()))
933 codesfor.add(acode.getKey());
938 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
939 + acode.getKey() + " in residue " + r);
943 // and programmatically add in the ambiguity codes that yield the same amino
945 String[] unambcodons = codonHash2.keySet().toArray(
946 new String[codonHash2.size()]);
947 for (String codon : unambcodons)
949 String residue = codonHash2.get(codon);
950 String acodon[][] = new String[codon.length()][];
951 for (int i = 0, iSize = codon.length(); i < iSize; i++)
953 String _ac = "" + codon.charAt(i);
954 List<String> acodes = _ambiguityCodes.get(_ac);
957 acodon[i] = acodes.toArray(new String[acodes.size()]);
961 acodon[i] = new String[]
965 // enumerate all combinations and test for veracity of translation
966 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
967 for (int i = 0; i < tpos.length; i++)
971 tpos[acodon.length - 1] = 0;
973 while (tpos[0] < acodon[0].length)
975 // make all codons for this combination
976 char allres[][] = new char[tpos.length][];
979 for (ipos = 0; ipos < tpos.length; ipos++)
981 if (acodon[ipos].length == 0 || tpos[ipos] < 0)
983 _acodon += codon.charAt(ipos);
984 allres[ipos] = new char[]
985 { codon.charAt(ipos) };
989 _acodon += acodon[ipos][tpos[ipos]];
990 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
991 allres[ipos] = new char[altbase.length];
993 for (String ab : altbase)
995 allres[ipos][j++] = ab.charAt(0);
999 // test all codons for this combination
1000 for (ipos = 0; ipos < cpos.length; ipos++)
1004 boolean valid = true;
1008 for (j = 0; j < cpos.length; j++)
1010 _codon += allres[j][cpos[j]];
1012 String tr = codonHash2.get(_codon);
1013 if (valid = (tr != null && tr.equals(residue)))
1015 // advance to next combination
1016 ipos = acodon.length - 1;
1017 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
1023 } while (valid && cpos[0] < allres[0].length);
1026 // Add this to the set of codons we will translate
1027 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
1029 codonHash2.put(_acodon, residue);
1033 // System.err.println("Rejecting ambiguity codon: " + _acodon
1034 // + " for " + residue);
1037 ipos = acodon.length - 1;
1038 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1050 Lys.addElement("AAA");
1051 Lys.addElement("AAG");
1052 Asn.addElement("AAC");
1053 Asn.addElement("AAT");
1055 Gln.addElement("CAA");
1056 Gln.addElement("CAG");
1057 His.addElement("CAC");
1058 His.addElement("CAT");
1060 Glu.addElement("GAA");
1061 Glu.addElement("GAG");
1062 Asp.addElement("GAC");
1063 Asp.addElement("GAT");
1065 Tyr.addElement("TAC");
1066 Tyr.addElement("TAT");
1068 Thr.addElement("ACA");
1069 Thr.addElement("ACG");
1070 Thr.addElement("ACC");
1071 Thr.addElement("ACT");
1073 Pro.addElement("CCA");
1074 Pro.addElement("CCG");
1075 Pro.addElement("CCC");
1076 Pro.addElement("CCT");
1078 Ala.addElement("GCA");
1079 Ala.addElement("GCG");
1080 Ala.addElement("GCC");
1081 Ala.addElement("GCT");
1083 Ser.addElement("TCA");
1084 Ser.addElement("TCG");
1085 Ser.addElement("TCC");
1086 Ser.addElement("TCT");
1087 Ser.addElement("AGC");
1088 Ser.addElement("AGT");
1090 Arg.addElement("AGA");
1091 Arg.addElement("AGG");
1092 Arg.addElement("CGA");
1093 Arg.addElement("CGG");
1094 Arg.addElement("CGC");
1095 Arg.addElement("CGT");
1097 Gly.addElement("GGA");
1098 Gly.addElement("GGG");
1099 Gly.addElement("GGC");
1100 Gly.addElement("GGT");
1106 Trp.addElement("TGG");
1108 Cys.addElement("TGC");
1109 Cys.addElement("TGT");
1111 Ile.addElement("ATA");
1112 Ile.addElement("ATC");
1113 Ile.addElement("ATT");
1115 Met.addElement("ATG");
1117 Leu.addElement("CTA");
1118 Leu.addElement("CTG");
1119 Leu.addElement("CTC");
1120 Leu.addElement("CTT");
1121 Leu.addElement("TTA");
1122 Leu.addElement("TTG");
1124 Val.addElement("GTA");
1125 Val.addElement("GTG");
1126 Val.addElement("GTC");
1127 Val.addElement("GTT");
1129 Phe.addElement("TTC");
1130 Phe.addElement("TTT");
1133 // Stores residue codes/names and colours and other things
1134 public static Hashtable propHash = new Hashtable();
1136 public static Hashtable hydrophobic = new Hashtable();
1138 public static Hashtable polar = new Hashtable();
1140 public static Hashtable small = new Hashtable();
1142 public static Hashtable positive = new Hashtable();
1144 public static Hashtable negative = new Hashtable();
1146 public static Hashtable charged = new Hashtable();
1148 public static Hashtable aromatic = new Hashtable();
1150 public static Hashtable aliphatic = new Hashtable();
1152 public static Hashtable tiny = new Hashtable();
1154 public static Hashtable proline = new Hashtable();
1158 hydrophobic.put("I", new Integer(1));
1159 hydrophobic.put("L", new Integer(1));
1160 hydrophobic.put("V", new Integer(1));
1161 hydrophobic.put("C", new Integer(1));
1162 hydrophobic.put("A", new Integer(1));
1163 hydrophobic.put("G", new Integer(1));
1164 hydrophobic.put("M", new Integer(1));
1165 hydrophobic.put("F", new Integer(1));
1166 hydrophobic.put("Y", new Integer(1));
1167 hydrophobic.put("W", new Integer(1));
1168 hydrophobic.put("H", new Integer(1));
1169 hydrophobic.put("K", new Integer(1));
1170 hydrophobic.put("X", new Integer(1));
1171 hydrophobic.put("-", new Integer(1));
1172 hydrophobic.put("*", new Integer(1));
1173 hydrophobic.put("R", new Integer(0));
1174 hydrophobic.put("E", new Integer(0));
1175 hydrophobic.put("Q", new Integer(0));
1176 hydrophobic.put("D", new Integer(0));
1177 hydrophobic.put("N", new Integer(0));
1178 hydrophobic.put("S", new Integer(0));
1179 hydrophobic.put("T", new Integer(0));
1180 hydrophobic.put("P", new Integer(0));
1185 polar.put("Y", new Integer(1));
1186 polar.put("W", new Integer(1));
1187 polar.put("H", new Integer(1));
1188 polar.put("K", new Integer(1));
1189 polar.put("R", new Integer(1));
1190 polar.put("E", new Integer(1));
1191 polar.put("Q", new Integer(1));
1192 polar.put("D", new Integer(1));
1193 polar.put("N", new Integer(1));
1194 polar.put("S", new Integer(1));
1195 polar.put("T", new Integer(1));
1196 polar.put("X", new Integer(1));
1197 polar.put("-", new Integer(1));
1198 polar.put("*", new Integer(1));
1199 polar.put("I", new Integer(0));
1200 polar.put("L", new Integer(0));
1201 polar.put("V", new Integer(0));
1202 polar.put("C", new Integer(0));
1203 polar.put("A", new Integer(0));
1204 polar.put("G", new Integer(0));
1205 polar.put("M", new Integer(0));
1206 polar.put("F", new Integer(0));
1207 polar.put("P", new Integer(0));
1212 small.put("I", new Integer(0));
1213 small.put("L", new Integer(0));
1214 small.put("V", new Integer(1));
1215 small.put("C", new Integer(1));
1216 small.put("A", new Integer(1));
1217 small.put("G", new Integer(1));
1218 small.put("M", new Integer(0));
1219 small.put("F", new Integer(0));
1220 small.put("Y", new Integer(0));
1221 small.put("W", new Integer(0));
1222 small.put("H", new Integer(0));
1223 small.put("K", new Integer(0));
1224 small.put("R", new Integer(0));
1225 small.put("E", new Integer(0));
1226 small.put("Q", new Integer(0));
1227 small.put("D", new Integer(1));
1228 small.put("N", new Integer(1));
1229 small.put("S", new Integer(1));
1230 small.put("T", new Integer(1));
1231 small.put("P", new Integer(1));
1232 small.put("-", new Integer(1));
1233 small.put("*", new Integer(1));
1238 positive.put("I", new Integer(0));
1239 positive.put("L", new Integer(0));
1240 positive.put("V", new Integer(0));
1241 positive.put("C", new Integer(0));
1242 positive.put("A", new Integer(0));
1243 positive.put("G", new Integer(0));
1244 positive.put("M", new Integer(0));
1245 positive.put("F", new Integer(0));
1246 positive.put("Y", new Integer(0));
1247 positive.put("W", new Integer(0));
1248 positive.put("H", new Integer(1));
1249 positive.put("K", new Integer(1));
1250 positive.put("R", new Integer(1));
1251 positive.put("E", new Integer(0));
1252 positive.put("Q", new Integer(0));
1253 positive.put("D", new Integer(0));
1254 positive.put("N", new Integer(0));
1255 positive.put("S", new Integer(0));
1256 positive.put("T", new Integer(0));
1257 positive.put("P", new Integer(0));
1258 positive.put("-", new Integer(1));
1259 positive.put("*", new Integer(1));
1264 negative.put("I", new Integer(0));
1265 negative.put("L", new Integer(0));
1266 negative.put("V", new Integer(0));
1267 negative.put("C", new Integer(0));
1268 negative.put("A", new Integer(0));
1269 negative.put("G", new Integer(0));
1270 negative.put("M", new Integer(0));
1271 negative.put("F", new Integer(0));
1272 negative.put("Y", new Integer(0));
1273 negative.put("W", new Integer(0));
1274 negative.put("H", new Integer(0));
1275 negative.put("K", new Integer(0));
1276 negative.put("R", new Integer(0));
1277 negative.put("E", new Integer(1));
1278 negative.put("Q", new Integer(0));
1279 negative.put("D", new Integer(1));
1280 negative.put("N", new Integer(0));
1281 negative.put("S", new Integer(0));
1282 negative.put("T", new Integer(0));
1283 negative.put("P", new Integer(0));
1284 negative.put("-", new Integer(1));
1285 negative.put("*", new Integer(1));
1290 charged.put("I", new Integer(0));
1291 charged.put("L", new Integer(0));
1292 charged.put("V", new Integer(0));
1293 charged.put("C", new Integer(0));
1294 charged.put("A", new Integer(0));
1295 charged.put("G", new Integer(0));
1296 charged.put("M", new Integer(0));
1297 charged.put("F", new Integer(0));
1298 charged.put("Y", new Integer(0));
1299 charged.put("W", new Integer(0));
1300 charged.put("H", new Integer(1));
1301 charged.put("K", new Integer(1));
1302 charged.put("R", new Integer(1));
1303 charged.put("E", new Integer(1));
1304 charged.put("Q", new Integer(0));
1305 charged.put("D", new Integer(1));
1306 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1307 // Alternative would be charged and
1308 // negative (in basic form)?
1309 charged.put("S", new Integer(0));
1310 charged.put("T", new Integer(0));
1311 charged.put("P", new Integer(0));
1312 charged.put("-", new Integer(1));
1313 charged.put("*", new Integer(1));
1318 aromatic.put("I", new Integer(0));
1319 aromatic.put("L", new Integer(0));
1320 aromatic.put("V", new Integer(0));
1321 aromatic.put("C", new Integer(0));
1322 aromatic.put("A", new Integer(0));
1323 aromatic.put("G", new Integer(0));
1324 aromatic.put("M", new Integer(0));
1325 aromatic.put("F", new Integer(1));
1326 aromatic.put("Y", new Integer(1));
1327 aromatic.put("W", new Integer(1));
1328 aromatic.put("H", new Integer(1));
1329 aromatic.put("K", new Integer(0));
1330 aromatic.put("R", new Integer(0));
1331 aromatic.put("E", new Integer(0));
1332 aromatic.put("Q", new Integer(0));
1333 aromatic.put("D", new Integer(0));
1334 aromatic.put("N", new Integer(0));
1335 aromatic.put("S", new Integer(0));
1336 aromatic.put("T", new Integer(0));
1337 aromatic.put("P", new Integer(0));
1338 aromatic.put("-", new Integer(1));
1339 aromatic.put("*", new Integer(1));
1344 aliphatic.put("I", new Integer(1));
1345 aliphatic.put("L", new Integer(1));
1346 aliphatic.put("V", new Integer(1));
1347 aliphatic.put("C", new Integer(0));
1348 aliphatic.put("A", new Integer(0));
1349 aliphatic.put("G", new Integer(0));
1350 aliphatic.put("M", new Integer(0));
1351 aliphatic.put("F", new Integer(0));
1352 aliphatic.put("Y", new Integer(0));
1353 aliphatic.put("W", new Integer(0));
1354 aliphatic.put("H", new Integer(0));
1355 aliphatic.put("K", new Integer(0));
1356 aliphatic.put("R", new Integer(0));
1357 aliphatic.put("E", new Integer(0));
1358 aliphatic.put("Q", new Integer(0));
1359 aliphatic.put("D", new Integer(0));
1360 aliphatic.put("N", new Integer(0));
1361 aliphatic.put("S", new Integer(0));
1362 aliphatic.put("T", new Integer(0));
1363 aliphatic.put("P", new Integer(0));
1364 aliphatic.put("-", new Integer(1));
1365 aliphatic.put("*", new Integer(1));
1370 tiny.put("I", new Integer(0));
1371 tiny.put("L", new Integer(0));
1372 tiny.put("V", new Integer(0));
1373 tiny.put("C", new Integer(0));
1374 tiny.put("A", new Integer(1));
1375 tiny.put("G", new Integer(1));
1376 tiny.put("M", new Integer(0));
1377 tiny.put("F", new Integer(0));
1378 tiny.put("Y", new Integer(0));
1379 tiny.put("W", new Integer(0));
1380 tiny.put("H", new Integer(0));
1381 tiny.put("K", new Integer(0));
1382 tiny.put("R", new Integer(0));
1383 tiny.put("E", new Integer(0));
1384 tiny.put("Q", new Integer(0));
1385 tiny.put("D", new Integer(0));
1386 tiny.put("N", new Integer(0));
1387 tiny.put("S", new Integer(1));
1388 tiny.put("T", new Integer(0));
1389 tiny.put("P", new Integer(0));
1390 tiny.put("-", new Integer(1));
1391 tiny.put("*", new Integer(1));
1396 proline.put("I", new Integer(0));
1397 proline.put("L", new Integer(0));
1398 proline.put("V", new Integer(0));
1399 proline.put("C", new Integer(0));
1400 proline.put("A", new Integer(0));
1401 proline.put("G", new Integer(0));
1402 proline.put("M", new Integer(0));
1403 proline.put("F", new Integer(0));
1404 proline.put("Y", new Integer(0));
1405 proline.put("W", new Integer(0));
1406 proline.put("H", new Integer(0));
1407 proline.put("K", new Integer(0));
1408 proline.put("R", new Integer(0));
1409 proline.put("E", new Integer(0));
1410 proline.put("Q", new Integer(0));
1411 proline.put("D", new Integer(0));
1412 proline.put("N", new Integer(0));
1413 proline.put("S", new Integer(0));
1414 proline.put("T", new Integer(0));
1415 proline.put("P", new Integer(1));
1416 proline.put("-", new Integer(1));
1417 proline.put("*", new Integer(1));
1422 propHash.put("hydrophobic", hydrophobic);
1423 propHash.put("small", small);
1424 propHash.put("positive", positive);
1425 propHash.put("negative", negative);
1426 propHash.put("charged", charged);
1427 propHash.put("aromatic", aromatic);
1428 propHash.put("aliphatic", aliphatic);
1429 propHash.put("tiny", tiny);
1430 propHash.put("proline", proline);
1431 propHash.put("polar", polar);
1435 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1436 for (int i = 0; i < maxProteinIndex; i++)
1438 int maxF = 0, maxP = 0, maxEP = 0;
1448 for (int j = i + 1; j < maxProteinIndex; j++)
1459 propMatrixF[i][j] = 0;
1460 propMatrixPos[i][j] = 0;
1461 propMatrixEpos[i][j] = 0;
1462 for (Enumeration<String> en = propHash.keys(); en
1463 .hasMoreElements();)
1465 String ph = en.nextElement();
1466 Map<String, Integer> pph = (Map<String, Integer>) propHash
1468 if (pph.get(ic) != null && pph.get(jc) != null)
1470 int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1471 // Still working on these definitions.
1472 propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1473 propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1474 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1475 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1476 propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1477 propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1480 if (maxF < propMatrixF[i][j])
1482 maxF = propMatrixF[i][j];
1484 if (maxP < propMatrixPos[i][j])
1486 maxP = propMatrixPos[i][j];
1488 if (maxEP < propMatrixEpos[i][j])
1490 maxEP = propMatrixEpos[i][j];
1493 propMatrixF[i][i] = maxF;
1494 propMatrixPos[i][i] = maxP;
1495 propMatrixEpos[i][i] = maxEP;
1497 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1498 // scoreMatrices.put("Conservation Pos", new
1499 // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1500 // scoreMatrices.put("Conservation Both", new
1501 // ScoreMatrix("Conservation Both",propMatrixF,0));
1502 // scoreMatrices.put("Conservation EnhPos", new
1503 // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1504 scoreMatrices.put("PID", new PIDScoreModel());
1505 scoreMatrices.put("Displayed Features", new FeatureScoreModel());
1508 private ResidueProperties()
1512 public static double getHydmax()
1517 public static double getHydmin()
1522 public static double[] getHyd()
1527 public static Map<String, Integer> getAA3Hash()
1532 public static int[][] getDNA()
1534 return ResidueProperties.DNA;
1537 public static int[][] getBLOSUM62()
1539 return ResidueProperties.BLOSUM62;
1542 public static int getPAM250(String A1, String A2)
1544 return getPAM250(A1.charAt(0), A2.charAt(0));
1547 public static int getBLOSUM62(char c1, char c2)
1553 int a = aaIndex[c1];
1554 int b = aaIndex[c2];
1556 pog = ResidueProperties.BLOSUM62[a][b];
1557 } catch (Exception e)
1559 // System.out.println("Unknown residue in " + A1 + " " + A2);
1565 public static Vector getCodons(String res)
1567 if (codonHash.containsKey(res))
1569 return (Vector) codonHash.get(res);
1575 public static String codonTranslate(String lccodon)
1579 return _codonTranslate(lccodon);
1581 String cdn = codonHash2.get(lccodon.toUpperCase());
1582 if (cdn != null && cdn.equals("*"))
1589 public static String _codonTranslate(String lccodon)
1591 String codon = lccodon.toUpperCase();
1592 // all base ambiguity codes yield an 'X' amino acid residue
1593 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1597 Enumeration e = codonHash.keys();
1599 while (e.hasMoreElements())
1601 String key = (String) e.nextElement();
1602 Vector tmp = (Vector) codonHash.get(key);
1604 if (tmp.contains(codon))
1613 public static int[][] getDefaultPeptideMatrix()
1615 return ResidueProperties.getBLOSUM62();
1618 public static int[][] getDefaultDnaMatrix()
1620 return ResidueProperties.getDNA();
1624 * get a ScoreMatrix based on its string name
1627 * @return matrix in scoreMatrices with key pwtype or null
1629 public static ScoreMatrix getScoreMatrix(String pwtype)
1631 Object val = scoreMatrices.get(pwtype);
1632 if (val != null && val instanceof ScoreMatrix)
1634 return (ScoreMatrix) val;
1640 * get a ScoreModel based on its string name
1643 * @return scoremodel of type pwtype or null
1645 public static ScoreModelI getScoreModel(String pwtype)
1647 return scoreMatrices.get(pwtype);
1650 public static int getPAM250(char c, char d)
1655 int pog = ResidueProperties.PAM250[a][b];
1660 public static Hashtable toDssp3State;
1663 toDssp3State = new Hashtable();
1664 toDssp3State.put("H", "H");
1665 toDssp3State.put("E", "E");
1666 toDssp3State.put("C", " ");
1667 toDssp3State.put(" ", " ");
1668 toDssp3State.put("T", " ");
1669 toDssp3State.put("B", "E");
1670 toDssp3State.put("G", "H");
1671 toDssp3State.put("I", "H");
1672 toDssp3State.put("X", " ");
1676 * translate from other dssp secondary structure alphabets to 3-state
1679 * @return ssstring as a three-state secondary structure assignment.
1681 public static String getDssp3state(String ssstring)
1683 if (ssstring == null)
1687 StringBuffer ss = new StringBuffer();
1688 for (int i = 0; i < ssstring.length(); i++)
1690 String ssc = ssstring.substring(i, i + 1);
1691 if (toDssp3State.containsKey(ssc))
1693 ss.append((String) toDssp3State.get(ssc));
1700 return ss.toString();
1704 * Used by getRNASecStrucState
1707 public static Hashtable<String, String> toRNAssState;
1709 public static boolean RNAcloseParen[] = new boolean[255];
1712 toRNAssState = new Hashtable<String, String>();
1713 toRNAssState.put(")", "(");
1714 toRNAssState.put("(", "(");
1715 toRNAssState.put("]", "[");
1716 toRNAssState.put("[", "[");
1717 toRNAssState.put("{", "{");
1718 toRNAssState.put("}", "{");
1719 toRNAssState.put(">", ">");
1720 toRNAssState.put("<", ">");
1721 toRNAssState.put("A", "A");
1722 toRNAssState.put("a", "A");
1723 toRNAssState.put("B", "B");
1724 toRNAssState.put("b", "B");
1725 toRNAssState.put("C", "C");
1726 toRNAssState.put("c", "C");
1727 toRNAssState.put("D", "D");
1728 toRNAssState.put("d", "D");
1729 toRNAssState.put("E", "E");
1730 toRNAssState.put("e", "E");
1731 toRNAssState.put("F", "F");
1732 toRNAssState.put("f", "F");
1733 toRNAssState.put("G", "G");
1734 toRNAssState.put("g", "G");
1735 toRNAssState.put("H", "H");
1736 toRNAssState.put("h", "H");
1737 toRNAssState.put("I", "I");
1738 toRNAssState.put("i", "I");
1739 toRNAssState.put("J", "J");
1740 toRNAssState.put("j", "J");
1741 toRNAssState.put("K", "K");
1742 toRNAssState.put("k", "K");
1743 toRNAssState.put("L", "L");
1744 toRNAssState.put("l", "L");
1745 toRNAssState.put("M", "M");
1746 toRNAssState.put("m", "M");
1747 toRNAssState.put("N", "N");
1748 toRNAssState.put("n", "N");
1749 toRNAssState.put("O", "O");
1750 toRNAssState.put("o", "O");
1751 toRNAssState.put("P", "P");
1752 toRNAssState.put("p", "P");
1753 toRNAssState.put("Q", "Q");
1754 toRNAssState.put("q", "Q");
1755 toRNAssState.put("R", "R");
1756 toRNAssState.put("r", "R");
1757 toRNAssState.put("S", "S");
1758 toRNAssState.put("s", "S");
1759 toRNAssState.put("T", "T");
1760 toRNAssState.put("t", "T");
1761 toRNAssState.put("U", "U");
1762 toRNAssState.put("u", "U");
1763 toRNAssState.put("V", "V");
1764 toRNAssState.put("v", "V");
1765 toRNAssState.put("W", "W");
1766 toRNAssState.put("w", "W");
1767 toRNAssState.put("X", "X");
1768 toRNAssState.put("x", "X");
1769 toRNAssState.put("Y", "Y");
1770 toRNAssState.put("y", "Y");
1771 toRNAssState.put("Z", "Z");
1772 toRNAssState.put("z", "Z");
1773 for (int p = 0; p < RNAcloseParen.length; p++)
1775 RNAcloseParen[p] = false;
1777 for (String k : toRNAssState.keySet())
1779 RNAcloseParen[k.charAt(0)] = k.charAt(0) != toRNAssState.get(k)
1785 * translate to RNA secondary structure representation
1788 * @return ssstring as a RNA-state secondary structure assignment.
1790 public static String getRNASecStrucState(String ssstring)
1792 if (ssstring == null)
1796 StringBuffer ss = new StringBuffer();
1797 for (int i = 0; i < ssstring.length(); i++)
1799 String ssc = ssstring.substring(i, i + 1);
1800 if (toRNAssState.containsKey(ssc))
1802 // valid ss character - so return it
1803 ss.append(ssc); // (String) toRNAssState.get(ssc));
1810 return ss.toString();
1813 public static boolean isCloseParenRNA(char dc)
1815 return RNAcloseParen[dc];
1818 // main method generates perl representation of residue property hash
1820 public static void main(String[] args)
1822 Hashtable aa = new Hashtable();
1823 System.out.println("my %aa = {");
1824 // invert property hashes
1825 Enumeration prop = propHash.keys();
1826 while (prop.hasMoreElements())
1828 String pname = (String) prop.nextElement();
1829 Hashtable phash = (Hashtable) propHash.get(pname);
1830 Enumeration res = phash.keys();
1831 while (res.hasMoreElements())
1833 String rname = (String) res.nextElement();
1834 Vector aprops = (Vector) aa.get(rname);
1837 aprops = new Vector();
1838 aa.put(rname, aprops);
1840 Integer hasprop = (Integer) phash.get(rname);
1841 if (hasprop.intValue() == 1)
1843 aprops.addElement(pname);
1847 Enumeration res = aa.keys();
1848 while (res.hasMoreElements())
1850 String rname = (String) res.nextElement();
1852 System.out.print("'" + rname + "' => [");
1853 Enumeration props = ((Vector) aa.get(rname)).elements();
1854 while (props.hasMoreElements())
1856 System.out.print("'" + (String) props.nextElement() + "'");
1857 if (props.hasMoreElements())
1859 System.out.println(", ");
1862 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1864 System.out.println("};");