X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueProperties.java;h=4699dc6982efb31fab7fe9dedb31a51df4f4a677;hb=9a88b5f931393037048bf4d8c1c3b871ae585b1c;hp=0b71381a2a027b7819a8e5ec844208ed02a25c4f;hpb=96786b7b949dc261a9556e13a17870166915d0e9;p=jalview.git diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 0b71381..4699dc6 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,85 +25,124 @@ import java.awt.*; public class ResidueProperties { //Stores residue codes/names and colours and other things - public static Hashtable aaHash = new Hashtable(); // stores the number value of the aa - public static Hashtable aa3Hash = new Hashtable(); - public static Hashtable aa2Triplet = new Hashtable(); - public static Hashtable nucleotideHash = new Hashtable(); + public static final int [] aaIndex; // aaHash version 2.1.1 and below + public static final int [] nucleotideIndex; + public static final Hashtable aa3Hash = new Hashtable(); + public static final Hashtable aa2Triplet = new Hashtable(); + public static final Hashtable nucleotideName = new Hashtable(); - static - { - aaHash.put("A", new Integer(0)); - aaHash.put("R", new Integer(1)); - aaHash.put("N", new Integer(2)); - aaHash.put("D", new Integer(3)); - aaHash.put("C", new Integer(4)); - aaHash.put("Q", new Integer(5)); - aaHash.put("E", new Integer(6)); - aaHash.put("G", new Integer(7)); - aaHash.put("H", new Integer(8)); - aaHash.put("I", new Integer(9)); - aaHash.put("L", new Integer(10)); - aaHash.put("K", new Integer(11)); - aaHash.put("M", new Integer(12)); - aaHash.put("F", new Integer(13)); - aaHash.put("P", new Integer(14)); - aaHash.put("S", new Integer(15)); - aaHash.put("T", new Integer(16)); - aaHash.put("W", new Integer(17)); - aaHash.put("Y", new Integer(18)); - aaHash.put("V", new Integer(19)); - aaHash.put("B", new Integer(20)); - aaHash.put("Z", new Integer(21)); - aaHash.put("X", new Integer(22)); - aaHash.put("a", new Integer(0)); - aaHash.put("r", new Integer(1)); - aaHash.put("n", new Integer(2)); - aaHash.put("d", new Integer(3)); - aaHash.put("c", new Integer(4)); - aaHash.put("q", new Integer(5)); - aaHash.put("e", new Integer(6)); - aaHash.put("g", new Integer(7)); - aaHash.put("h", new Integer(8)); - aaHash.put("i", new Integer(9)); - aaHash.put("l", new Integer(10)); - aaHash.put("k", new Integer(11)); - aaHash.put("m", new Integer(12)); - aaHash.put("f", new Integer(13)); - aaHash.put("p", new Integer(14)); - aaHash.put("s", new Integer(15)); - aaHash.put("t", new Integer(16)); - aaHash.put("w", new Integer(17)); - aaHash.put("y", new Integer(18)); - aaHash.put("v", new Integer(19)); - aaHash.put("b", new Integer(20)); - aaHash.put("z", new Integer(21)); - aaHash.put("x", new Integer(22)); - aaHash.put("-", new Integer(23)); - aaHash.put("*", new Integer(23)); - aaHash.put(".", new Integer(23)); - aaHash.put(" ", new Integer(23)); - } static { - nucleotideHash.put("A", new Integer(0)); - nucleotideHash.put("C", new Integer(1)); - nucleotideHash.put("G", new Integer(2)); - nucleotideHash.put("T", new Integer(3)); - nucleotideHash.put("U", new Integer(4)); + aaIndex = new int[132]; + for(int i=0; i<132; i++) + aaIndex[i] = -1; + + aaIndex['A'] = 0; + aaIndex['R'] = 1; + aaIndex['N'] = 2; + aaIndex['D'] = 3; + aaIndex['C'] = 4; + aaIndex['Q'] = 5; + aaIndex['E'] = 6; + aaIndex['G'] = 7; + aaIndex['H'] = 8; + aaIndex['I'] = 9; + aaIndex['L'] = 10; + aaIndex['K'] = 11; + aaIndex['M'] = 12; + aaIndex['F'] = 13; + aaIndex['P'] = 14; + aaIndex['S'] = 15; + aaIndex['T'] = 16; + aaIndex['W'] = 17; + aaIndex['Y'] = 18; + aaIndex['V'] = 19; + aaIndex['B'] = 20; + aaIndex['Z'] = 21; + aaIndex['X'] = 22; + aaIndex['U'] = 22; + aaIndex['a'] = 0; + aaIndex['r'] = 1; + aaIndex['n'] = 2; + aaIndex['d'] = 3; + aaIndex['c'] = 4; + aaIndex['q'] = 5; + aaIndex['e'] = 6; + aaIndex['g'] = 7; + aaIndex['h'] = 8; + aaIndex['i'] = 9; + aaIndex['l'] = 10; + aaIndex['k'] = 11; + aaIndex['m'] = 12; + aaIndex['f'] = 13; + aaIndex['p'] = 14; + aaIndex['s'] = 15; + aaIndex['t'] = 16; + aaIndex['w'] = 17; + aaIndex['y'] = 18; + aaIndex['v'] = 19; + aaIndex['b'] = 20; + aaIndex['z'] = 21; + aaIndex['x'] = 22; + aaIndex['u'] = 22; + aaIndex['-'] = 23; + aaIndex['*'] = 23; + aaIndex['.'] = 23; + aaIndex[' '] = 23; } - // These numbers should correspond to the indices in the Color hashes - public static Hashtable aaSpecialsHash = new Hashtable(); - static { - aaSpecialsHash.put("-", new Integer(23)); - aaSpecialsHash.put("*", new Integer(24)); - aaSpecialsHash.put(".", new Integer(25)); - aaSpecialsHash.put(" ", new Integer(26)); + nucleotideIndex = new int[132]; + for (int i = 0; i < 132; i++) + nucleotideIndex[i] = -1; + + nucleotideIndex['A'] = 0; + nucleotideIndex['a'] = 0; + nucleotideIndex['C'] = 1; + nucleotideIndex['c'] = 1; + nucleotideIndex['G'] = 2; + nucleotideIndex['g'] = 2; + nucleotideIndex['T'] = 3; + nucleotideIndex['t'] = 3; + nucleotideIndex['U'] = 4; + nucleotideIndex['u'] = 4; + nucleotideIndex['I'] = 5; + nucleotideIndex['i'] = 5; + nucleotideIndex['X'] = 6; + nucleotideIndex['x'] = 6; + nucleotideIndex['R'] = 7; + nucleotideIndex['r'] = 7; + nucleotideIndex['Y'] = 8; + nucleotideIndex['y'] = 8; + nucleotideIndex['N'] = 9; + nucleotideIndex['n'] = 9; + + + nucleotideName.put("A", "Adenine"); + nucleotideName.put("a", "Adenine"); + nucleotideName.put("G", "Guanine"); + nucleotideName.put("g", "Guanine"); + nucleotideName.put("C", "Cytosine"); + nucleotideName.put("c", "Cytosine"); + nucleotideName.put("T", "Thymine"); + nucleotideName.put("t", "Thymine"); + nucleotideName.put("U", "Uracil"); + nucleotideName.put("u", "Uracil"); + nucleotideName.put("I", "Inosine"); + nucleotideName.put("i", "Inosine"); + nucleotideName.put("X", "Xanthine"); + nucleotideName.put("x", "Xanthine"); + nucleotideName.put("R", "Unknown Purine"); + nucleotideName.put("r", "Unknown Purine"); + nucleotideName.put("Y", "Unknown Pyrimidine"); + nucleotideName.put("y", "Unknown Pyrimidine"); + nucleotideName.put("N", "Unknown"); + nucleotideName.put("n", "Unknown"); } + static { aa3Hash.put("ALA", new Integer(0)); @@ -126,13 +165,15 @@ public class ResidueProperties aa3Hash.put("TRP", new Integer(17)); aa3Hash.put("TYR", new Integer(18)); aa3Hash.put("VAL", new Integer(19)); - aa3Hash.put("B", new Integer(20)); - aa3Hash.put("Z", new Integer(21)); - aa3Hash.put("X", new Integer(22)); + // IUB Nomenclature for ambiguous peptides + aa3Hash.put("ASX", new Integer(20)); // "B"; + aa3Hash.put("GLX", new Integer(21)); // X + aa3Hash.put("XAA", new Integer(22));// X unknown aa3Hash.put("-", new Integer(23)); aa3Hash.put("*", new Integer(23)); aa3Hash.put(".", new Integer(23)); aa3Hash.put(" ", new Integer(23)); + aa3Hash.put("Gap", new Integer(23)); } static @@ -179,13 +220,13 @@ public class ResidueProperties aa2Triplet.put("v", "VAL"); } - public static String[] aa = + public static final String[] aa = { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " }; - public static Color midBlue = new Color(100, 100, 255); - public static Vector scaleColours = new Vector(); + public static final Color midBlue = new Color(100, 100, 255); + public static final Vector scaleColours = new Vector(); static { @@ -201,7 +242,7 @@ public class ResidueProperties scaleColours.addElement(Color.white); } - public static Color[] taylor = + public static final Color[] taylor = { new Color(204, 255, 0), // A Greenish-yellowy-yellow new Color(0, 0, 255), // R Blueish-bluey-blue @@ -230,7 +271,7 @@ public class ResidueProperties Color.white, // * Color.white // . }; - public static Color[] nucleotide = + public static final Color[] nucleotide = { new Color(100, 247, 63), // A new Color(255, 179, 64), // C @@ -238,7 +279,7 @@ public class ResidueProperties new Color(60, 136, 238), // T new Color(60, 136, 238) // U }; - public static Color[] color = + public static final Color[] color = { Color.pink, // A midBlue, // R @@ -270,7 +311,7 @@ public class ResidueProperties }; // Dunno where I got these numbers from - public static double[] hyd2 = + public static final double[] hyd2 = { 0.62, //A 0.29, //R @@ -296,39 +337,39 @@ public class ResidueProperties 0.0, //Z 0.0 //X }; - public static double[] helix = + public static final double[] helix = { 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 }; - public static double helixmin = 0.57; - public static double helixmax = 1.51; - public static double[] strand = + public static final double helixmin = 0.57; + public static final double helixmax = 1.51; + public static final double[] strand = { 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 }; - public static double strandmin = 0.37; - public static double strandmax = 1.7; - public static double[] turn = + public static final double strandmin = 0.37; + public static final double strandmax = 1.7; + public static final double[] turn = { 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0 }; - public static double turnmin = 0.47; - public static double turnmax = 1.56; - public static double[] buried = + public static final double turnmin = 0.47; + public static final double turnmax = 1.56; + public static final double[] buried = { 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, 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 }; - public static double buriedmin = 0.05; - public static double buriedmax = 4.6; + public static final double buriedmin = 0.05; + public static final double buriedmax = 4.6; // This is hydropathy index // Kyte, J., and Doolittle, R.F., J. Mol. Biol. // 1157, 105-132, 1982 - public static double[] hyd = + public static final double[] hyd = { 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 @@ -536,7 +577,7 @@ public class ResidueProperties -8, -8, -8, -8, -8, -8, 1 }, }; - public static Hashtable ssHash = new Hashtable(); // stores the number value of the aa + public static final Hashtable ssHash = new Hashtable(); // stores the number value of the aa static { @@ -564,13 +605,13 @@ public class ResidueProperties { 1, 1, 1, 1, 1}, // - }; - public static Color[] pidColours = + public static final Color[] pidColours = { midBlue, new Color(153, 153, 255), // Color.lightGray, new Color(204, 204, 255), }; - public static float[] pidThresholds = + public static final float[] pidThresholds = { 80, 60, 40, }; public static Hashtable codonHash = new Hashtable(); @@ -793,27 +834,6 @@ public class ResidueProperties Phe.addElement("TTT"); } - public static Color[][] groupColors = - { - { - Color.red, Color.red.brighter(), Color.red.brighter().brighter()}, - { - Color.orange, Color.orange.brighter(), - Color.orange.brighter().brighter() - }, - { - Color.green, Color.green.brighter(), Color.green.brighter().brighter()}, - { - Color.blue, Color.blue.brighter(), Color.blue.brighter().brighter()}, - { - Color.magenta, Color.magenta.brighter(), - Color.magenta.brighter().brighter() - }, - { - Color.cyan, Color.cyan.brighter(), Color.cyan.brighter().brighter()}, - { - Color.pink, Color.pink.brighter(), Color.pink.brighter().brighter()}, - }; //Stores residue codes/names and colours and other things public static Hashtable propHash = new Hashtable(); @@ -1104,20 +1124,6 @@ public class ResidueProperties propHash.put("polar", polar); } - public static Hashtable chainColours = new Hashtable(); - - static - { - chainColours.put("A", Color.red); - chainColours.put("B", Color.orange); - chainColours.put("C", Color.yellow); - chainColours.put("D", Color.green); - chainColours.put("E", Color.cyan); - chainColours.put("F", Color.blue); - chainColours.put("G", Color.magenta); - chainColours.put("H", Color.pink); - } - private ResidueProperties() { } @@ -1137,11 +1143,6 @@ public class ResidueProperties return hyd; } - public static Hashtable getAAHash() - { - return aaHash; - } - public static Hashtable getAA3Hash() { return aa3Hash; @@ -1159,9 +1160,10 @@ public class ResidueProperties public static int getPAM250(String A1, String A2) { - Integer pog1 = (Integer) aaHash.get(A1); - Integer pog2 = (Integer) aaHash.get(A2); - int pog = ResidueProperties.PAM250[pog1.intValue()][pog2.intValue()]; + int a = aaIndex[A1.charAt(0)]; + int b = aaIndex[A2.charAt(0)]; + + int pog = ResidueProperties.PAM250[a][b]; return pog; } @@ -1172,9 +1174,10 @@ public class ResidueProperties try { - Integer pog1 = (Integer) aaHash.get(A1); - Integer pog2 = (Integer) aaHash.get(A2); - pog = ResidueProperties.BLOSUM62[pog1.intValue()][pog2.intValue()]; + int a = aaIndex[A1.charAt(0)]; + int b = aaIndex[A2.charAt(0)]; + + pog = ResidueProperties.BLOSUM62[a][b]; } catch (Exception e) { @@ -1203,7 +1206,7 @@ public class ResidueProperties String key = (String) e.nextElement(); Vector tmp = (Vector) codonHash.get(key); - if (tmp.contains(codon)) + if (tmp.contains(codon.toUpperCase())) { return key; } @@ -1211,9 +1214,4 @@ public class ResidueProperties return null; } - - public static Hashtable getChainColours() - { - return chainColours; - } }