X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueProperties.java;h=4699dc6982efb31fab7fe9dedb31a51df4f4a677;hb=9a88b5f931393037048bf4d8c1c3b871ae585b1c;hp=87efddc2d927e5126859386eeae669d5a345bef4;hpb=af5db81aeed0fb115a5c808275cf2d5c1b6cc139;p=jalview.git diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 87efddc..4699dc6 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -25,90 +25,99 @@ 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("U", 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("u", new Integer(22)); - aaHash.put("-", new Integer(23)); - aaHash.put("*", new Integer(23)); - aaHash.put(".", new Integer(23)); - aaHash.put(" ", new Integer(23)); + 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; } static { - nucleotideHash.put("A", new Integer(0)); - nucleotideHash.put("a", new Integer(0)); - nucleotideHash.put("C", new Integer(1)); - nucleotideHash.put("c", new Integer(1)); - nucleotideHash.put("G", new Integer(2)); - nucleotideHash.put("g", new Integer(2)); - nucleotideHash.put("T", new Integer(3)); - nucleotideHash.put("t", new Integer(3)); - nucleotideHash.put("U", new Integer(4)); - nucleotideHash.put("u", new Integer(4)); - nucleotideHash.put("I", new Integer(5)); - nucleotideHash.put("i", new Integer(5)); - nucleotideHash.put("X", new Integer(6)); - nucleotideHash.put("x", new Integer(6)); - nucleotideHash.put("R", new Integer(7)); - nucleotideHash.put("r", new Integer(7)); - nucleotideHash.put("Y", new Integer(8)); - nucleotideHash.put("y", new Integer(8)); - nucleotideHash.put("N", new Integer(9)); - nucleotideHash.put("n", new Integer(9)); + 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"); @@ -1134,11 +1143,6 @@ public class ResidueProperties return hyd; } - public static Hashtable getAAHash() - { - return aaHash; - } - public static Hashtable getAA3Hash() { return aa3Hash; @@ -1156,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; } @@ -1169,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) {