*/
package jalview.schemes;
+import java.util.Locale;
+
import jalview.analysis.GeneticCodes;
import java.awt.Color;
return peptide;
}
- public static Hashtable<String, String> 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
// main method generates perl representation of residue property hash
// / cut here
+ /**
+ * @j2sIgnore
+ * @param args
+ */
public static void main(String[] args)
{
Hashtable<String, Vector<String>> aaProps = new Hashtable<>();
{
continue;
}
- nuc = nuc.toUpperCase();
+ nuc = nuc.toUpperCase(Locale.ROOT);
if (!result.contains(nuc))
{
result.add(nuc);
{
continue;
}
- res = res.toUpperCase();
+ res = res.toUpperCase(Locale.ROOT);
if (!result.contains(res))
{
result.add(res);
return '0';
}
Integer index = ResidueProperties.aa3Hash
- .get(threeLetterCode.toUpperCase());
+ .get(threeLetterCode.toUpperCase(Locale.ROOT));
return index == null ? '0' : aa[index].charAt(0);
}
}