2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 java.awt.Color;
24 import java.util.ArrayList;
25 import java.util.Enumeration;
26 import java.util.HashMap;
27 import java.util.Hashtable;
28 import java.util.List;
30 import java.util.Vector;
32 import jalview.analysis.scoremodels.FeatureScoreModel;
33 import jalview.analysis.scoremodels.PIDScoreModel;
34 import jalview.api.analysis.ScoreModelI;
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 Map<String, List<String>> codonHash = new HashMap<String, List<String>>();
638 private static List<String> Lys = new ArrayList<String>();
640 private static List<String> Asn = new ArrayList<String>();
642 private static List<String> Gln = new ArrayList<String>();
644 private static List<String> His = new ArrayList<String>();
646 private static List<String> Glu = new ArrayList<String>();
648 private static List<String> Asp = new ArrayList<String>();
650 private static List<String> Tyr = new ArrayList<String>();
652 private static List<String> Thr = new ArrayList<String>();
654 private static List<String> Pro = new ArrayList<String>();
656 private static List<String> Ala = new ArrayList<String>();
658 private static List<String> Ser = new ArrayList<String>();
660 private static List<String> Arg = new ArrayList<String>();
662 private static List<String> Gly = new ArrayList<String>();
664 private static List<String> Trp = new ArrayList<String>();
666 private static List<String> Cys = new ArrayList<String>();
668 private static List<String> Ile = new ArrayList<String>();
670 private static List<String> Met = new ArrayList<String>();
672 private static List<String> Leu = new ArrayList<String>();
674 private static List<String> Val = new ArrayList<String>();
676 private static List<String> Phe = new ArrayList<String>();
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 Map<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 * Ambiguity codes as per http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html
728 ambiguityCodes.put("R", new String[]
730 ambiguityCodes.put("Y", new String[]
732 ambiguityCodes.put("W", new String[]
734 ambiguityCodes.put("S", new String[]
736 ambiguityCodes.put("M", new String[]
738 ambiguityCodes.put("K", new String[]
740 ambiguityCodes.put("H", new String[]
742 ambiguityCodes.put("B", new String[]
744 ambiguityCodes.put("V", new String[]
746 ambiguityCodes.put("D", new String[]
748 ambiguityCodes.put("N", new String[]
749 { "G", "A", "T", "C" });
751 // Now build codon translation table
752 codonHash2.put("AAA", "K");
753 codonHash2.put("AAG", "K");
754 codonHash2.put("AAC", "N");
755 codonHash2.put("AAT", "N");
757 codonHash2.put("CAA", "Q");
758 codonHash2.put("CAG", "Q");
759 codonHash2.put("CAC", "H");
760 codonHash2.put("CAT", "H");
762 codonHash2.put("GAA", "E");
763 codonHash2.put("GAG", "E");
764 codonHash2.put("GAC", "D");
765 codonHash2.put("GAT", "D");
767 codonHash2.put("TAC", "Y");
768 codonHash2.put("TAT", "Y");
770 codonHash2.put("ACA", "T");
771 codonHash2.put("ACC", "T");
772 codonHash2.put("ACT", "T");
773 codonHash2.put("ACG", "T");
775 codonHash2.put("CCA", "P");
776 codonHash2.put("CCG", "P");
777 codonHash2.put("CCC", "P");
778 codonHash2.put("CCT", "P");
780 codonHash2.put("GCA", "A");
781 codonHash2.put("GCG", "A");
782 codonHash2.put("GCC", "A");
783 codonHash2.put("GCT", "A");
785 codonHash2.put("TCA", "S");
786 codonHash2.put("TCG", "S");
787 codonHash2.put("TCC", "S");
788 codonHash2.put("TCT", "S");
789 codonHash2.put("AGC", "S");
790 codonHash2.put("AGT", "S");
792 codonHash2.put("AGA", "R");
793 codonHash2.put("AGG", "R");
794 codonHash2.put("CGA", "R");
795 codonHash2.put("CGG", "R");
796 codonHash2.put("CGC", "R");
797 codonHash2.put("CGT", "R");
799 codonHash2.put("GGA", "G");
800 codonHash2.put("GGG", "G");
801 codonHash2.put("GGC", "G");
802 codonHash2.put("GGT", "G");
804 codonHash2.put("TGA", "*");
805 codonHash2.put("TAA", "*");
806 codonHash2.put("TAG", "*");
808 codonHash2.put("TGG", "W");
810 codonHash2.put("TGC", "C");
811 codonHash2.put("TGT", "C");
813 codonHash2.put("ATA", "I");
814 codonHash2.put("ATC", "I");
815 codonHash2.put("ATT", "I");
817 codonHash2.put("ATG", "M");
819 codonHash2.put("CTA", "L");
820 codonHash2.put("CTG", "L");
821 codonHash2.put("CTC", "L");
822 codonHash2.put("CTT", "L");
823 codonHash2.put("TTA", "L");
824 codonHash2.put("TTG", "L");
826 codonHash2.put("GTA", "V");
827 codonHash2.put("GTG", "V");
828 codonHash2.put("GTC", "V");
829 codonHash2.put("GTT", "V");
831 codonHash2.put("TTC", "F");
832 codonHash2.put("TTT", "F");
834 buildAmbiguityCodonSet();
838 * programmatic generation of codons including ambiguity codes
840 public static void buildAmbiguityCodonSet()
842 if (_ambiguityCodes.size() > 0)
845 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
848 // Invert the ambiguity code set
849 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
851 for (String r : acode.getValue())
853 List<String> codesfor = _ambiguityCodes.get(r);
854 if (codesfor == null)
856 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
858 if (!codesfor.contains(acode.getKey()))
860 codesfor.add(acode.getKey());
865 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
866 + acode.getKey() + " in residue " + r);
870 // and programmatically add in the ambiguity codes that yield the same amino
872 String[] unambcodons = codonHash2.keySet().toArray(
873 new String[codonHash2.size()]);
874 for (String codon : unambcodons)
876 String residue = codonHash2.get(codon);
877 String acodon[][] = new String[codon.length()][];
878 for (int i = 0, iSize = codon.length(); i < iSize; i++)
880 String _ac = "" + codon.charAt(i);
881 List<String> acodes = _ambiguityCodes.get(_ac);
884 acodon[i] = acodes.toArray(new String[acodes.size()]);
888 acodon[i] = new String[]
892 // enumerate all combinations and test for veracity of translation
893 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
894 for (int i = 0; i < tpos.length; i++)
898 tpos[acodon.length - 1] = 0;
900 while (tpos[0] < acodon[0].length)
902 // make all codons for this combination
903 char allres[][] = new char[tpos.length][];
906 for (ipos = 0; ipos < tpos.length; ipos++)
908 if (acodon[ipos].length == 0 || tpos[ipos] < 0)
910 _acodon += codon.charAt(ipos);
911 allres[ipos] = new char[]
912 { codon.charAt(ipos) };
916 _acodon += acodon[ipos][tpos[ipos]];
917 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
918 allres[ipos] = new char[altbase.length];
920 for (String ab : altbase)
922 allres[ipos][j++] = ab.charAt(0);
926 // test all codons for this combination
927 for (ipos = 0; ipos < cpos.length; ipos++)
931 boolean valid = true;
935 for (j = 0; j < cpos.length; j++)
937 _codon += allres[j][cpos[j]];
939 String tr = codonHash2.get(_codon);
940 if (valid = (tr != null && tr.equals(residue)))
942 // advance to next combination
943 ipos = acodon.length - 1;
944 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
950 } while (valid && cpos[0] < allres[0].length);
953 // Add this to the set of codons we will translate
954 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
956 codonHash2.put(_acodon, residue);
960 // System.err.println("Rejecting ambiguity codon: " + _acodon
961 // + " for " + residue);
964 ipos = acodon.length - 1;
965 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1060 // Stores residue codes/names and colours and other things
1061 public static Hashtable propHash = new Hashtable();
1063 public static Hashtable hydrophobic = new Hashtable();
1065 public static Hashtable polar = new Hashtable();
1067 public static Hashtable small = new Hashtable();
1069 public static Hashtable positive = new Hashtable();
1071 public static Hashtable negative = new Hashtable();
1073 public static Hashtable charged = new Hashtable();
1075 public static Hashtable aromatic = new Hashtable();
1077 public static Hashtable aliphatic = new Hashtable();
1079 public static Hashtable tiny = new Hashtable();
1081 public static Hashtable proline = new Hashtable();
1085 hydrophobic.put("I", new Integer(1));
1086 hydrophobic.put("L", new Integer(1));
1087 hydrophobic.put("V", new Integer(1));
1088 hydrophobic.put("C", new Integer(1));
1089 hydrophobic.put("A", new Integer(1));
1090 hydrophobic.put("G", new Integer(1));
1091 hydrophobic.put("M", new Integer(1));
1092 hydrophobic.put("F", new Integer(1));
1093 hydrophobic.put("Y", new Integer(1));
1094 hydrophobic.put("W", new Integer(1));
1095 hydrophobic.put("H", new Integer(1));
1096 hydrophobic.put("K", new Integer(1));
1097 hydrophobic.put("X", new Integer(1));
1098 hydrophobic.put("-", new Integer(1));
1099 hydrophobic.put("*", new Integer(1));
1100 hydrophobic.put("R", new Integer(0));
1101 hydrophobic.put("E", new Integer(0));
1102 hydrophobic.put("Q", new Integer(0));
1103 hydrophobic.put("D", new Integer(0));
1104 hydrophobic.put("N", new Integer(0));
1105 hydrophobic.put("S", new Integer(0));
1106 hydrophobic.put("T", new Integer(0));
1107 hydrophobic.put("P", new Integer(0));
1112 polar.put("Y", new Integer(1));
1113 polar.put("W", new Integer(1));
1114 polar.put("H", new Integer(1));
1115 polar.put("K", new Integer(1));
1116 polar.put("R", new Integer(1));
1117 polar.put("E", new Integer(1));
1118 polar.put("Q", new Integer(1));
1119 polar.put("D", new Integer(1));
1120 polar.put("N", new Integer(1));
1121 polar.put("S", new Integer(1));
1122 polar.put("T", new Integer(1));
1123 polar.put("X", new Integer(1));
1124 polar.put("-", new Integer(1));
1125 polar.put("*", new Integer(1));
1126 polar.put("I", new Integer(0));
1127 polar.put("L", new Integer(0));
1128 polar.put("V", new Integer(0));
1129 polar.put("C", new Integer(0));
1130 polar.put("A", new Integer(0));
1131 polar.put("G", new Integer(0));
1132 polar.put("M", new Integer(0));
1133 polar.put("F", new Integer(0));
1134 polar.put("P", new Integer(0));
1139 small.put("I", new Integer(0));
1140 small.put("L", new Integer(0));
1141 small.put("V", new Integer(1));
1142 small.put("C", new Integer(1));
1143 small.put("A", new Integer(1));
1144 small.put("G", new Integer(1));
1145 small.put("M", new Integer(0));
1146 small.put("F", new Integer(0));
1147 small.put("Y", new Integer(0));
1148 small.put("W", new Integer(0));
1149 small.put("H", new Integer(0));
1150 small.put("K", new Integer(0));
1151 small.put("R", new Integer(0));
1152 small.put("E", new Integer(0));
1153 small.put("Q", new Integer(0));
1154 small.put("D", new Integer(1));
1155 small.put("N", new Integer(1));
1156 small.put("S", new Integer(1));
1157 small.put("T", new Integer(1));
1158 small.put("P", new Integer(1));
1159 small.put("-", new Integer(1));
1160 small.put("*", new Integer(1));
1165 positive.put("I", new Integer(0));
1166 positive.put("L", new Integer(0));
1167 positive.put("V", new Integer(0));
1168 positive.put("C", new Integer(0));
1169 positive.put("A", new Integer(0));
1170 positive.put("G", new Integer(0));
1171 positive.put("M", new Integer(0));
1172 positive.put("F", new Integer(0));
1173 positive.put("Y", new Integer(0));
1174 positive.put("W", new Integer(0));
1175 positive.put("H", new Integer(1));
1176 positive.put("K", new Integer(1));
1177 positive.put("R", new Integer(1));
1178 positive.put("E", new Integer(0));
1179 positive.put("Q", new Integer(0));
1180 positive.put("D", new Integer(0));
1181 positive.put("N", new Integer(0));
1182 positive.put("S", new Integer(0));
1183 positive.put("T", new Integer(0));
1184 positive.put("P", new Integer(0));
1185 positive.put("-", new Integer(1));
1186 positive.put("*", new Integer(1));
1191 negative.put("I", new Integer(0));
1192 negative.put("L", new Integer(0));
1193 negative.put("V", new Integer(0));
1194 negative.put("C", new Integer(0));
1195 negative.put("A", new Integer(0));
1196 negative.put("G", new Integer(0));
1197 negative.put("M", new Integer(0));
1198 negative.put("F", new Integer(0));
1199 negative.put("Y", new Integer(0));
1200 negative.put("W", new Integer(0));
1201 negative.put("H", new Integer(0));
1202 negative.put("K", new Integer(0));
1203 negative.put("R", new Integer(0));
1204 negative.put("E", new Integer(1));
1205 negative.put("Q", new Integer(0));
1206 negative.put("D", new Integer(1));
1207 negative.put("N", new Integer(0));
1208 negative.put("S", new Integer(0));
1209 negative.put("T", new Integer(0));
1210 negative.put("P", new Integer(0));
1211 negative.put("-", new Integer(1));
1212 negative.put("*", new Integer(1));
1217 charged.put("I", new Integer(0));
1218 charged.put("L", new Integer(0));
1219 charged.put("V", new Integer(0));
1220 charged.put("C", new Integer(0));
1221 charged.put("A", new Integer(0));
1222 charged.put("G", new Integer(0));
1223 charged.put("M", new Integer(0));
1224 charged.put("F", new Integer(0));
1225 charged.put("Y", new Integer(0));
1226 charged.put("W", new Integer(0));
1227 charged.put("H", new Integer(1));
1228 charged.put("K", new Integer(1));
1229 charged.put("R", new Integer(1));
1230 charged.put("E", new Integer(1));
1231 charged.put("Q", new Integer(0));
1232 charged.put("D", new Integer(1));
1233 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1234 // Alternative would be charged and
1235 // negative (in basic form)?
1236 charged.put("S", new Integer(0));
1237 charged.put("T", new Integer(0));
1238 charged.put("P", new Integer(0));
1239 charged.put("-", new Integer(1));
1240 charged.put("*", new Integer(1));
1245 aromatic.put("I", new Integer(0));
1246 aromatic.put("L", new Integer(0));
1247 aromatic.put("V", new Integer(0));
1248 aromatic.put("C", new Integer(0));
1249 aromatic.put("A", new Integer(0));
1250 aromatic.put("G", new Integer(0));
1251 aromatic.put("M", new Integer(0));
1252 aromatic.put("F", new Integer(1));
1253 aromatic.put("Y", new Integer(1));
1254 aromatic.put("W", new Integer(1));
1255 aromatic.put("H", new Integer(1));
1256 aromatic.put("K", new Integer(0));
1257 aromatic.put("R", new Integer(0));
1258 aromatic.put("E", new Integer(0));
1259 aromatic.put("Q", new Integer(0));
1260 aromatic.put("D", new Integer(0));
1261 aromatic.put("N", new Integer(0));
1262 aromatic.put("S", new Integer(0));
1263 aromatic.put("T", new Integer(0));
1264 aromatic.put("P", new Integer(0));
1265 aromatic.put("-", new Integer(1));
1266 aromatic.put("*", new Integer(1));
1271 aliphatic.put("I", new Integer(1));
1272 aliphatic.put("L", new Integer(1));
1273 aliphatic.put("V", new Integer(1));
1274 aliphatic.put("C", new Integer(0));
1275 aliphatic.put("A", new Integer(0));
1276 aliphatic.put("G", new Integer(0));
1277 aliphatic.put("M", new Integer(0));
1278 aliphatic.put("F", new Integer(0));
1279 aliphatic.put("Y", new Integer(0));
1280 aliphatic.put("W", new Integer(0));
1281 aliphatic.put("H", new Integer(0));
1282 aliphatic.put("K", new Integer(0));
1283 aliphatic.put("R", new Integer(0));
1284 aliphatic.put("E", new Integer(0));
1285 aliphatic.put("Q", new Integer(0));
1286 aliphatic.put("D", new Integer(0));
1287 aliphatic.put("N", new Integer(0));
1288 aliphatic.put("S", new Integer(0));
1289 aliphatic.put("T", new Integer(0));
1290 aliphatic.put("P", new Integer(0));
1291 aliphatic.put("-", new Integer(1));
1292 aliphatic.put("*", new Integer(1));
1297 tiny.put("I", new Integer(0));
1298 tiny.put("L", new Integer(0));
1299 tiny.put("V", new Integer(0));
1300 tiny.put("C", new Integer(0));
1301 tiny.put("A", new Integer(1));
1302 tiny.put("G", new Integer(1));
1303 tiny.put("M", new Integer(0));
1304 tiny.put("F", new Integer(0));
1305 tiny.put("Y", new Integer(0));
1306 tiny.put("W", new Integer(0));
1307 tiny.put("H", new Integer(0));
1308 tiny.put("K", new Integer(0));
1309 tiny.put("R", new Integer(0));
1310 tiny.put("E", new Integer(0));
1311 tiny.put("Q", new Integer(0));
1312 tiny.put("D", new Integer(0));
1313 tiny.put("N", new Integer(0));
1314 tiny.put("S", new Integer(1));
1315 tiny.put("T", new Integer(0));
1316 tiny.put("P", new Integer(0));
1317 tiny.put("-", new Integer(1));
1318 tiny.put("*", new Integer(1));
1323 proline.put("I", new Integer(0));
1324 proline.put("L", new Integer(0));
1325 proline.put("V", new Integer(0));
1326 proline.put("C", new Integer(0));
1327 proline.put("A", new Integer(0));
1328 proline.put("G", new Integer(0));
1329 proline.put("M", new Integer(0));
1330 proline.put("F", new Integer(0));
1331 proline.put("Y", new Integer(0));
1332 proline.put("W", new Integer(0));
1333 proline.put("H", new Integer(0));
1334 proline.put("K", new Integer(0));
1335 proline.put("R", new Integer(0));
1336 proline.put("E", new Integer(0));
1337 proline.put("Q", new Integer(0));
1338 proline.put("D", new Integer(0));
1339 proline.put("N", new Integer(0));
1340 proline.put("S", new Integer(0));
1341 proline.put("T", new Integer(0));
1342 proline.put("P", new Integer(1));
1343 proline.put("-", new Integer(1));
1344 proline.put("*", new Integer(1));
1349 propHash.put("hydrophobic", hydrophobic);
1350 propHash.put("small", small);
1351 propHash.put("positive", positive);
1352 propHash.put("negative", negative);
1353 propHash.put("charged", charged);
1354 propHash.put("aromatic", aromatic);
1355 propHash.put("aliphatic", aliphatic);
1356 propHash.put("tiny", tiny);
1357 propHash.put("proline", proline);
1358 propHash.put("polar", polar);
1362 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1363 for (int i = 0; i < maxProteinIndex; i++)
1365 int maxF = 0, maxP = 0, maxEP = 0;
1375 for (int j = i + 1; j < maxProteinIndex; j++)
1386 propMatrixF[i][j] = 0;
1387 propMatrixPos[i][j] = 0;
1388 propMatrixEpos[i][j] = 0;
1389 for (Enumeration<String> en = propHash.keys(); en
1390 .hasMoreElements();)
1392 String ph = en.nextElement();
1393 Map<String, Integer> pph = (Map<String, Integer>) propHash
1395 if (pph.get(ic) != null && pph.get(jc) != null)
1397 int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1398 // Still working on these definitions.
1399 propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1400 propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1401 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1402 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1403 propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1404 propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1407 if (maxF < propMatrixF[i][j])
1409 maxF = propMatrixF[i][j];
1411 if (maxP < propMatrixPos[i][j])
1413 maxP = propMatrixPos[i][j];
1415 if (maxEP < propMatrixEpos[i][j])
1417 maxEP = propMatrixEpos[i][j];
1420 propMatrixF[i][i] = maxF;
1421 propMatrixPos[i][i] = maxP;
1422 propMatrixEpos[i][i] = maxEP;
1424 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1425 // scoreMatrices.put("Conservation Pos", new
1426 // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1427 // scoreMatrices.put("Conservation Both", new
1428 // ScoreMatrix("Conservation Both",propMatrixF,0));
1429 // scoreMatrices.put("Conservation EnhPos", new
1430 // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1431 scoreMatrices.put("PID", new PIDScoreModel());
1432 scoreMatrices.put("Displayed Features", new FeatureScoreModel());
1435 private ResidueProperties()
1439 public static double getHydmax()
1444 public static double getHydmin()
1449 public static double[] getHyd()
1454 public static Map<String, Integer> getAA3Hash()
1459 public static int[][] getDNA()
1461 return ResidueProperties.DNA;
1464 public static int[][] getBLOSUM62()
1466 return ResidueProperties.BLOSUM62;
1469 public static int getPAM250(String A1, String A2)
1471 return getPAM250(A1.charAt(0), A2.charAt(0));
1474 public static int getBLOSUM62(char c1, char c2)
1480 int a = aaIndex[c1];
1481 int b = aaIndex[c2];
1483 pog = ResidueProperties.BLOSUM62[a][b];
1484 } catch (Exception e)
1486 // System.out.println("Unknown residue in " + A1 + " " + A2);
1492 public static Vector getCodons(String res)
1494 if (codonHash.containsKey(res))
1496 return (Vector) codonHash.get(res);
1502 public static String codonTranslate(String lccodon)
1506 return _codonTranslate(lccodon);
1508 String cdn = codonHash2.get(lccodon.toUpperCase());
1509 if (cdn != null && cdn.equals("*"))
1516 public static String _codonTranslate(String lccodon)
1518 String codon = lccodon.toUpperCase();
1519 // all base ambiguity codes yield an 'X' amino acid residue
1520 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1524 for (String key : codonHash.keySet())
1526 if (codonHash.get(key).contains(codon))
1535 public static int[][] getDefaultPeptideMatrix()
1537 return ResidueProperties.getBLOSUM62();
1540 public static int[][] getDefaultDnaMatrix()
1542 return ResidueProperties.getDNA();
1546 * get a ScoreMatrix based on its string name
1549 * @return matrix in scoreMatrices with key pwtype or null
1551 public static ScoreMatrix getScoreMatrix(String pwtype)
1553 Object val = scoreMatrices.get(pwtype);
1554 if (val != null && val instanceof ScoreMatrix)
1556 return (ScoreMatrix) val;
1562 * get a ScoreModel based on its string name
1565 * @return scoremodel of type pwtype or null
1567 public static ScoreModelI getScoreModel(String pwtype)
1569 return scoreMatrices.get(pwtype);
1572 public static int getPAM250(char c, char d)
1577 int pog = ResidueProperties.PAM250[a][b];
1582 public static Hashtable toDssp3State;
1585 toDssp3State = new Hashtable();
1586 toDssp3State.put("H", "H");
1587 toDssp3State.put("E", "E");
1588 toDssp3State.put("C", " ");
1589 toDssp3State.put(" ", " ");
1590 toDssp3State.put("T", " ");
1591 toDssp3State.put("B", "E");
1592 toDssp3State.put("G", "H");
1593 toDssp3State.put("I", "H");
1594 toDssp3State.put("X", " ");
1598 * translate from other dssp secondary structure alphabets to 3-state
1601 * @return ssstring as a three-state secondary structure assignment.
1603 public static String getDssp3state(String ssstring)
1605 if (ssstring == null)
1609 StringBuffer ss = new StringBuffer();
1610 for (int i = 0; i < ssstring.length(); i++)
1612 String ssc = ssstring.substring(i, i + 1);
1613 if (toDssp3State.containsKey(ssc))
1615 ss.append((String) toDssp3State.get(ssc));
1622 return ss.toString();
1626 * Used by getRNASecStrucState
1629 public static Hashtable<String, String> toRNAssState;
1631 public static boolean RNAcloseParen[] = new boolean[255];
1634 toRNAssState = new Hashtable<String, String>();
1635 toRNAssState.put(")", "(");
1636 toRNAssState.put("(", "(");
1637 toRNAssState.put("]", "[");
1638 toRNAssState.put("[", "[");
1639 toRNAssState.put("{", "{");
1640 toRNAssState.put("}", "{");
1641 toRNAssState.put(">", ">");
1642 toRNAssState.put("<", ">");
1643 toRNAssState.put("A", "A");
1644 toRNAssState.put("a", "A");
1645 toRNAssState.put("B", "B");
1646 toRNAssState.put("b", "B");
1647 toRNAssState.put("C", "C");
1648 toRNAssState.put("c", "C");
1649 toRNAssState.put("D", "D");
1650 toRNAssState.put("d", "D");
1651 toRNAssState.put("E", "E");
1652 toRNAssState.put("e", "E");
1653 toRNAssState.put("F", "F");
1654 toRNAssState.put("f", "F");
1655 toRNAssState.put("G", "G");
1656 toRNAssState.put("g", "G");
1657 toRNAssState.put("H", "H");
1658 toRNAssState.put("h", "H");
1659 toRNAssState.put("I", "I");
1660 toRNAssState.put("i", "I");
1661 toRNAssState.put("J", "J");
1662 toRNAssState.put("j", "J");
1663 toRNAssState.put("K", "K");
1664 toRNAssState.put("k", "K");
1665 toRNAssState.put("L", "L");
1666 toRNAssState.put("l", "L");
1667 toRNAssState.put("M", "M");
1668 toRNAssState.put("m", "M");
1669 toRNAssState.put("N", "N");
1670 toRNAssState.put("n", "N");
1671 toRNAssState.put("O", "O");
1672 toRNAssState.put("o", "O");
1673 toRNAssState.put("P", "P");
1674 toRNAssState.put("p", "P");
1675 toRNAssState.put("Q", "Q");
1676 toRNAssState.put("q", "Q");
1677 toRNAssState.put("R", "R");
1678 toRNAssState.put("r", "R");
1679 toRNAssState.put("S", "S");
1680 toRNAssState.put("s", "S");
1681 toRNAssState.put("T", "T");
1682 toRNAssState.put("t", "T");
1683 toRNAssState.put("U", "U");
1684 toRNAssState.put("u", "U");
1685 toRNAssState.put("V", "V");
1686 toRNAssState.put("v", "V");
1687 toRNAssState.put("W", "W");
1688 toRNAssState.put("w", "W");
1689 toRNAssState.put("X", "X");
1690 toRNAssState.put("x", "X");
1691 toRNAssState.put("Y", "Y");
1692 toRNAssState.put("y", "Y");
1693 toRNAssState.put("Z", "Z");
1694 toRNAssState.put("z", "Z");
1695 for (int p = 0; p < RNAcloseParen.length; p++)
1697 RNAcloseParen[p] = false;
1699 for (String k : toRNAssState.keySet())
1701 RNAcloseParen[k.charAt(0)] = k.charAt(0) != toRNAssState.get(k)
1707 * translate to RNA secondary structure representation
1710 * @return ssstring as a RNA-state secondary structure assignment.
1712 public static String getRNASecStrucState(String ssstring)
1714 if (ssstring == null)
1718 StringBuffer ss = new StringBuffer();
1719 for (int i = 0; i < ssstring.length(); i++)
1721 String ssc = ssstring.substring(i, i + 1);
1722 if (toRNAssState.containsKey(ssc))
1724 // valid ss character - so return it
1725 ss.append(ssc); // (String) toRNAssState.get(ssc));
1732 return ss.toString();
1735 public static boolean isCloseParenRNA(char dc)
1737 return RNAcloseParen[dc];
1740 // main method generates perl representation of residue property hash
1742 public static void main(String[] args)
1744 Hashtable aa = new Hashtable();
1745 System.out.println("my %aa = {");
1746 // invert property hashes
1747 Enumeration prop = propHash.keys();
1748 while (prop.hasMoreElements())
1750 String pname = (String) prop.nextElement();
1751 Hashtable phash = (Hashtable) propHash.get(pname);
1752 Enumeration res = phash.keys();
1753 while (res.hasMoreElements())
1755 String rname = (String) res.nextElement();
1756 Vector aprops = (Vector) aa.get(rname);
1759 aprops = new Vector();
1760 aa.put(rname, aprops);
1762 Integer hasprop = (Integer) phash.get(rname);
1763 if (hasprop.intValue() == 1)
1765 aprops.addElement(pname);
1769 Enumeration res = aa.keys();
1770 while (res.hasMoreElements())
1772 String rname = (String) res.nextElement();
1774 System.out.print("'" + rname + "' => [");
1775 Enumeration props = ((Vector) aa.get(rname)).elements();
1776 while (props.hasMoreElements())
1778 System.out.print("'" + (String) props.nextElement() + "'");
1779 if (props.hasMoreElements())
1781 System.out.println(", ");
1784 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1786 System.out.println("};");
1791 * Returns a list of residue characters for the specified inputs
1794 * @param includeAmbiguous
1797 public static List<String> getResidues(boolean nucleotide,
1798 boolean includeAmbiguous)
1800 List<String> result = new ArrayList<String>();
1803 for (String nuc : nucleotideName.keySet())
1805 int val = nucleotideIndex[nuc.charAt(0)];
1806 if ((!includeAmbiguous && val > 4) || (val >= maxNucleotideIndex))
1810 nuc = nuc.toUpperCase();
1811 if (!result.contains(nuc))
1820 for (String res : aa3Hash.keySet())
1822 int index = aa3Hash.get(res).intValue();
1823 if ((!includeAmbiguous && index >= 20) || index >= maxProteinIndex)
1827 res = res.toUpperCase();
1828 if (!result.contains(res))