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 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>();
53 // lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET)
54 public static final Map<String, String> modifications = new HashMap<String, String>();
58 aaIndex = new int[255];
59 for (int i = 0; i < 255; i++)
111 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
112 // extend subt. matrices
116 * maximum (gap) index for matrices involving protein alphabet
118 public final static int maxProteinIndex = 23;
121 * maximum (gap) index for matrices involving nucleotide alphabet
123 public final static int maxNucleotideIndex = 10;
127 nucleotideIndex = new int[255];
128 for (int i = 0; i < 255; i++)
130 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
133 nucleotideIndex['A'] = 0;
134 nucleotideIndex['a'] = 0;
135 nucleotideIndex['C'] = 1;
136 nucleotideIndex['c'] = 1;
137 nucleotideIndex['G'] = 2;
138 nucleotideIndex['g'] = 2;
139 nucleotideIndex['T'] = 3;
140 nucleotideIndex['t'] = 3;
141 nucleotideIndex['U'] = 4;
142 nucleotideIndex['u'] = 4;
143 nucleotideIndex['I'] = 5;
144 nucleotideIndex['i'] = 5;
145 nucleotideIndex['X'] = 6;
146 nucleotideIndex['x'] = 6;
147 nucleotideIndex['R'] = 7;
148 nucleotideIndex['r'] = 7;
149 nucleotideIndex['Y'] = 8;
150 nucleotideIndex['y'] = 8;
151 nucleotideIndex['N'] = 9;
152 nucleotideIndex['n'] = 9;
154 nucleotideName.put("A", "Adenine");
155 nucleotideName.put("a", "Adenine");
156 nucleotideName.put("G", "Guanine");
157 nucleotideName.put("g", "Guanine");
158 nucleotideName.put("C", "Cytosine");
159 nucleotideName.put("c", "Cytosine");
160 nucleotideName.put("T", "Thymine");
161 nucleotideName.put("t", "Thymine");
162 nucleotideName.put("U", "Uracil");
163 nucleotideName.put("u", "Uracil");
164 nucleotideName.put("I", "Inosine");
165 nucleotideName.put("i", "Inosine");
166 nucleotideName.put("X", "Xanthine");
167 nucleotideName.put("x", "Xanthine");
168 nucleotideName.put("R", "Unknown Purine");
169 nucleotideName.put("r", "Unknown Purine");
170 nucleotideName.put("Y", "Unknown Pyrimidine");
171 nucleotideName.put("y", "Unknown Pyrimidine");
172 nucleotideName.put("N", "Unknown");
173 nucleotideName.put("n", "Unknown");
174 nucleotideName.put("W", "Weak nucleotide (A or T)");
175 nucleotideName.put("w", "Weak nucleotide (A or T)");
176 nucleotideName.put("S", "Strong nucleotide (G or C)");
177 nucleotideName.put("s", "Strong nucleotide (G or C)");
178 nucleotideName.put("M", "Amino (A or C)");
179 nucleotideName.put("m", "Amino (A or C)");
180 nucleotideName.put("K", "Keto (G or T)");
181 nucleotideName.put("k", "Keto (G or T)");
182 nucleotideName.put("B", "Not A (G or C or T)");
183 nucleotideName.put("b", "Not A (G or C or T)");
184 nucleotideName.put("H", "Not G (A or C or T)");
185 nucleotideName.put("h", "Not G (A or C or T)");
186 nucleotideName.put("D", "Not C (A or G or T)");
187 nucleotideName.put("d", "Not C (A or G or T)");
188 nucleotideName.put("V", "Not T (A or G or C");
189 nucleotideName.put("v", "Not T (A or G or C");
195 purinepyrimidineIndex = new int[255];
196 for (int i = 0; i < 255; i++)
198 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
202 purinepyrimidineIndex['A'] = 0;
203 purinepyrimidineIndex['a'] = 0;
204 purinepyrimidineIndex['C'] = 1;
205 purinepyrimidineIndex['c'] = 1;
206 purinepyrimidineIndex['G'] = 0;
207 purinepyrimidineIndex['g'] = 0;
208 purinepyrimidineIndex['T'] = 1;
209 purinepyrimidineIndex['t'] = 1;
210 purinepyrimidineIndex['U'] = 1;
211 purinepyrimidineIndex['u'] = 1;
212 purinepyrimidineIndex['I'] = 2;
213 purinepyrimidineIndex['i'] = 2;
214 purinepyrimidineIndex['X'] = 2;
215 purinepyrimidineIndex['x'] = 2;
216 purinepyrimidineIndex['R'] = 0;
217 purinepyrimidineIndex['r'] = 0;
218 purinepyrimidineIndex['Y'] = 1;
219 purinepyrimidineIndex['y'] = 1;
220 purinepyrimidineIndex['N'] = 2;
221 purinepyrimidineIndex['n'] = 2;
226 aa3Hash.put("ALA", new Integer(0));
227 aa3Hash.put("ARG", new Integer(1));
228 aa3Hash.put("ASN", new Integer(2));
229 aa3Hash.put("ASP", new Integer(3)); // D
230 aa3Hash.put("CYS", new Integer(4));
231 aa3Hash.put("GLN", new Integer(5)); // Q
232 aa3Hash.put("GLU", new Integer(6)); // E
233 aa3Hash.put("GLY", new Integer(7));
234 aa3Hash.put("HIS", new Integer(8));
235 aa3Hash.put("ILE", new Integer(9));
236 aa3Hash.put("LEU", new Integer(10));
237 aa3Hash.put("LYS", new Integer(11));
238 aa3Hash.put("MET", new Integer(12));
239 aa3Hash.put("PHE", new Integer(13));
240 aa3Hash.put("PRO", new Integer(14));
241 aa3Hash.put("SER", new Integer(15));
242 aa3Hash.put("THR", new Integer(16));
243 aa3Hash.put("TRP", new Integer(17));
244 aa3Hash.put("TYR", new Integer(18));
245 aa3Hash.put("VAL", new Integer(19));
246 // IUB Nomenclature for ambiguous peptides
247 aa3Hash.put("ASX", new Integer(20)); // "B";
248 aa3Hash.put("GLX", new Integer(21)); // X
249 aa3Hash.put("XAA", new Integer(22)); // X unknown
250 aa3Hash.put("-", new Integer(23));
251 aa3Hash.put("*", new Integer(23));
252 aa3Hash.put(".", new Integer(23));
253 aa3Hash.put(" ", new Integer(23));
254 aa3Hash.put("Gap", new Integer(23));
259 aa2Triplet.put("A", "ALA");
260 aa2Triplet.put("a", "ALA");
261 aa2Triplet.put("R", "ARG");
262 aa2Triplet.put("r", "ARG");
263 aa2Triplet.put("N", "ASN");
264 aa2Triplet.put("n", "ASN");
265 aa2Triplet.put("D", "ASP");
266 aa2Triplet.put("d", "ASP");
267 aa2Triplet.put("C", "CYS");
268 aa2Triplet.put("c", "CYS");
269 aa2Triplet.put("Q", "GLN");
270 aa2Triplet.put("q", "GLN");
271 aa2Triplet.put("E", "GLU");
272 aa2Triplet.put("e", "GLU");
273 aa2Triplet.put("G", "GLY");
274 aa2Triplet.put("g", "GLY");
275 aa2Triplet.put("H", "HIS");
276 aa2Triplet.put("h", "HIS");
277 aa2Triplet.put("I", "ILE");
278 aa2Triplet.put("i", "ILE");
279 aa2Triplet.put("L", "LEU");
280 aa2Triplet.put("l", "LEU");
281 aa2Triplet.put("K", "LYS");
282 aa2Triplet.put("k", "LYS");
283 aa2Triplet.put("M", "MET");
284 aa2Triplet.put("m", "MET");
285 aa2Triplet.put("F", "PHE");
286 aa2Triplet.put("f", "PHE");
287 aa2Triplet.put("P", "PRO");
288 aa2Triplet.put("p", "PRO");
289 aa2Triplet.put("S", "SER");
290 aa2Triplet.put("s", "SER");
291 aa2Triplet.put("T", "THR");
292 aa2Triplet.put("t", "THR");
293 aa2Triplet.put("W", "TRP");
294 aa2Triplet.put("w", "TRP");
295 aa2Triplet.put("Y", "TYR");
296 aa2Triplet.put("y", "TYR");
297 aa2Triplet.put("V", "VAL");
298 aa2Triplet.put("v", "VAL");
301 public static final String[] aa =
302 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
303 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
305 public static final Color midBlue = new Color(100, 100, 255);
307 public static final Vector scaleColours = new Vector();
311 scaleColours.addElement(new Color(114, 0, 147));
312 scaleColours.addElement(new Color(156, 0, 98));
313 scaleColours.addElement(new Color(190, 0, 0));
314 scaleColours.addElement(Color.red);
315 scaleColours.addElement(new Color(255, 125, 0));
316 scaleColours.addElement(Color.orange);
317 scaleColours.addElement(new Color(255, 194, 85));
318 scaleColours.addElement(Color.yellow);
319 scaleColours.addElement(new Color(255, 255, 181));
320 scaleColours.addElement(Color.white);
323 public static final Color[] taylor =
324 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
325 new Color(0, 0, 255), // R Blueish-bluey-blue
326 new Color(204, 0, 255), // N Blueish-reddy-blue
327 new Color(255, 0, 0), // D Reddish-reddy-red
328 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
329 new Color(255, 0, 204), // Q Reddish-bluey-red
330 new Color(255, 0, 102), // E Blueish-reddy-red
331 new Color(255, 153, 0), // G Yellowy-reddy-yellow
332 new Color(0, 102, 255), // H Greenish-bluey-blue
333 new Color(102, 255, 0), // I Greenish-yellowy-green
334 new Color(51, 255, 0), // L Yellowish-greeny-green
335 new Color(102, 0, 255), // K Reddish-bluey-blue
336 new Color(0, 255, 0), // M Greenish-greeny-green
337 new Color(0, 255, 102), // F Blueish-greeny-green
338 new Color(255, 204, 0), // P Reddish-yellowy-yellow
339 new Color(255, 51, 0), // S Yellowish-reddy-red
340 new Color(255, 102, 0), // T Reddish-yellowy-red
341 new Color(0, 204, 255), // W Blueish-greeny-green
342 new Color(0, 255, 204), // Y Greenish-bluey-green
343 new Color(153, 255, 0), // V Yellowish-greeny-yellow
352 public static final Color[] nucleotide =
353 { new Color(100, 247, 63), // A
354 new Color(255, 179, 64), // C
355 new Color(235, 65, 60), // G
356 new Color(60, 136, 238), // T
357 new Color(60, 136, 238), // U
358 Color.white, // I (inosine)
359 Color.white, // X (xanthine)
366 // Added for PurinePyrimidineColourScheme
367 public static final Color[] purinepyrimidine =
368 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
369 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
370 Color.white, // all other nucleotides
375 public static final Color[] zappo =
384 midBlue,// Color.red, // H
405 // Dunno where I got these numbers from
406 public static final double[] hyd2 =
432 public static final double[] helix =
433 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
434 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
436 public static final double helixmin = 0.57;
438 public static final double helixmax = 1.51;
440 public static final double[] strand =
441 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
442 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
444 public static final double strandmin = 0.37;
446 public static final double strandmax = 1.7;
448 public static final double[] turn =
449 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
450 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
453 public static final double turnmin = 0.47;
455 public static final double turnmax = 1.56;
457 public static final double[] buried =
458 { 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,
459 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
461 public static final double buriedmin = 0.05;
463 public static final double buriedmax = 4.6;
465 // This is hydropathy index
466 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
467 // 1157, 105-132, 1982
468 public static final double[] hyd =
469 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
470 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
472 public static final double hydmax = 4.5;
474 public static final double hydmin = -3.9;
476 // public static final double hydmax = 1.38;
477 // public static final double hydmin = -2.53;
478 private static final int[][] BLOSUM62 =
480 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
481 -2, 0, -2, -1, 0, -4 },
482 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
483 -2, -3, -1, 0, -1, -4 },
484 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
486 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
487 -3, -3, 4, 1, -1, -4 },
488 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
489 -2, -2, -1, -3, -3, -2, -4 },
490 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
492 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
494 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
495 -3, -3, -1, -2, -1, -4 },
496 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
497 2, -3, 0, 0, -1, -4 },
498 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
499 -1, 3, -3, -3, -1, -4 },
500 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
501 -1, 1, -4, -3, -1, -4 },
502 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
503 -2, -2, 0, 1, -1, -4 },
504 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
505 -1, 1, -3, -1, -1, -4 },
506 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
507 3, -1, -3, -3, -1, -4 },
508 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
509 -4, -3, -2, -2, -1, -2, -4 },
510 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
512 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
513 -2, 0, -1, -1, 0, -4 },
514 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
515 11, 2, -3, -4, -3, -2, -4 },
516 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
517 2, 7, -1, -3, -2, -1, -4 },
518 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
519 -1, 4, -3, -2, -1, -4 },
520 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
521 -3, -3, 4, 1, -1, -4 },
522 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
524 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
525 -2, -1, -1, -1, -1, -1, -4 },
526 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
527 -4, -4, -4, -4, -4, -4, 1 }, };
529 static final int[][] PAM250 =
531 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
533 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
535 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
537 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
539 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
540 -8, 0, -2, -4, -5, -3, -8 },
541 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
543 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
545 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
547 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
549 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
550 -1, 4, -2, -2, -1, -8 },
551 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
552 -1, 2, -3, -3, -1, -8 },
553 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
555 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
556 -2, 2, -2, -2, -1, -8 },
557 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
558 7, -1, -4, -5, -2, -8 },
559 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
561 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
563 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
565 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
566 17, 0, -6, -5, -6, -4, -8 },
567 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
568 10, -2, -3, -4, -2, -8 },
569 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
570 -2, 4, -2, -2, -1, -8 },
571 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
573 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
575 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
576 -2, -1, -1, -1, -1, -8 },
577 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
578 -8, -8, -8, -8, -8, -8, 1 }, };
580 public static final Hashtable ssHash = new Hashtable(); // stores the number
585 ssHash.put("H", Color.magenta);
586 ssHash.put("E", Color.yellow);
587 ssHash.put("-", Color.white);
588 ssHash.put(".", Color.white);
589 ssHash.put("S", Color.cyan);
590 ssHash.put("T", Color.blue);
591 ssHash.put("G", Color.pink);
592 ssHash.put("I", Color.pink);
593 ssHash.put("B", Color.yellow);
597 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
598 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
601 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
602 // Will equate sequences if working with mixed nucleotide sets.
603 // treats T and U identically. R and Y weak equivalence with AG and CTU.
604 // N matches any other base weakly
606 static final int[][] DNA =
608 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
609 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
610 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
611 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
612 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
613 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
614 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
615 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
616 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
617 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
618 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
621 * register matrices in list
625 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
626 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
627 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
631 public static final Color[] pidColours =
632 { midBlue, new Color(153, 153, 255),
634 new Color(204, 204, 255), };
636 public static final float[] pidThresholds =
639 public static Map<String, List<String>> codonHash = new HashMap<String, List<String>>();
641 private static List<String> Lys = new ArrayList<String>();
643 private static List<String> Asn = new ArrayList<String>();
645 private static List<String> Gln = new ArrayList<String>();
647 private static List<String> His = new ArrayList<String>();
649 private static List<String> Glu = new ArrayList<String>();
651 private static List<String> Asp = new ArrayList<String>();
653 private static List<String> Tyr = new ArrayList<String>();
655 private static List<String> Thr = new ArrayList<String>();
657 private static List<String> Pro = new ArrayList<String>();
659 private static List<String> Ala = new ArrayList<String>();
661 private static List<String> Ser = new ArrayList<String>();
663 private static List<String> Arg = new ArrayList<String>();
665 private static List<String> Gly = new ArrayList<String>();
667 private static List<String> Trp = new ArrayList<String>();
669 private static List<String> Cys = new ArrayList<String>();
671 private static List<String> Ile = new ArrayList<String>();
673 private static List<String> Met = new ArrayList<String>();
675 private static List<String> Leu = new ArrayList<String>();
677 private static List<String> Val = new ArrayList<String>();
679 private static List<String> Phe = new ArrayList<String>();
681 public static List<String> STOP = new ArrayList<String>();
683 public static String START = "ATG";
687 codonHash.put("K", Lys);
688 codonHash.put("N", Asn);
689 codonHash.put("Q", Gln);
690 codonHash.put("H", His);
691 codonHash.put("E", Glu);
692 codonHash.put("D", Asp);
693 codonHash.put("Y", Tyr);
694 codonHash.put("T", Thr);
695 codonHash.put("P", Pro);
696 codonHash.put("A", Ala);
697 codonHash.put("S", Ser);
698 codonHash.put("R", Arg);
699 codonHash.put("G", Gly);
700 codonHash.put("W", Trp);
701 codonHash.put("C", Cys);
702 codonHash.put("I", Ile);
703 codonHash.put("M", Met);
704 codonHash.put("L", Leu);
705 codonHash.put("V", Val);
706 codonHash.put("F", Phe);
707 codonHash.put("STOP", STOP);
711 * Nucleotide Ambiguity Codes
713 public static final Map<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
716 * Codon triplets with additional symbols for unambiguous codons that include
719 public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
722 * all ambiguity codes for a given base
724 public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
729 * Ambiguity codes as per http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html
731 ambiguityCodes.put("R", new String[]
733 ambiguityCodes.put("Y", new String[]
735 ambiguityCodes.put("W", new String[]
737 ambiguityCodes.put("S", new String[]
739 ambiguityCodes.put("M", new String[]
741 ambiguityCodes.put("K", new String[]
743 ambiguityCodes.put("H", new String[]
745 ambiguityCodes.put("B", new String[]
747 ambiguityCodes.put("V", new String[]
749 ambiguityCodes.put("D", new String[]
751 ambiguityCodes.put("N", new String[]
752 { "G", "A", "T", "C" });
754 // Now build codon translation table
755 codonHash2.put("AAA", "K");
756 codonHash2.put("AAG", "K");
757 codonHash2.put("AAC", "N");
758 codonHash2.put("AAT", "N");
760 codonHash2.put("CAA", "Q");
761 codonHash2.put("CAG", "Q");
762 codonHash2.put("CAC", "H");
763 codonHash2.put("CAT", "H");
765 codonHash2.put("GAA", "E");
766 codonHash2.put("GAG", "E");
767 codonHash2.put("GAC", "D");
768 codonHash2.put("GAT", "D");
770 codonHash2.put("TAC", "Y");
771 codonHash2.put("TAT", "Y");
773 codonHash2.put("ACA", "T");
774 codonHash2.put("ACC", "T");
775 codonHash2.put("ACT", "T");
776 codonHash2.put("ACG", "T");
778 codonHash2.put("CCA", "P");
779 codonHash2.put("CCG", "P");
780 codonHash2.put("CCC", "P");
781 codonHash2.put("CCT", "P");
783 codonHash2.put("GCA", "A");
784 codonHash2.put("GCG", "A");
785 codonHash2.put("GCC", "A");
786 codonHash2.put("GCT", "A");
788 codonHash2.put("TCA", "S");
789 codonHash2.put("TCG", "S");
790 codonHash2.put("TCC", "S");
791 codonHash2.put("TCT", "S");
792 codonHash2.put("AGC", "S");
793 codonHash2.put("AGT", "S");
795 codonHash2.put("AGA", "R");
796 codonHash2.put("AGG", "R");
797 codonHash2.put("CGA", "R");
798 codonHash2.put("CGG", "R");
799 codonHash2.put("CGC", "R");
800 codonHash2.put("CGT", "R");
802 codonHash2.put("GGA", "G");
803 codonHash2.put("GGG", "G");
804 codonHash2.put("GGC", "G");
805 codonHash2.put("GGT", "G");
807 codonHash2.put("TGA", "*");
808 codonHash2.put("TAA", "*");
809 codonHash2.put("TAG", "*");
811 codonHash2.put("TGG", "W");
813 codonHash2.put("TGC", "C");
814 codonHash2.put("TGT", "C");
816 codonHash2.put("ATA", "I");
817 codonHash2.put("ATC", "I");
818 codonHash2.put("ATT", "I");
820 codonHash2.put("ATG", "M");
822 codonHash2.put("CTA", "L");
823 codonHash2.put("CTG", "L");
824 codonHash2.put("CTC", "L");
825 codonHash2.put("CTT", "L");
826 codonHash2.put("TTA", "L");
827 codonHash2.put("TTG", "L");
829 codonHash2.put("GTA", "V");
830 codonHash2.put("GTG", "V");
831 codonHash2.put("GTC", "V");
832 codonHash2.put("GTT", "V");
834 codonHash2.put("TTC", "F");
835 codonHash2.put("TTT", "F");
837 buildAmbiguityCodonSet();
841 * programmatic generation of codons including ambiguity codes
843 public static void buildAmbiguityCodonSet()
845 if (_ambiguityCodes.size() > 0)
848 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
851 // Invert the ambiguity code set
852 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
854 for (String r : acode.getValue())
856 List<String> codesfor = _ambiguityCodes.get(r);
857 if (codesfor == null)
859 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
861 if (!codesfor.contains(acode.getKey()))
863 codesfor.add(acode.getKey());
868 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
869 + acode.getKey() + " in residue " + r);
873 // and programmatically add in the ambiguity codes that yield the same amino
875 String[] unambcodons = codonHash2.keySet().toArray(
876 new String[codonHash2.size()]);
877 for (String codon : unambcodons)
879 String residue = codonHash2.get(codon);
880 String acodon[][] = new String[codon.length()][];
881 for (int i = 0, iSize = codon.length(); i < iSize; i++)
883 String _ac = "" + codon.charAt(i);
884 List<String> acodes = _ambiguityCodes.get(_ac);
887 acodon[i] = acodes.toArray(new String[acodes.size()]);
891 acodon[i] = new String[]
895 // enumerate all combinations and test for veracity of translation
896 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
897 for (int i = 0; i < tpos.length; i++)
901 tpos[acodon.length - 1] = 0;
903 while (tpos[0] < acodon[0].length)
905 // make all codons for this combination
906 char allres[][] = new char[tpos.length][];
909 for (ipos = 0; ipos < tpos.length; ipos++)
911 if (acodon[ipos].length == 0 || tpos[ipos] < 0)
913 _acodon += codon.charAt(ipos);
914 allres[ipos] = new char[]
915 { codon.charAt(ipos) };
919 _acodon += acodon[ipos][tpos[ipos]];
920 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
921 allres[ipos] = new char[altbase.length];
923 for (String ab : altbase)
925 allres[ipos][j++] = ab.charAt(0);
929 // test all codons for this combination
930 for (ipos = 0; ipos < cpos.length; ipos++)
934 boolean valid = true;
938 for (j = 0; j < cpos.length; j++)
940 _codon += allres[j][cpos[j]];
942 String tr = codonHash2.get(_codon);
943 if (valid = (tr != null && tr.equals(residue)))
945 // advance to next combination
946 ipos = acodon.length - 1;
947 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
953 } while (valid && cpos[0] < allres[0].length);
956 // Add this to the set of codons we will translate
957 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
959 codonHash2.put(_acodon, residue);
963 // System.err.println("Rejecting ambiguity codon: " + _acodon
964 // + " for " + residue);
967 ipos = acodon.length - 1;
968 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1063 // Stores residue codes/names and colours and other things
1064 public static Hashtable propHash = new Hashtable();
1066 public static Hashtable hydrophobic = new Hashtable();
1068 public static Hashtable polar = new Hashtable();
1070 public static Hashtable small = new Hashtable();
1072 public static Hashtable positive = new Hashtable();
1074 public static Hashtable negative = new Hashtable();
1076 public static Hashtable charged = new Hashtable();
1078 public static Hashtable aromatic = new Hashtable();
1080 public static Hashtable aliphatic = new Hashtable();
1082 public static Hashtable tiny = new Hashtable();
1084 public static Hashtable proline = new Hashtable();
1088 hydrophobic.put("I", new Integer(1));
1089 hydrophobic.put("L", new Integer(1));
1090 hydrophobic.put("V", new Integer(1));
1091 hydrophobic.put("C", new Integer(1));
1092 hydrophobic.put("A", new Integer(1));
1093 hydrophobic.put("G", new Integer(1));
1094 hydrophobic.put("M", new Integer(1));
1095 hydrophobic.put("F", new Integer(1));
1096 hydrophobic.put("Y", new Integer(1));
1097 hydrophobic.put("W", new Integer(1));
1098 hydrophobic.put("H", new Integer(1));
1099 hydrophobic.put("K", new Integer(1));
1100 hydrophobic.put("X", new Integer(1));
1101 hydrophobic.put("-", new Integer(1));
1102 hydrophobic.put("*", new Integer(1));
1103 hydrophobic.put("R", new Integer(0));
1104 hydrophobic.put("E", new Integer(0));
1105 hydrophobic.put("Q", new Integer(0));
1106 hydrophobic.put("D", new Integer(0));
1107 hydrophobic.put("N", new Integer(0));
1108 hydrophobic.put("S", new Integer(0));
1109 hydrophobic.put("T", new Integer(0));
1110 hydrophobic.put("P", new Integer(0));
1115 polar.put("Y", new Integer(1));
1116 polar.put("W", new Integer(1));
1117 polar.put("H", new Integer(1));
1118 polar.put("K", new Integer(1));
1119 polar.put("R", new Integer(1));
1120 polar.put("E", new Integer(1));
1121 polar.put("Q", new Integer(1));
1122 polar.put("D", new Integer(1));
1123 polar.put("N", new Integer(1));
1124 polar.put("S", new Integer(1));
1125 polar.put("T", new Integer(1));
1126 polar.put("X", new Integer(1));
1127 polar.put("-", new Integer(1));
1128 polar.put("*", new Integer(1));
1129 polar.put("I", new Integer(0));
1130 polar.put("L", new Integer(0));
1131 polar.put("V", new Integer(0));
1132 polar.put("C", new Integer(0));
1133 polar.put("A", new Integer(0));
1134 polar.put("G", new Integer(0));
1135 polar.put("M", new Integer(0));
1136 polar.put("F", new Integer(0));
1137 polar.put("P", new Integer(0));
1142 small.put("I", new Integer(0));
1143 small.put("L", new Integer(0));
1144 small.put("V", new Integer(1));
1145 small.put("C", new Integer(1));
1146 small.put("A", new Integer(1));
1147 small.put("G", new Integer(1));
1148 small.put("M", new Integer(0));
1149 small.put("F", new Integer(0));
1150 small.put("Y", new Integer(0));
1151 small.put("W", new Integer(0));
1152 small.put("H", new Integer(0));
1153 small.put("K", new Integer(0));
1154 small.put("R", new Integer(0));
1155 small.put("E", new Integer(0));
1156 small.put("Q", new Integer(0));
1157 small.put("D", new Integer(1));
1158 small.put("N", new Integer(1));
1159 small.put("S", new Integer(1));
1160 small.put("T", new Integer(1));
1161 small.put("P", new Integer(1));
1162 small.put("-", new Integer(1));
1163 small.put("*", new Integer(1));
1168 positive.put("I", new Integer(0));
1169 positive.put("L", new Integer(0));
1170 positive.put("V", new Integer(0));
1171 positive.put("C", new Integer(0));
1172 positive.put("A", new Integer(0));
1173 positive.put("G", new Integer(0));
1174 positive.put("M", new Integer(0));
1175 positive.put("F", new Integer(0));
1176 positive.put("Y", new Integer(0));
1177 positive.put("W", new Integer(0));
1178 positive.put("H", new Integer(1));
1179 positive.put("K", new Integer(1));
1180 positive.put("R", new Integer(1));
1181 positive.put("E", new Integer(0));
1182 positive.put("Q", new Integer(0));
1183 positive.put("D", new Integer(0));
1184 positive.put("N", new Integer(0));
1185 positive.put("S", new Integer(0));
1186 positive.put("T", new Integer(0));
1187 positive.put("P", new Integer(0));
1188 positive.put("-", new Integer(1));
1189 positive.put("*", new Integer(1));
1194 negative.put("I", new Integer(0));
1195 negative.put("L", new Integer(0));
1196 negative.put("V", new Integer(0));
1197 negative.put("C", new Integer(0));
1198 negative.put("A", new Integer(0));
1199 negative.put("G", new Integer(0));
1200 negative.put("M", new Integer(0));
1201 negative.put("F", new Integer(0));
1202 negative.put("Y", new Integer(0));
1203 negative.put("W", new Integer(0));
1204 negative.put("H", new Integer(0));
1205 negative.put("K", new Integer(0));
1206 negative.put("R", new Integer(0));
1207 negative.put("E", new Integer(1));
1208 negative.put("Q", new Integer(0));
1209 negative.put("D", new Integer(1));
1210 negative.put("N", new Integer(0));
1211 negative.put("S", new Integer(0));
1212 negative.put("T", new Integer(0));
1213 negative.put("P", new Integer(0));
1214 negative.put("-", new Integer(1));
1215 negative.put("*", new Integer(1));
1220 charged.put("I", new Integer(0));
1221 charged.put("L", new Integer(0));
1222 charged.put("V", new Integer(0));
1223 charged.put("C", new Integer(0));
1224 charged.put("A", new Integer(0));
1225 charged.put("G", new Integer(0));
1226 charged.put("M", new Integer(0));
1227 charged.put("F", new Integer(0));
1228 charged.put("Y", new Integer(0));
1229 charged.put("W", new Integer(0));
1230 charged.put("H", new Integer(1));
1231 charged.put("K", new Integer(1));
1232 charged.put("R", new Integer(1));
1233 charged.put("E", new Integer(1));
1234 charged.put("Q", new Integer(0));
1235 charged.put("D", new Integer(1));
1236 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1237 // Alternative would be charged and
1238 // negative (in basic form)?
1239 charged.put("S", new Integer(0));
1240 charged.put("T", new Integer(0));
1241 charged.put("P", new Integer(0));
1242 charged.put("-", new Integer(1));
1243 charged.put("*", new Integer(1));
1248 aromatic.put("I", new Integer(0));
1249 aromatic.put("L", new Integer(0));
1250 aromatic.put("V", new Integer(0));
1251 aromatic.put("C", new Integer(0));
1252 aromatic.put("A", new Integer(0));
1253 aromatic.put("G", new Integer(0));
1254 aromatic.put("M", new Integer(0));
1255 aromatic.put("F", new Integer(1));
1256 aromatic.put("Y", new Integer(1));
1257 aromatic.put("W", new Integer(1));
1258 aromatic.put("H", new Integer(1));
1259 aromatic.put("K", new Integer(0));
1260 aromatic.put("R", new Integer(0));
1261 aromatic.put("E", new Integer(0));
1262 aromatic.put("Q", new Integer(0));
1263 aromatic.put("D", new Integer(0));
1264 aromatic.put("N", new Integer(0));
1265 aromatic.put("S", new Integer(0));
1266 aromatic.put("T", new Integer(0));
1267 aromatic.put("P", new Integer(0));
1268 aromatic.put("-", new Integer(1));
1269 aromatic.put("*", new Integer(1));
1274 aliphatic.put("I", new Integer(1));
1275 aliphatic.put("L", new Integer(1));
1276 aliphatic.put("V", new Integer(1));
1277 aliphatic.put("C", new Integer(0));
1278 aliphatic.put("A", new Integer(0));
1279 aliphatic.put("G", new Integer(0));
1280 aliphatic.put("M", new Integer(0));
1281 aliphatic.put("F", new Integer(0));
1282 aliphatic.put("Y", new Integer(0));
1283 aliphatic.put("W", new Integer(0));
1284 aliphatic.put("H", new Integer(0));
1285 aliphatic.put("K", new Integer(0));
1286 aliphatic.put("R", new Integer(0));
1287 aliphatic.put("E", new Integer(0));
1288 aliphatic.put("Q", new Integer(0));
1289 aliphatic.put("D", new Integer(0));
1290 aliphatic.put("N", new Integer(0));
1291 aliphatic.put("S", new Integer(0));
1292 aliphatic.put("T", new Integer(0));
1293 aliphatic.put("P", new Integer(0));
1294 aliphatic.put("-", new Integer(1));
1295 aliphatic.put("*", new Integer(1));
1300 tiny.put("I", new Integer(0));
1301 tiny.put("L", new Integer(0));
1302 tiny.put("V", new Integer(0));
1303 tiny.put("C", new Integer(0));
1304 tiny.put("A", new Integer(1));
1305 tiny.put("G", new Integer(1));
1306 tiny.put("M", new Integer(0));
1307 tiny.put("F", new Integer(0));
1308 tiny.put("Y", new Integer(0));
1309 tiny.put("W", new Integer(0));
1310 tiny.put("H", new Integer(0));
1311 tiny.put("K", new Integer(0));
1312 tiny.put("R", new Integer(0));
1313 tiny.put("E", new Integer(0));
1314 tiny.put("Q", new Integer(0));
1315 tiny.put("D", new Integer(0));
1316 tiny.put("N", new Integer(0));
1317 tiny.put("S", new Integer(1));
1318 tiny.put("T", new Integer(0));
1319 tiny.put("P", new Integer(0));
1320 tiny.put("-", new Integer(1));
1321 tiny.put("*", new Integer(1));
1326 proline.put("I", new Integer(0));
1327 proline.put("L", new Integer(0));
1328 proline.put("V", new Integer(0));
1329 proline.put("C", new Integer(0));
1330 proline.put("A", new Integer(0));
1331 proline.put("G", new Integer(0));
1332 proline.put("M", new Integer(0));
1333 proline.put("F", new Integer(0));
1334 proline.put("Y", new Integer(0));
1335 proline.put("W", new Integer(0));
1336 proline.put("H", new Integer(0));
1337 proline.put("K", new Integer(0));
1338 proline.put("R", new Integer(0));
1339 proline.put("E", new Integer(0));
1340 proline.put("Q", new Integer(0));
1341 proline.put("D", new Integer(0));
1342 proline.put("N", new Integer(0));
1343 proline.put("S", new Integer(0));
1344 proline.put("T", new Integer(0));
1345 proline.put("P", new Integer(1));
1346 proline.put("-", new Integer(1));
1347 proline.put("*", new Integer(1));
1352 propHash.put("hydrophobic", hydrophobic);
1353 propHash.put("small", small);
1354 propHash.put("positive", positive);
1355 propHash.put("negative", negative);
1356 propHash.put("charged", charged);
1357 propHash.put("aromatic", aromatic);
1358 propHash.put("aliphatic", aliphatic);
1359 propHash.put("tiny", tiny);
1360 propHash.put("proline", proline);
1361 propHash.put("polar", polar);
1365 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1366 for (int i = 0; i < maxProteinIndex; i++)
1368 int maxF = 0, maxP = 0, maxEP = 0;
1378 for (int j = i + 1; j < maxProteinIndex; j++)
1389 propMatrixF[i][j] = 0;
1390 propMatrixPos[i][j] = 0;
1391 propMatrixEpos[i][j] = 0;
1392 for (Enumeration<String> en = propHash.keys(); en
1393 .hasMoreElements();)
1395 String ph = en.nextElement();
1396 Map<String, Integer> pph = (Map<String, Integer>) propHash
1398 if (pph.get(ic) != null && pph.get(jc) != null)
1400 int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1401 // Still working on these definitions.
1402 propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1403 propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1404 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1405 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1406 propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1407 propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1410 if (maxF < propMatrixF[i][j])
1412 maxF = propMatrixF[i][j];
1414 if (maxP < propMatrixPos[i][j])
1416 maxP = propMatrixPos[i][j];
1418 if (maxEP < propMatrixEpos[i][j])
1420 maxEP = propMatrixEpos[i][j];
1423 propMatrixF[i][i] = maxF;
1424 propMatrixPos[i][i] = maxP;
1425 propMatrixEpos[i][i] = maxEP;
1427 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1428 // scoreMatrices.put("Conservation Pos", new
1429 // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1430 // scoreMatrices.put("Conservation Both", new
1431 // ScoreMatrix("Conservation Both",propMatrixF,0));
1432 // scoreMatrices.put("Conservation EnhPos", new
1433 // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1434 scoreMatrices.put("PID", new PIDScoreModel());
1435 scoreMatrices.put("Displayed Features", new FeatureScoreModel());
1438 private ResidueProperties()
1442 public static double getHydmax()
1447 public static double getHydmin()
1452 public static double[] getHyd()
1457 public static Map<String, Integer> getAA3Hash()
1462 public static int[][] getDNA()
1464 return ResidueProperties.DNA;
1467 public static int[][] getBLOSUM62()
1469 return ResidueProperties.BLOSUM62;
1472 public static int getPAM250(String A1, String A2)
1474 return getPAM250(A1.charAt(0), A2.charAt(0));
1477 public static int getBLOSUM62(char c1, char c2)
1483 int a = aaIndex[c1];
1484 int b = aaIndex[c2];
1486 pog = ResidueProperties.BLOSUM62[a][b];
1487 } catch (Exception e)
1489 // System.out.println("Unknown residue in " + A1 + " " + A2);
1495 public static Vector getCodons(String res)
1497 if (codonHash.containsKey(res))
1499 return (Vector) codonHash.get(res);
1505 public static String codonTranslate(String lccodon)
1509 return _codonTranslate(lccodon);
1511 String cdn = codonHash2.get(lccodon.toUpperCase());
1512 if (cdn != null && cdn.equals("*"))
1519 public static String _codonTranslate(String lccodon)
1521 String codon = lccodon.toUpperCase();
1522 // all base ambiguity codes yield an 'X' amino acid residue
1523 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1527 for (String key : codonHash.keySet())
1529 if (codonHash.get(key).contains(codon))
1538 public static int[][] getDefaultPeptideMatrix()
1540 return ResidueProperties.getBLOSUM62();
1543 public static int[][] getDefaultDnaMatrix()
1545 return ResidueProperties.getDNA();
1549 * get a ScoreMatrix based on its string name
1552 * @return matrix in scoreMatrices with key pwtype or null
1554 public static ScoreMatrix getScoreMatrix(String pwtype)
1556 Object val = scoreMatrices.get(pwtype);
1557 if (val != null && val instanceof ScoreMatrix)
1559 return (ScoreMatrix) val;
1565 * get a ScoreModel based on its string name
1568 * @return scoremodel of type pwtype or null
1570 public static ScoreModelI getScoreModel(String pwtype)
1572 return scoreMatrices.get(pwtype);
1575 public static int getPAM250(char c, char d)
1580 int pog = ResidueProperties.PAM250[a][b];
1585 public static Hashtable toDssp3State;
1588 toDssp3State = new Hashtable();
1589 toDssp3State.put("H", "H");
1590 toDssp3State.put("E", "E");
1591 toDssp3State.put("C", " ");
1592 toDssp3State.put(" ", " ");
1593 toDssp3State.put("T", " ");
1594 toDssp3State.put("B", "E");
1595 toDssp3State.put("G", "H");
1596 toDssp3State.put("I", "H");
1597 toDssp3State.put("X", " ");
1601 * translate from other dssp secondary structure alphabets to 3-state
1604 * @return ssstring as a three-state secondary structure assignment.
1606 public static String getDssp3state(String ssstring)
1608 if (ssstring == null)
1612 StringBuffer ss = new StringBuffer();
1613 for (int i = 0; i < ssstring.length(); i++)
1615 String ssc = ssstring.substring(i, i + 1);
1616 if (toDssp3State.containsKey(ssc))
1618 ss.append((String) toDssp3State.get(ssc));
1625 return ss.toString();
1629 * Used by getRNASecStrucState
1632 public static Hashtable<String, String> toRNAssState;
1634 public static boolean RNAcloseParen[] = new boolean[255];
1637 toRNAssState = new Hashtable<String, String>();
1638 toRNAssState.put(")", "(");
1639 toRNAssState.put("(", "(");
1640 toRNAssState.put("]", "[");
1641 toRNAssState.put("[", "[");
1642 toRNAssState.put("{", "{");
1643 toRNAssState.put("}", "{");
1644 toRNAssState.put(">", ">");
1645 toRNAssState.put("<", ">");
1646 toRNAssState.put("A", "A");
1647 toRNAssState.put("a", "A");
1648 toRNAssState.put("B", "B");
1649 toRNAssState.put("b", "B");
1650 toRNAssState.put("C", "C");
1651 toRNAssState.put("c", "C");
1652 toRNAssState.put("D", "D");
1653 toRNAssState.put("d", "D");
1654 toRNAssState.put("E", "E");
1655 toRNAssState.put("e", "E");
1656 toRNAssState.put("F", "F");
1657 toRNAssState.put("f", "F");
1658 toRNAssState.put("G", "G");
1659 toRNAssState.put("g", "G");
1660 toRNAssState.put("H", "H");
1661 toRNAssState.put("h", "H");
1662 toRNAssState.put("I", "I");
1663 toRNAssState.put("i", "I");
1664 toRNAssState.put("J", "J");
1665 toRNAssState.put("j", "J");
1666 toRNAssState.put("K", "K");
1667 toRNAssState.put("k", "K");
1668 toRNAssState.put("L", "L");
1669 toRNAssState.put("l", "L");
1670 toRNAssState.put("M", "M");
1671 toRNAssState.put("m", "M");
1672 toRNAssState.put("N", "N");
1673 toRNAssState.put("n", "N");
1674 toRNAssState.put("O", "O");
1675 toRNAssState.put("o", "O");
1676 toRNAssState.put("P", "P");
1677 toRNAssState.put("p", "P");
1678 toRNAssState.put("Q", "Q");
1679 toRNAssState.put("q", "Q");
1680 toRNAssState.put("R", "R");
1681 toRNAssState.put("r", "R");
1682 toRNAssState.put("S", "S");
1683 toRNAssState.put("s", "S");
1684 toRNAssState.put("T", "T");
1685 toRNAssState.put("t", "T");
1686 toRNAssState.put("U", "U");
1687 toRNAssState.put("u", "U");
1688 toRNAssState.put("V", "V");
1689 toRNAssState.put("v", "V");
1690 toRNAssState.put("W", "W");
1691 toRNAssState.put("w", "W");
1692 toRNAssState.put("X", "X");
1693 toRNAssState.put("x", "X");
1694 toRNAssState.put("Y", "Y");
1695 toRNAssState.put("y", "Y");
1696 toRNAssState.put("Z", "Z");
1697 toRNAssState.put("z", "Z");
1698 for (int p = 0; p < RNAcloseParen.length; p++)
1700 RNAcloseParen[p] = false;
1702 for (String k : toRNAssState.keySet())
1704 RNAcloseParen[k.charAt(0)] = k.charAt(0) != toRNAssState.get(k)
1711 modifications.put("MSE", "MET"); // Selenomethionine
1712 // the rest tbc; from
1713 // http://sourceforge.net/p/jmol/mailman/message/12833570/
1714 // modifications.put("CSE", "CYS"); // Selenocysteine
1715 // modifications.put("PTR", "TYR"); // Phosphotyrosine
1716 // modifications.put("SEP", "SER"); // Phosphoserine
1717 // modifications.put("HYP", "PRO"); // 4-hydroxyproline
1718 // modifications.put("5HP", "GLU"); // Pyroglutamic acid; 5-hydroxyproline
1719 // modifications.put("PCA", "GLU"); // Pyroglutamic acid
1720 // modifications.put("LYZ", "LYS"); // 5-hydroxylysine
1723 public static String getCanonicalAminoAcid(String aa)
1725 String canonical = modifications.get(aa);
1726 return canonical == null ? aa : canonical;
1730 * translate to RNA secondary structure representation
1733 * @return ssstring as a RNA-state secondary structure assignment.
1735 public static String getRNASecStrucState(String ssstring)
1737 if (ssstring == null)
1741 StringBuffer ss = new StringBuffer();
1742 for (int i = 0; i < ssstring.length(); i++)
1744 String ssc = ssstring.substring(i, i + 1);
1745 if (toRNAssState.containsKey(ssc))
1747 // valid ss character - so return it
1748 ss.append(ssc); // (String) toRNAssState.get(ssc));
1755 return ss.toString();
1758 public static boolean isCloseParenRNA(char dc)
1760 return RNAcloseParen[dc];
1763 // main method generates perl representation of residue property hash
1765 public static void main(String[] args)
1767 Hashtable aa = new Hashtable();
1768 System.out.println("my %aa = {");
1769 // invert property hashes
1770 Enumeration prop = propHash.keys();
1771 while (prop.hasMoreElements())
1773 String pname = (String) prop.nextElement();
1774 Hashtable phash = (Hashtable) propHash.get(pname);
1775 Enumeration res = phash.keys();
1776 while (res.hasMoreElements())
1778 String rname = (String) res.nextElement();
1779 Vector aprops = (Vector) aa.get(rname);
1782 aprops = new Vector();
1783 aa.put(rname, aprops);
1785 Integer hasprop = (Integer) phash.get(rname);
1786 if (hasprop.intValue() == 1)
1788 aprops.addElement(pname);
1792 Enumeration res = aa.keys();
1793 while (res.hasMoreElements())
1795 String rname = (String) res.nextElement();
1797 System.out.print("'" + rname + "' => [");
1798 Enumeration props = ((Vector) aa.get(rname)).elements();
1799 while (props.hasMoreElements())
1801 System.out.print("'" + (String) props.nextElement() + "'");
1802 if (props.hasMoreElements())
1804 System.out.println(", ");
1807 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1809 System.out.println("};");
1814 * Returns a list of residue characters for the specified inputs
1817 * @param includeAmbiguous
1820 public static List<String> getResidues(boolean nucleotide,
1821 boolean includeAmbiguous)
1823 List<String> result = new ArrayList<String>();
1826 for (String nuc : nucleotideName.keySet())
1828 int val = nucleotideIndex[nuc.charAt(0)];
1829 if ((!includeAmbiguous && val > 4) || (val >= maxNucleotideIndex))
1833 nuc = nuc.toUpperCase();
1834 if (!result.contains(nuc))
1843 for (String res : aa3Hash.keySet())
1845 int index = aa3Hash.get(res).intValue();
1846 if ((!includeAmbiguous && index >= 20) || index >= maxProteinIndex)
1850 res = res.toUpperCase();
1851 if (!result.contains(res))
1862 * Returns the single letter code for a three letter code, or '0' if not known
1864 * @param threeLetterCode
1865 * not case sensitive
1868 public static char getSingleCharacterCode(String threeLetterCode)
1870 if (threeLetterCode == null)
1874 Integer index = ResidueProperties.aa3Hash.get(threeLetterCode
1876 return index == null ? '0' : aa[index].charAt(0);