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 javajs.J2SRequireImport;
34 import jalview.analysis.scoremodels.FeatureScoreModel;
35 import jalview.analysis.scoremodels.PIDScoreModel;
36 import jalview.api.analysis.ScoreModelI;
38 // required because of the static defs
40 @J2SRequireImport({ScoreMatrix.class, PIDScoreModel.class, FeatureScoreModel.class})
41 public class ResidueProperties
43 public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable();
45 // Stores residue codes/names and colours and other things
46 public static final int[] aaIndex; // aaHash version 2.1.1 and below
48 public static final int[] nucleotideIndex;
50 public static final int[] purinepyrimidineIndex;
52 public static final Map<String, Integer> aa3Hash = new HashMap<String, Integer>();
54 public static final Map<String, String> aa2Triplet = new HashMap<String, String>();
56 public static final Map<String, String> nucleotideName = new HashMap<String, String>();
60 aaIndex = new int[255];
61 for (int i = 0; i < 255; i++)
113 aaIndex['u'] = 22; // TODO: selenocystine triplet and codons needed. also
114 // extend subt. matrices
118 * maximum (gap) index for matrices involving protein alphabet
120 public final static int maxProteinIndex = 23;
123 * maximum (gap) index for matrices involving nucleotide alphabet
125 public final static int maxNucleotideIndex = 10;
129 nucleotideIndex = new int[255];
130 for (int i = 0; i < 255; i++)
132 nucleotideIndex[i] = 10; // non-nucleotide symbols are all non-gap gaps.
135 nucleotideIndex['A'] = 0;
136 nucleotideIndex['a'] = 0;
137 nucleotideIndex['C'] = 1;
138 nucleotideIndex['c'] = 1;
139 nucleotideIndex['G'] = 2;
140 nucleotideIndex['g'] = 2;
141 nucleotideIndex['T'] = 3;
142 nucleotideIndex['t'] = 3;
143 nucleotideIndex['U'] = 4;
144 nucleotideIndex['u'] = 4;
145 nucleotideIndex['I'] = 5;
146 nucleotideIndex['i'] = 5;
147 nucleotideIndex['X'] = 6;
148 nucleotideIndex['x'] = 6;
149 nucleotideIndex['R'] = 7;
150 nucleotideIndex['r'] = 7;
151 nucleotideIndex['Y'] = 8;
152 nucleotideIndex['y'] = 8;
153 nucleotideIndex['N'] = 9;
154 nucleotideIndex['n'] = 9;
156 nucleotideName.put("A", "Adenine");
157 nucleotideName.put("a", "Adenine");
158 nucleotideName.put("G", "Guanine");
159 nucleotideName.put("g", "Guanine");
160 nucleotideName.put("C", "Cytosine");
161 nucleotideName.put("c", "Cytosine");
162 nucleotideName.put("T", "Thymine");
163 nucleotideName.put("t", "Thymine");
164 nucleotideName.put("U", "Uracil");
165 nucleotideName.put("u", "Uracil");
166 nucleotideName.put("I", "Inosine");
167 nucleotideName.put("i", "Inosine");
168 nucleotideName.put("X", "Xanthine");
169 nucleotideName.put("x", "Xanthine");
170 nucleotideName.put("R", "Unknown Purine");
171 nucleotideName.put("r", "Unknown Purine");
172 nucleotideName.put("Y", "Unknown Pyrimidine");
173 nucleotideName.put("y", "Unknown Pyrimidine");
174 nucleotideName.put("N", "Unknown");
175 nucleotideName.put("n", "Unknown");
176 nucleotideName.put("W", "Weak nucleotide (A or T)");
177 nucleotideName.put("w", "Weak nucleotide (A or T)");
178 nucleotideName.put("S", "Strong nucleotide (G or C)");
179 nucleotideName.put("s", "Strong nucleotide (G or C)");
180 nucleotideName.put("M", "Amino (A or C)");
181 nucleotideName.put("m", "Amino (A or C)");
182 nucleotideName.put("K", "Keto (G or T)");
183 nucleotideName.put("k", "Keto (G or T)");
184 nucleotideName.put("B", "Not A (G or C or T)");
185 nucleotideName.put("b", "Not A (G or C or T)");
186 nucleotideName.put("H", "Not G (A or C or T)");
187 nucleotideName.put("h", "Not G (A or C or T)");
188 nucleotideName.put("D", "Not C (A or G or T)");
189 nucleotideName.put("d", "Not C (A or G or T)");
190 nucleotideName.put("V", "Not T (A or G or C");
191 nucleotideName.put("v", "Not T (A or G or C");
197 purinepyrimidineIndex = new int[255];
198 for (int i = 0; i < 255; i++)
200 purinepyrimidineIndex[i] = 3; // non-nucleotide symbols are all non-gap
204 purinepyrimidineIndex['A'] = 0;
205 purinepyrimidineIndex['a'] = 0;
206 purinepyrimidineIndex['C'] = 1;
207 purinepyrimidineIndex['c'] = 1;
208 purinepyrimidineIndex['G'] = 0;
209 purinepyrimidineIndex['g'] = 0;
210 purinepyrimidineIndex['T'] = 1;
211 purinepyrimidineIndex['t'] = 1;
212 purinepyrimidineIndex['U'] = 1;
213 purinepyrimidineIndex['u'] = 1;
214 purinepyrimidineIndex['I'] = 2;
215 purinepyrimidineIndex['i'] = 2;
216 purinepyrimidineIndex['X'] = 2;
217 purinepyrimidineIndex['x'] = 2;
218 purinepyrimidineIndex['R'] = 0;
219 purinepyrimidineIndex['r'] = 0;
220 purinepyrimidineIndex['Y'] = 1;
221 purinepyrimidineIndex['y'] = 1;
222 purinepyrimidineIndex['N'] = 2;
223 purinepyrimidineIndex['n'] = 2;
228 aa3Hash.put("ALA", new Integer(0));
229 aa3Hash.put("ARG", new Integer(1));
230 aa3Hash.put("ASN", new Integer(2));
231 aa3Hash.put("ASP", new Integer(3)); // D
232 aa3Hash.put("CYS", new Integer(4));
233 aa3Hash.put("GLN", new Integer(5)); // Q
234 aa3Hash.put("GLU", new Integer(6)); // E
235 aa3Hash.put("GLY", new Integer(7));
236 aa3Hash.put("HIS", new Integer(8));
237 aa3Hash.put("ILE", new Integer(9));
238 aa3Hash.put("LEU", new Integer(10));
239 aa3Hash.put("LYS", new Integer(11));
240 aa3Hash.put("MET", new Integer(12));
241 aa3Hash.put("PHE", new Integer(13));
242 aa3Hash.put("PRO", new Integer(14));
243 aa3Hash.put("SER", new Integer(15));
244 aa3Hash.put("THR", new Integer(16));
245 aa3Hash.put("TRP", new Integer(17));
246 aa3Hash.put("TYR", new Integer(18));
247 aa3Hash.put("VAL", new Integer(19));
248 // IUB Nomenclature for ambiguous peptides
249 aa3Hash.put("ASX", new Integer(20)); // "B";
250 aa3Hash.put("GLX", new Integer(21)); // X
251 aa3Hash.put("XAA", new Integer(22)); // X unknown
252 aa3Hash.put("-", new Integer(23));
253 aa3Hash.put("*", new Integer(23));
254 aa3Hash.put(".", new Integer(23));
255 aa3Hash.put(" ", new Integer(23));
256 aa3Hash.put("Gap", new Integer(23));
261 aa2Triplet.put("A", "ALA");
262 aa2Triplet.put("a", "ALA");
263 aa2Triplet.put("R", "ARG");
264 aa2Triplet.put("r", "ARG");
265 aa2Triplet.put("N", "ASN");
266 aa2Triplet.put("n", "ASN");
267 aa2Triplet.put("D", "ASP");
268 aa2Triplet.put("d", "ASP");
269 aa2Triplet.put("C", "CYS");
270 aa2Triplet.put("c", "CYS");
271 aa2Triplet.put("Q", "GLN");
272 aa2Triplet.put("q", "GLN");
273 aa2Triplet.put("E", "GLU");
274 aa2Triplet.put("e", "GLU");
275 aa2Triplet.put("G", "GLY");
276 aa2Triplet.put("g", "GLY");
277 aa2Triplet.put("H", "HIS");
278 aa2Triplet.put("h", "HIS");
279 aa2Triplet.put("I", "ILE");
280 aa2Triplet.put("i", "ILE");
281 aa2Triplet.put("L", "LEU");
282 aa2Triplet.put("l", "LEU");
283 aa2Triplet.put("K", "LYS");
284 aa2Triplet.put("k", "LYS");
285 aa2Triplet.put("M", "MET");
286 aa2Triplet.put("m", "MET");
287 aa2Triplet.put("F", "PHE");
288 aa2Triplet.put("f", "PHE");
289 aa2Triplet.put("P", "PRO");
290 aa2Triplet.put("p", "PRO");
291 aa2Triplet.put("S", "SER");
292 aa2Triplet.put("s", "SER");
293 aa2Triplet.put("T", "THR");
294 aa2Triplet.put("t", "THR");
295 aa2Triplet.put("W", "TRP");
296 aa2Triplet.put("w", "TRP");
297 aa2Triplet.put("Y", "TYR");
298 aa2Triplet.put("y", "TYR");
299 aa2Triplet.put("V", "VAL");
300 aa2Triplet.put("v", "VAL");
303 public static final String[] aa =
304 { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F",
305 "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " };
307 public static final Color midBlue = new Color(100, 100, 255);
309 public static final Vector scaleColours = new Vector();
313 scaleColours.addElement(new Color(114, 0, 147));
314 scaleColours.addElement(new Color(156, 0, 98));
315 scaleColours.addElement(new Color(190, 0, 0));
316 scaleColours.addElement(Color.red);
317 scaleColours.addElement(new Color(255, 125, 0));
318 scaleColours.addElement(Color.orange);
319 scaleColours.addElement(new Color(255, 194, 85));
320 scaleColours.addElement(Color.yellow);
321 scaleColours.addElement(new Color(255, 255, 181));
322 scaleColours.addElement(Color.white);
325 public static final Color[] taylor =
326 { new Color(204, 255, 0), // A Greenish-yellowy-yellow
327 new Color(0, 0, 255), // R Blueish-bluey-blue
328 new Color(204, 0, 255), // N Blueish-reddy-blue
329 new Color(255, 0, 0), // D Reddish-reddy-red
330 new Color(255, 255, 0), // C Yellowish-yellowy-yellow
331 new Color(255, 0, 204), // Q Reddish-bluey-red
332 new Color(255, 0, 102), // E Blueish-reddy-red
333 new Color(255, 153, 0), // G Yellowy-reddy-yellow
334 new Color(0, 102, 255), // H Greenish-bluey-blue
335 new Color(102, 255, 0), // I Greenish-yellowy-green
336 new Color(51, 255, 0), // L Yellowish-greeny-green
337 new Color(102, 0, 255), // K Reddish-bluey-blue
338 new Color(0, 255, 0), // M Greenish-greeny-green
339 new Color(0, 255, 102), // F Blueish-greeny-green
340 new Color(255, 204, 0), // P Reddish-yellowy-yellow
341 new Color(255, 51, 0), // S Yellowish-reddy-red
342 new Color(255, 102, 0), // T Reddish-yellowy-red
343 new Color(0, 204, 255), // W Blueish-greeny-green
344 new Color(0, 255, 204), // Y Greenish-bluey-green
345 new Color(153, 255, 0), // V Yellowish-greeny-yellow
354 public static final Color[] nucleotide =
355 { new Color(100, 247, 63), // A
356 new Color(255, 179, 64), // C
357 new Color(235, 65, 60), // G
358 new Color(60, 136, 238), // T
359 new Color(60, 136, 238), // U
360 Color.white, // I (inosine)
361 Color.white, // X (xanthine)
368 // Added for PurinePyrimidineColourScheme
369 public static final Color[] purinepyrimidine =
370 { new Color(255, 131, 250), // A, G, R purines purplish/orchid
371 new Color(64, 224, 208), // C,U, T, Y pyrimidines turquoise
372 Color.white, // all other nucleotides
377 public static final Color[] zappo =
386 midBlue,// Color.red, // H
407 // Dunno where I got these numbers from
408 public static final double[] hyd2 =
434 public static final double[] helix =
435 { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16,
436 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 };
438 public static final double helixmin = 0.57;
440 public static final double helixmax = 1.51;
442 public static final double[] strand =
443 { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74,
444 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 };
446 public static final double strandmin = 0.37;
448 public static final double strandmax = 1.7;
450 public static final double[] turn =
451 { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01,
452 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0,
455 public static final double turnmin = 0.47;
457 public static final double turnmax = 1.56;
459 public static final double[] buried =
460 { 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,
461 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 };
463 public static final double buriedmin = 0.05;
465 public static final double buriedmax = 4.6;
467 // This is hydropathy index
468 // Kyte, J., and Doolittle, R.F., J. Mol. Biol.
469 // 1157, 105-132, 1982
470 public static final double[] hyd =
471 { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9,
472 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 };
474 public static final double hydmax = 4.5;
476 public static final double hydmin = -3.9;
478 // public static final double hydmax = 1.38;
479 // public static final double hydmin = -2.53;
480 private static final int[][] BLOSUM62 =
482 { 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3,
483 -2, 0, -2, -1, 0, -4 },
484 { -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3,
485 -2, -3, -1, 0, -1, -4 },
486 { -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2,
488 { -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4,
489 -3, -3, 4, 1, -1, -4 },
490 { 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1,
491 -2, -2, -1, -3, -3, -2, -4 },
492 { -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1,
494 { -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2,
496 { 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2,
497 -3, -3, -1, -2, -1, -4 },
498 { -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2,
499 2, -3, 0, 0, -1, -4 },
500 { -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3,
501 -1, 3, -3, -3, -1, -4 },
502 { -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2,
503 -1, 1, -4, -3, -1, -4 },
504 { -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3,
505 -2, -2, 0, 1, -1, -4 },
506 { -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1,
507 -1, 1, -3, -1, -1, -4 },
508 { -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1,
509 3, -1, -3, -3, -1, -4 },
510 { -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1,
511 -4, -3, -2, -2, -1, -2, -4 },
512 { 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2,
514 { 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2,
515 -2, 0, -1, -1, 0, -4 },
516 { -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2,
517 11, 2, -3, -4, -3, -2, -4 },
518 { -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2,
519 2, 7, -1, -3, -2, -1, -4 },
520 { 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3,
521 -1, 4, -3, -2, -1, -4 },
522 { -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4,
523 -3, -3, 4, 1, -1, -4 },
524 { -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2,
526 { 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0,
527 -2, -1, -1, -1, -1, -1, -4 },
528 { -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
529 -4, -4, -4, -4, -4, -4, 1 }, };
531 static final int[][] PAM250 =
533 { 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3,
535 { -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4,
537 { 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2,
539 { 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4,
541 { -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2,
542 -8, 0, -2, -4, -5, -3, -8 },
543 { 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4,
545 { 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4,
547 { 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5,
549 { -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0,
551 { -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5,
552 -1, 4, -2, -2, -1, -8 },
553 { -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2,
554 -1, 2, -3, -3, -1, -8 },
555 { -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4,
557 { -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4,
558 -2, 2, -2, -2, -1, -8 },
559 { -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0,
560 7, -1, -4, -5, -2, -8 },
561 { 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5,
563 { 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3,
565 { 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3,
567 { -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5,
568 17, 0, -6, -5, -6, -4, -8 },
569 { -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0,
570 10, -2, -3, -4, -2, -8 },
571 { 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6,
572 -2, 4, -2, -2, -1, -8 },
573 { 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3,
575 { 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4,
577 { 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4,
578 -2, -1, -1, -1, -1, -8 },
579 { -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
580 -8, -8, -8, -8, -8, -8, 1 }, };
582 public static final Hashtable ssHash = new Hashtable(); // stores the number
587 ssHash.put("H", Color.magenta);
588 ssHash.put("E", Color.yellow);
589 ssHash.put("-", Color.white);
590 ssHash.put(".", Color.white);
591 ssHash.put("S", Color.cyan);
592 ssHash.put("T", Color.blue);
593 ssHash.put("G", Color.pink);
594 ssHash.put("I", Color.pink);
595 ssHash.put("B", Color.yellow);
599 * new Color(60, 136, 238), // U Color.white, // I Color.white, // X
600 * Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
603 // JBPNote: patch matrix for T/U equivalence when working with DNA or RNA.
604 // Will equate sequences if working with mixed nucleotide sets.
605 // treats T and U identically. R and Y weak equivalence with AG and CTU.
606 // N matches any other base weakly
608 static final int[][] DNA =
610 { 10, -8, -8, -8, -8, 1, 1, 1, -8, 1, 1 }, // A
611 { -8, 10, -8, -8, -8, 1, 1, -8, 1, 1, 1 }, // C
612 { -8, -8, 10, -8, -8, 1, 1, 1, -8, 1, 1 }, // G
613 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // T
614 { -8, -8, -8, 10, 10, 1, 1, -8, 1, 1, 1 }, // U
615 { 1, 1, 1, 1, 1, 10, 0, 0, 0, 1, 1 }, // I
616 { 1, 1, 1, 1, 1, 0, 10, 0, 0, 1, 1 }, // X
617 { 1, -8, 1, -8, -8, 0, 0, 10, -8, 1, 1 }, // R
618 { -8, 1, -8, 1, 1, 0, 0, -8, 10, 1, 1 }, // Y
619 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1 }, // N
620 { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // -
623 * register matrices in list
627 scoreMatrices.put("BLOSUM62", new ScoreMatrix("BLOSUM62", BLOSUM62, 0));
628 scoreMatrices.put("PAM250", new ScoreMatrix("PAM250", PAM250, 0));
629 scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
633 public static final Color[] pidColours =
634 { midBlue, new Color(153, 153, 255),
636 new Color(204, 204, 255), };
638 public static final float[] pidThresholds =
641 public static Map<String, List<String>> codonHash = new HashMap<String, List<String>>();
643 private static List<String> Lys = new ArrayList<String>();
645 private static List<String> Asn = new ArrayList<String>();
647 private static List<String> Gln = new ArrayList<String>();
649 private static List<String> His = new ArrayList<String>();
651 private static List<String> Glu = new ArrayList<String>();
653 private static List<String> Asp = new ArrayList<String>();
655 private static List<String> Tyr = new ArrayList<String>();
657 private static List<String> Thr = new ArrayList<String>();
659 private static List<String> Pro = new ArrayList<String>();
661 private static List<String> Ala = new ArrayList<String>();
663 private static List<String> Ser = new ArrayList<String>();
665 private static List<String> Arg = new ArrayList<String>();
667 private static List<String> Gly = new ArrayList<String>();
669 private static List<String> Trp = new ArrayList<String>();
671 private static List<String> Cys = new ArrayList<String>();
673 private static List<String> Ile = new ArrayList<String>();
675 private static List<String> Met = new ArrayList<String>();
677 private static List<String> Leu = new ArrayList<String>();
679 private static List<String> Val = new ArrayList<String>();
681 private static List<String> Phe = new ArrayList<String>();
683 public static List<String> STOP = new ArrayList<String>();
685 public static String START = "ATG";
689 codonHash.put("K", Lys);
690 codonHash.put("N", Asn);
691 codonHash.put("Q", Gln);
692 codonHash.put("H", His);
693 codonHash.put("E", Glu);
694 codonHash.put("D", Asp);
695 codonHash.put("Y", Tyr);
696 codonHash.put("T", Thr);
697 codonHash.put("P", Pro);
698 codonHash.put("A", Ala);
699 codonHash.put("S", Ser);
700 codonHash.put("R", Arg);
701 codonHash.put("G", Gly);
702 codonHash.put("W", Trp);
703 codonHash.put("C", Cys);
704 codonHash.put("I", Ile);
705 codonHash.put("M", Met);
706 codonHash.put("L", Leu);
707 codonHash.put("V", Val);
708 codonHash.put("F", Phe);
709 codonHash.put("STOP", STOP);
713 * Nucleotide Ambiguity Codes
715 public static final Map<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
718 * Codon triplets with additional symbols for unambiguous codons that include
721 public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
724 * all ambiguity codes for a given base
726 public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
731 * Ambiguity codes as per http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html
733 ambiguityCodes.put("R", new String[]
735 ambiguityCodes.put("Y", new String[]
737 ambiguityCodes.put("W", new String[]
739 ambiguityCodes.put("S", new String[]
741 ambiguityCodes.put("M", new String[]
743 ambiguityCodes.put("K", new String[]
745 ambiguityCodes.put("H", new String[]
747 ambiguityCodes.put("B", new String[]
749 ambiguityCodes.put("V", new String[]
751 ambiguityCodes.put("D", new String[]
753 ambiguityCodes.put("N", new String[]
754 { "G", "A", "T", "C" });
756 // Now build codon translation table
757 codonHash2.put("AAA", "K");
758 codonHash2.put("AAG", "K");
759 codonHash2.put("AAC", "N");
760 codonHash2.put("AAT", "N");
762 codonHash2.put("CAA", "Q");
763 codonHash2.put("CAG", "Q");
764 codonHash2.put("CAC", "H");
765 codonHash2.put("CAT", "H");
767 codonHash2.put("GAA", "E");
768 codonHash2.put("GAG", "E");
769 codonHash2.put("GAC", "D");
770 codonHash2.put("GAT", "D");
772 codonHash2.put("TAC", "Y");
773 codonHash2.put("TAT", "Y");
775 codonHash2.put("ACA", "T");
776 codonHash2.put("ACC", "T");
777 codonHash2.put("ACT", "T");
778 codonHash2.put("ACG", "T");
780 codonHash2.put("CCA", "P");
781 codonHash2.put("CCG", "P");
782 codonHash2.put("CCC", "P");
783 codonHash2.put("CCT", "P");
785 codonHash2.put("GCA", "A");
786 codonHash2.put("GCG", "A");
787 codonHash2.put("GCC", "A");
788 codonHash2.put("GCT", "A");
790 codonHash2.put("TCA", "S");
791 codonHash2.put("TCG", "S");
792 codonHash2.put("TCC", "S");
793 codonHash2.put("TCT", "S");
794 codonHash2.put("AGC", "S");
795 codonHash2.put("AGT", "S");
797 codonHash2.put("AGA", "R");
798 codonHash2.put("AGG", "R");
799 codonHash2.put("CGA", "R");
800 codonHash2.put("CGG", "R");
801 codonHash2.put("CGC", "R");
802 codonHash2.put("CGT", "R");
804 codonHash2.put("GGA", "G");
805 codonHash2.put("GGG", "G");
806 codonHash2.put("GGC", "G");
807 codonHash2.put("GGT", "G");
809 codonHash2.put("TGA", "*");
810 codonHash2.put("TAA", "*");
811 codonHash2.put("TAG", "*");
813 codonHash2.put("TGG", "W");
815 codonHash2.put("TGC", "C");
816 codonHash2.put("TGT", "C");
818 codonHash2.put("ATA", "I");
819 codonHash2.put("ATC", "I");
820 codonHash2.put("ATT", "I");
822 codonHash2.put("ATG", "M");
824 codonHash2.put("CTA", "L");
825 codonHash2.put("CTG", "L");
826 codonHash2.put("CTC", "L");
827 codonHash2.put("CTT", "L");
828 codonHash2.put("TTA", "L");
829 codonHash2.put("TTG", "L");
831 codonHash2.put("GTA", "V");
832 codonHash2.put("GTG", "V");
833 codonHash2.put("GTC", "V");
834 codonHash2.put("GTT", "V");
836 codonHash2.put("TTC", "F");
837 codonHash2.put("TTT", "F");
839 buildAmbiguityCodonSet();
843 * programmatic generation of codons including ambiguity codes
845 public static void buildAmbiguityCodonSet()
847 if (_ambiguityCodes.size() > 0)
850 .println("Ignoring multiple calls to buildAmbiguityCodonSet");
853 // Invert the ambiguity code set
854 for (Map.Entry<String, String[]> acode : ambiguityCodes.entrySet())
856 for (String r : acode.getValue())
858 List<String> codesfor = _ambiguityCodes.get(r);
859 if (codesfor == null)
861 _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
863 if (!codesfor.contains(acode.getKey()))
865 codesfor.add(acode.getKey());
870 .println("Inconsistency in the IUBMB ambiguity code nomenclature table: collision for "
871 + acode.getKey() + " in residue " + r);
875 // and programmatically add in the ambiguity codes that yield the same amino
879 String[] unambcodons = codonHash2.keySet().toArray(
880 new String[codonHash2.size()]);
881 for (String codon : unambcodons)
883 String residue = codonHash2.get(codon);
884 String acodon[][] = new String[codon.length()][];
885 for (int i = 0, iSize = codon.length(); i < iSize; i++)
887 String _ac = "" + codon.charAt(i);
888 List<String> acodes = _ambiguityCodes.get(_ac);
891 acodon[i] = acodes.toArray(new String[acodes.size()]);
895 acodon[i] = new String[]
899 // enumerate all combinations and test for veracity of translation
900 int tpos[] = new int[codon.length()], cpos[] = new int[codon.length()];
901 for (int i = 0; i < tpos.length; i++)
905 tpos[acodon.length - 1] = 0;
907 while (tpos[0] < acodon[0].length)
909 // make all codons for this combination
910 char allres[][] = new char[tpos.length][];
913 for (ipos = 0; ipos < tpos.length; ipos++)
915 if (acodon[ipos].length == 0 || tpos[ipos] < 0)
917 _acodon += codon.charAt(ipos);
918 allres[ipos] = new char[]
919 { codon.charAt(ipos) };
923 _acodon += acodon[ipos][tpos[ipos]];
924 String[] altbase = ambiguityCodes.get(acodon[ipos][tpos[ipos]]);
925 allres[ipos] = new char[altbase.length];
927 for (String ab : altbase)
929 allres[ipos][j++] = ab.charAt(0);
933 // test all codons for this combination
934 for (ipos = 0; ipos < cpos.length; ipos++)
938 boolean valid = true;
942 for (j = 0; j < cpos.length; j++)
944 _codon += allres[j][cpos[j]];
946 String tr = codonHash2.get(_codon);
947 if (valid = (tr != null && tr.equals(residue)))
949 // advance to next combination
950 ipos = acodon.length - 1;
951 while (++cpos[ipos] >= allres[ipos].length && ipos > 0)
957 } while (valid && cpos[0] < allres[0].length);
960 // Add this to the set of codons we will translate
961 // System.out.println("Adding ambiguity codon: " + _acodon + " for "
963 codonHash2.put(_acodon, residue);
967 // System.err.println("Rejecting ambiguity codon: " + _acodon
968 // + " for " + residue);
971 ipos = acodon.length - 1;
972 while (++tpos[ipos] >= acodon[ipos].length && ipos > 0)
1067 // Stores residue codes/names and colours and other things
1068 public static Hashtable propHash = new Hashtable();
1070 public static Hashtable hydrophobic = new Hashtable();
1072 public static Hashtable polar = new Hashtable();
1074 public static Hashtable small = new Hashtable();
1076 public static Hashtable positive = new Hashtable();
1078 public static Hashtable negative = new Hashtable();
1080 public static Hashtable charged = new Hashtable();
1082 public static Hashtable aromatic = new Hashtable();
1084 public static Hashtable aliphatic = new Hashtable();
1086 public static Hashtable tiny = new Hashtable();
1088 public static Hashtable proline = new Hashtable();
1092 hydrophobic.put("I", new Integer(1));
1093 hydrophobic.put("L", new Integer(1));
1094 hydrophobic.put("V", new Integer(1));
1095 hydrophobic.put("C", new Integer(1));
1096 hydrophobic.put("A", new Integer(1));
1097 hydrophobic.put("G", new Integer(1));
1098 hydrophobic.put("M", new Integer(1));
1099 hydrophobic.put("F", new Integer(1));
1100 hydrophobic.put("Y", new Integer(1));
1101 hydrophobic.put("W", new Integer(1));
1102 hydrophobic.put("H", new Integer(1));
1103 hydrophobic.put("K", new Integer(1));
1104 hydrophobic.put("X", new Integer(1));
1105 hydrophobic.put("-", new Integer(1));
1106 hydrophobic.put("*", new Integer(1));
1107 hydrophobic.put("R", new Integer(0));
1108 hydrophobic.put("E", new Integer(0));
1109 hydrophobic.put("Q", new Integer(0));
1110 hydrophobic.put("D", new Integer(0));
1111 hydrophobic.put("N", new Integer(0));
1112 hydrophobic.put("S", new Integer(0));
1113 hydrophobic.put("T", new Integer(0));
1114 hydrophobic.put("P", new Integer(0));
1119 polar.put("Y", new Integer(1));
1120 polar.put("W", new Integer(1));
1121 polar.put("H", new Integer(1));
1122 polar.put("K", new Integer(1));
1123 polar.put("R", new Integer(1));
1124 polar.put("E", new Integer(1));
1125 polar.put("Q", new Integer(1));
1126 polar.put("D", new Integer(1));
1127 polar.put("N", new Integer(1));
1128 polar.put("S", new Integer(1));
1129 polar.put("T", new Integer(1));
1130 polar.put("X", new Integer(1));
1131 polar.put("-", new Integer(1));
1132 polar.put("*", new Integer(1));
1133 polar.put("I", new Integer(0));
1134 polar.put("L", new Integer(0));
1135 polar.put("V", new Integer(0));
1136 polar.put("C", new Integer(0));
1137 polar.put("A", new Integer(0));
1138 polar.put("G", new Integer(0));
1139 polar.put("M", new Integer(0));
1140 polar.put("F", new Integer(0));
1141 polar.put("P", new Integer(0));
1146 small.put("I", new Integer(0));
1147 small.put("L", new Integer(0));
1148 small.put("V", new Integer(1));
1149 small.put("C", new Integer(1));
1150 small.put("A", new Integer(1));
1151 small.put("G", new Integer(1));
1152 small.put("M", new Integer(0));
1153 small.put("F", new Integer(0));
1154 small.put("Y", new Integer(0));
1155 small.put("W", new Integer(0));
1156 small.put("H", new Integer(0));
1157 small.put("K", new Integer(0));
1158 small.put("R", new Integer(0));
1159 small.put("E", new Integer(0));
1160 small.put("Q", new Integer(0));
1161 small.put("D", new Integer(1));
1162 small.put("N", new Integer(1));
1163 small.put("S", new Integer(1));
1164 small.put("T", new Integer(1));
1165 small.put("P", new Integer(1));
1166 small.put("-", new Integer(1));
1167 small.put("*", new Integer(1));
1172 positive.put("I", new Integer(0));
1173 positive.put("L", new Integer(0));
1174 positive.put("V", new Integer(0));
1175 positive.put("C", new Integer(0));
1176 positive.put("A", new Integer(0));
1177 positive.put("G", new Integer(0));
1178 positive.put("M", new Integer(0));
1179 positive.put("F", new Integer(0));
1180 positive.put("Y", new Integer(0));
1181 positive.put("W", new Integer(0));
1182 positive.put("H", new Integer(1));
1183 positive.put("K", new Integer(1));
1184 positive.put("R", new Integer(1));
1185 positive.put("E", new Integer(0));
1186 positive.put("Q", new Integer(0));
1187 positive.put("D", new Integer(0));
1188 positive.put("N", new Integer(0));
1189 positive.put("S", new Integer(0));
1190 positive.put("T", new Integer(0));
1191 positive.put("P", new Integer(0));
1192 positive.put("-", new Integer(1));
1193 positive.put("*", new Integer(1));
1198 negative.put("I", new Integer(0));
1199 negative.put("L", new Integer(0));
1200 negative.put("V", new Integer(0));
1201 negative.put("C", new Integer(0));
1202 negative.put("A", new Integer(0));
1203 negative.put("G", new Integer(0));
1204 negative.put("M", new Integer(0));
1205 negative.put("F", new Integer(0));
1206 negative.put("Y", new Integer(0));
1207 negative.put("W", new Integer(0));
1208 negative.put("H", new Integer(0));
1209 negative.put("K", new Integer(0));
1210 negative.put("R", new Integer(0));
1211 negative.put("E", new Integer(1));
1212 negative.put("Q", new Integer(0));
1213 negative.put("D", new Integer(1));
1214 negative.put("N", new Integer(0));
1215 negative.put("S", new Integer(0));
1216 negative.put("T", new Integer(0));
1217 negative.put("P", new Integer(0));
1218 negative.put("-", new Integer(1));
1219 negative.put("*", new Integer(1));
1224 charged.put("I", new Integer(0));
1225 charged.put("L", new Integer(0));
1226 charged.put("V", new Integer(0));
1227 charged.put("C", new Integer(0));
1228 charged.put("A", new Integer(0));
1229 charged.put("G", new Integer(0));
1230 charged.put("M", new Integer(0));
1231 charged.put("F", new Integer(0));
1232 charged.put("Y", new Integer(0));
1233 charged.put("W", new Integer(0));
1234 charged.put("H", new Integer(1));
1235 charged.put("K", new Integer(1));
1236 charged.put("R", new Integer(1));
1237 charged.put("E", new Integer(1));
1238 charged.put("Q", new Integer(0));
1239 charged.put("D", new Integer(1));
1240 charged.put("N", new Integer(0)); // Asparagine is polar but not charged.
1241 // Alternative would be charged and
1242 // negative (in basic form)?
1243 charged.put("S", new Integer(0));
1244 charged.put("T", new Integer(0));
1245 charged.put("P", new Integer(0));
1246 charged.put("-", new Integer(1));
1247 charged.put("*", new Integer(1));
1252 aromatic.put("I", new Integer(0));
1253 aromatic.put("L", new Integer(0));
1254 aromatic.put("V", new Integer(0));
1255 aromatic.put("C", new Integer(0));
1256 aromatic.put("A", new Integer(0));
1257 aromatic.put("G", new Integer(0));
1258 aromatic.put("M", new Integer(0));
1259 aromatic.put("F", new Integer(1));
1260 aromatic.put("Y", new Integer(1));
1261 aromatic.put("W", new Integer(1));
1262 aromatic.put("H", new Integer(1));
1263 aromatic.put("K", new Integer(0));
1264 aromatic.put("R", new Integer(0));
1265 aromatic.put("E", new Integer(0));
1266 aromatic.put("Q", new Integer(0));
1267 aromatic.put("D", new Integer(0));
1268 aromatic.put("N", new Integer(0));
1269 aromatic.put("S", new Integer(0));
1270 aromatic.put("T", new Integer(0));
1271 aromatic.put("P", new Integer(0));
1272 aromatic.put("-", new Integer(1));
1273 aromatic.put("*", new Integer(1));
1278 aliphatic.put("I", new Integer(1));
1279 aliphatic.put("L", new Integer(1));
1280 aliphatic.put("V", new Integer(1));
1281 aliphatic.put("C", new Integer(0));
1282 aliphatic.put("A", new Integer(0));
1283 aliphatic.put("G", new Integer(0));
1284 aliphatic.put("M", new Integer(0));
1285 aliphatic.put("F", new Integer(0));
1286 aliphatic.put("Y", new Integer(0));
1287 aliphatic.put("W", new Integer(0));
1288 aliphatic.put("H", new Integer(0));
1289 aliphatic.put("K", new Integer(0));
1290 aliphatic.put("R", new Integer(0));
1291 aliphatic.put("E", new Integer(0));
1292 aliphatic.put("Q", new Integer(0));
1293 aliphatic.put("D", new Integer(0));
1294 aliphatic.put("N", new Integer(0));
1295 aliphatic.put("S", new Integer(0));
1296 aliphatic.put("T", new Integer(0));
1297 aliphatic.put("P", new Integer(0));
1298 aliphatic.put("-", new Integer(1));
1299 aliphatic.put("*", new Integer(1));
1304 tiny.put("I", new Integer(0));
1305 tiny.put("L", new Integer(0));
1306 tiny.put("V", new Integer(0));
1307 tiny.put("C", new Integer(0));
1308 tiny.put("A", new Integer(1));
1309 tiny.put("G", new Integer(1));
1310 tiny.put("M", new Integer(0));
1311 tiny.put("F", new Integer(0));
1312 tiny.put("Y", new Integer(0));
1313 tiny.put("W", new Integer(0));
1314 tiny.put("H", new Integer(0));
1315 tiny.put("K", new Integer(0));
1316 tiny.put("R", new Integer(0));
1317 tiny.put("E", new Integer(0));
1318 tiny.put("Q", new Integer(0));
1319 tiny.put("D", new Integer(0));
1320 tiny.put("N", new Integer(0));
1321 tiny.put("S", new Integer(1));
1322 tiny.put("T", new Integer(0));
1323 tiny.put("P", new Integer(0));
1324 tiny.put("-", new Integer(1));
1325 tiny.put("*", new Integer(1));
1330 proline.put("I", new Integer(0));
1331 proline.put("L", new Integer(0));
1332 proline.put("V", new Integer(0));
1333 proline.put("C", new Integer(0));
1334 proline.put("A", new Integer(0));
1335 proline.put("G", new Integer(0));
1336 proline.put("M", new Integer(0));
1337 proline.put("F", new Integer(0));
1338 proline.put("Y", new Integer(0));
1339 proline.put("W", new Integer(0));
1340 proline.put("H", new Integer(0));
1341 proline.put("K", new Integer(0));
1342 proline.put("R", new Integer(0));
1343 proline.put("E", new Integer(0));
1344 proline.put("Q", new Integer(0));
1345 proline.put("D", new Integer(0));
1346 proline.put("N", new Integer(0));
1347 proline.put("S", new Integer(0));
1348 proline.put("T", new Integer(0));
1349 proline.put("P", new Integer(1));
1350 proline.put("-", new Integer(1));
1351 proline.put("*", new Integer(1));
1356 propHash.put("hydrophobic", hydrophobic);
1357 propHash.put("small", small);
1358 propHash.put("positive", positive);
1359 propHash.put("negative", negative);
1360 propHash.put("charged", charged);
1361 propHash.put("aromatic", aromatic);
1362 propHash.put("aliphatic", aliphatic);
1363 propHash.put("tiny", tiny);
1364 propHash.put("proline", proline);
1365 propHash.put("polar", polar);
1369 int[][] propMatrixF = new int[maxProteinIndex][maxProteinIndex], propMatrixPos = new int[maxProteinIndex][maxProteinIndex], propMatrixEpos = new int[maxProteinIndex][maxProteinIndex];
1370 for (int i = 0; i < maxProteinIndex; i++)
1372 int maxF = 0, maxP = 0, maxEP = 0;
1382 for (int j = i + 1; j < maxProteinIndex; j++)
1393 propMatrixF[i][j] = 0;
1394 propMatrixPos[i][j] = 0;
1395 propMatrixEpos[i][j] = 0;
1396 for (Enumeration<String> en = propHash.keys(); en
1397 .hasMoreElements();)
1399 String ph = en.nextElement();
1400 Map<String, Integer> pph = (Map<String, Integer>) propHash
1402 if (pph.get(ic) != null && pph.get(jc) != null)
1404 int icp = pph.get(ic).intValue(), jcp = pph.get(jc).intValue();
1405 // Still working on these definitions.
1406 propMatrixPos[i][j] += icp == jcp && icp > 0 ? 2 : 0;
1407 propMatrixPos[j][i] += icp == jcp && icp > 0 ? 2 : 0;
1408 propMatrixF[i][j] += icp == jcp ? 2 : 0;
1409 propMatrixF[j][i] += icp == jcp ? 2 : 0;
1410 propMatrixEpos[i][j] += icp == jcp ? (1 + icp * 2) : 0;
1411 propMatrixEpos[j][i] += icp == jcp ? (1 + icp * 2) : 0;
1414 if (maxF < propMatrixF[i][j])
1416 maxF = propMatrixF[i][j];
1418 if (maxP < propMatrixPos[i][j])
1420 maxP = propMatrixPos[i][j];
1422 if (maxEP < propMatrixEpos[i][j])
1424 maxEP = propMatrixEpos[i][j];
1427 propMatrixF[i][i] = maxF;
1428 propMatrixPos[i][i] = maxP;
1429 propMatrixEpos[i][i] = maxEP;
1431 // JAL-1512 comment out physicochemical score matrices for 2.8.1 release
1432 // scoreMatrices.put("Conservation Pos", new
1433 // ScoreMatrix("Conservation Pos",propMatrixPos,0));
1434 // scoreMatrices.put("Conservation Both", new
1435 // ScoreMatrix("Conservation Both",propMatrixF,0));
1436 // scoreMatrices.put("Conservation EnhPos", new
1437 // ScoreMatrix("Conservation EnhPos",propMatrixEpos,0));
1438 scoreMatrices.put("PID", new PIDScoreModel());
1439 scoreMatrices.put("Displayed Features", new FeatureScoreModel());
1442 private ResidueProperties()
1446 public static double getHydmax()
1451 public static double getHydmin()
1456 public static double[] getHyd()
1461 public static Map<String, Integer> getAA3Hash()
1466 public static int[][] getDNA()
1468 return ResidueProperties.DNA;
1471 public static int[][] getBLOSUM62()
1473 return ResidueProperties.BLOSUM62;
1476 public static int getPAM250(String A1, String A2)
1478 return getPAM250(A1.charAt(0), A2.charAt(0));
1481 public static int getBLOSUM62(char c1, char c2)
1487 int a = aaIndex[c1];
1488 int b = aaIndex[c2];
1490 pog = ResidueProperties.BLOSUM62[a][b];
1491 } catch (Exception e)
1493 // System.out.println("Unknown residue in " + A1 + " " + A2);
1499 public static Vector getCodons(String res)
1501 if (codonHash.containsKey(res))
1503 return (Vector) codonHash.get(res);
1509 public static String codonTranslate(String lccodon)
1513 return _codonTranslate(lccodon);
1515 String cdn = codonHash2.get(lccodon.toUpperCase());
1516 if (cdn != null && cdn.equals("*"))
1523 public static String _codonTranslate(String lccodon)
1525 String codon = lccodon.toUpperCase();
1526 // all base ambiguity codes yield an 'X' amino acid residue
1527 if (codon.indexOf('X') > -1 || codon.indexOf('N') > -1)
1531 for (String key : codonHash.keySet())
1533 if (codonHash.get(key).contains(codon))
1542 public static int[][] getDefaultPeptideMatrix()
1544 return ResidueProperties.getBLOSUM62();
1547 public static int[][] getDefaultDnaMatrix()
1549 return ResidueProperties.getDNA();
1553 * get a ScoreMatrix based on its string name
1556 * @return matrix in scoreMatrices with key pwtype or null
1558 public static ScoreMatrix getScoreMatrix(String pwtype)
1560 Object val = scoreMatrices.get(pwtype);
1561 if (val != null && val instanceof ScoreMatrix)
1563 return (ScoreMatrix) val;
1569 * get a ScoreModel based on its string name
1572 * @return scoremodel of type pwtype or null
1574 public static ScoreModelI getScoreModel(String pwtype)
1576 return scoreMatrices.get(pwtype);
1579 public static int getPAM250(char c, char d)
1584 int pog = ResidueProperties.PAM250[a][b];
1589 public static Hashtable toDssp3State;
1592 toDssp3State = new Hashtable();
1593 toDssp3State.put("H", "H");
1594 toDssp3State.put("E", "E");
1595 toDssp3State.put("C", " ");
1596 toDssp3State.put(" ", " ");
1597 toDssp3State.put("T", " ");
1598 toDssp3State.put("B", "E");
1599 toDssp3State.put("G", "H");
1600 toDssp3State.put("I", "H");
1601 toDssp3State.put("X", " ");
1605 * translate from other dssp secondary structure alphabets to 3-state
1608 * @return ssstring as a three-state secondary structure assignment.
1610 public static String getDssp3state(String ssstring)
1612 if (ssstring == null)
1616 StringBuffer ss = new StringBuffer();
1617 for (int i = 0; i < ssstring.length(); i++)
1619 String ssc = ssstring.substring(i, i + 1);
1620 if (toDssp3State.containsKey(ssc))
1622 ss.append((String) toDssp3State.get(ssc));
1629 return ss.toString();
1633 * Used by getRNASecStrucState
1636 public static Hashtable<String, String> toRNAssState;
1638 public static boolean RNAcloseParen[] = new boolean[255];
1641 toRNAssState = new Hashtable<String, String>();
1642 toRNAssState.put(")", "(");
1643 toRNAssState.put("(", "(");
1644 toRNAssState.put("]", "[");
1645 toRNAssState.put("[", "[");
1646 toRNAssState.put("{", "{");
1647 toRNAssState.put("}", "{");
1648 toRNAssState.put(">", ">");
1649 toRNAssState.put("<", ">");
1650 toRNAssState.put("A", "A");
1651 toRNAssState.put("a", "A");
1652 toRNAssState.put("B", "B");
1653 toRNAssState.put("b", "B");
1654 toRNAssState.put("C", "C");
1655 toRNAssState.put("c", "C");
1656 toRNAssState.put("D", "D");
1657 toRNAssState.put("d", "D");
1658 toRNAssState.put("E", "E");
1659 toRNAssState.put("e", "E");
1660 toRNAssState.put("F", "F");
1661 toRNAssState.put("f", "F");
1662 toRNAssState.put("G", "G");
1663 toRNAssState.put("g", "G");
1664 toRNAssState.put("H", "H");
1665 toRNAssState.put("h", "H");
1666 toRNAssState.put("I", "I");
1667 toRNAssState.put("i", "I");
1668 toRNAssState.put("J", "J");
1669 toRNAssState.put("j", "J");
1670 toRNAssState.put("K", "K");
1671 toRNAssState.put("k", "K");
1672 toRNAssState.put("L", "L");
1673 toRNAssState.put("l", "L");
1674 toRNAssState.put("M", "M");
1675 toRNAssState.put("m", "M");
1676 toRNAssState.put("N", "N");
1677 toRNAssState.put("n", "N");
1678 toRNAssState.put("O", "O");
1679 toRNAssState.put("o", "O");
1680 toRNAssState.put("P", "P");
1681 toRNAssState.put("p", "P");
1682 toRNAssState.put("Q", "Q");
1683 toRNAssState.put("q", "Q");
1684 toRNAssState.put("R", "R");
1685 toRNAssState.put("r", "R");
1686 toRNAssState.put("S", "S");
1687 toRNAssState.put("s", "S");
1688 toRNAssState.put("T", "T");
1689 toRNAssState.put("t", "T");
1690 toRNAssState.put("U", "U");
1691 toRNAssState.put("u", "U");
1692 toRNAssState.put("V", "V");
1693 toRNAssState.put("v", "V");
1694 toRNAssState.put("W", "W");
1695 toRNAssState.put("w", "W");
1696 toRNAssState.put("X", "X");
1697 toRNAssState.put("x", "X");
1698 toRNAssState.put("Y", "Y");
1699 toRNAssState.put("y", "Y");
1700 toRNAssState.put("Z", "Z");
1701 toRNAssState.put("z", "Z");
1702 for (int p = 0; p < RNAcloseParen.length; p++)
1704 RNAcloseParen[p] = false;
1706 for (String k : toRNAssState.keySet())
1708 RNAcloseParen[k.charAt(0)] = k.charAt(0) != toRNAssState.get(k)
1714 * translate to RNA secondary structure representation
1717 * @return ssstring as a RNA-state secondary structure assignment.
1719 public static String getRNASecStrucState(String ssstring)
1721 if (ssstring == null)
1725 StringBuffer ss = new StringBuffer();
1726 for (int i = 0; i < ssstring.length(); i++)
1728 String ssc = ssstring.substring(i, i + 1);
1729 if (toRNAssState.containsKey(ssc))
1731 // valid ss character - so return it
1732 ss.append(ssc); // (String) toRNAssState.get(ssc));
1739 return ss.toString();
1742 public static boolean isCloseParenRNA(char dc)
1744 return RNAcloseParen[dc];
1747 // main method generates perl representation of residue property hash
1755 public static void main(String[] args)
1757 Hashtable aa = new Hashtable();
1758 System.out.println("my %aa = {");
1759 // invert property hashes
1760 Enumeration prop = propHash.keys();
1761 while (prop.hasMoreElements())
1763 String pname = (String) prop.nextElement();
1764 Hashtable phash = (Hashtable) propHash.get(pname);
1765 Enumeration res = phash.keys();
1766 while (res.hasMoreElements())
1768 String rname = (String) res.nextElement();
1769 Vector aprops = (Vector) aa.get(rname);
1772 aprops = new Vector();
1773 aa.put(rname, aprops);
1775 Integer hasprop = (Integer) phash.get(rname);
1776 if (hasprop.intValue() == 1)
1778 aprops.addElement(pname);
1782 Enumeration res = aa.keys();
1783 while (res.hasMoreElements())
1785 String rname = (String) res.nextElement();
1787 System.out.print("'" + rname + "' => [");
1788 Enumeration props = ((Vector) aa.get(rname)).elements();
1789 while (props.hasMoreElements())
1791 System.out.print("'" + (String) props.nextElement() + "'");
1792 if (props.hasMoreElements())
1794 System.out.println(", ");
1797 System.out.println("]" + (res.hasMoreElements() ? "," : ""));
1799 System.out.println("};");
1804 * Returns a list of residue characters for the specified inputs
1807 * @param includeAmbiguous
1810 public static List<String> getResidues(boolean nucleotide,
1811 boolean includeAmbiguous)
1813 List<String> result = new ArrayList<String>();
1816 for (String nuc : nucleotideName.keySet())
1818 int val = nucleotideIndex[nuc.charAt(0)];
1819 if ((!includeAmbiguous && val > 4) || (val >= maxNucleotideIndex))
1823 nuc = nuc.toUpperCase();
1824 if (!result.contains(nuc))
1833 for (String res : aa3Hash.keySet())
1835 int index = aa3Hash.get(res).intValue();
1836 if ((!includeAmbiguous && index >= 20) || index >= maxProteinIndex)
1840 res = res.toUpperCase();
1841 if (!result.contains(res))