X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueProperties.java;h=4699dc6982efb31fab7fe9dedb31a51df4f4a677;hb=ecb5ab32cb7599f6665117ad4e25c61f0a650720;hp=f92bfd12601c61862a61f5f7086d55444123003a;hpb=c3a5f5735df3a8e85818a6dd1e3f1d614060b721;p=jalview.git diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index f92bfd1..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,90 +25,124 @@ import java.awt.*; public class ResidueProperties { //Stores residue codes/names and colours and other things - public static final Hashtable aaHash = new Hashtable(); // stores the number value of the aa + 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 nucleotideHash = 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)); - 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 final 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)); @@ -131,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 @@ -798,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(); @@ -1109,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() { } @@ -1142,11 +1143,6 @@ public class ResidueProperties return hyd; } - public static Hashtable getAAHash() - { - return aaHash; - } - public static Hashtable getAA3Hash() { return aa3Hash; @@ -1164,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; } @@ -1177,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) { @@ -1208,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; } @@ -1216,9 +1214,4 @@ public class ResidueProperties return null; } - - public static Hashtable getChainColours() - { - return chainColours; - } }