X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fschemes%2FResidueProperties.java;h=18b11c114499848d77de2bd8c0790929c1a3ce04;hb=b53d11f22f9c5db694835ba27490e7c19671872d;hp=a4e648071e152d4462152cc79002300867b53e3b;hpb=2fca9caf0623a1fc950402c2ac303959bb676947;p=jalview.git diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index a4e6480..18b11c1 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1156,47 +1156,51 @@ public class ResidueProperties return cdn; } - public static Hashtable toDssp3State; + /* + * lookup of (A-Z) alternative secondary structure symbols' + * equivalents in DSSP3 notation + */ + private static char[] toDssp3State; static { - toDssp3State = new Hashtable<>(); - toDssp3State.put("H", "H"); - toDssp3State.put("E", "E"); - toDssp3State.put("C", " "); - toDssp3State.put(" ", " "); - toDssp3State.put("T", " "); - toDssp3State.put("B", "E"); - toDssp3State.put("G", "H"); - toDssp3State.put("I", "H"); - toDssp3State.put("X", " "); + toDssp3State = new char[9]; // for 'A'-'I'; extend if needed + Arrays.fill(toDssp3State, ' '); + toDssp3State['B' - 'A'] = 'E'; + toDssp3State['E' - 'A'] = 'E'; + toDssp3State['G' - 'A'] = 'H'; + toDssp3State['H' - 'A'] = 'H'; + toDssp3State['I' - 'A'] = 'H'; } /** * translate from other dssp secondary structure alphabets to 3-state * - * @param ssstring - * @return ssstring as a three-state secondary structure assignment. + * @param ssString + * @return ssstring */ - public static String getDssp3state(String ssstring) + public static String getDssp3state(String ssString) { - if (ssstring == null) + if (ssString == null) { return null; } - StringBuffer ss = new StringBuffer(); - for (int i = 0; i < ssstring.length(); i++) + int lookupSize = toDssp3State.length; + int len = ssString.length(); + char[] trans = new char[len]; + for (int i = 0; i < len; i++) { - String ssc = ssstring.substring(i, i + 1); - if (toDssp3State.containsKey(ssc)) + char c = ssString.charAt(i); + int index = c - 'A'; + if (index < 0 || index >= lookupSize) { - ss.append(toDssp3State.get(ssc)); + trans[i] = ' '; } else { - ss.append(" "); + trans[i] = toDssp3State[index]; } } - return ss.toString(); + return new String(trans); } static