return cdn;
}
- 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
}
@Test(groups = { "Functional" })
+ public void testGetDssp3State()
+ {
+ assertNull(ResidueProperties.getDssp3state(null));
+ assertEquals("", ResidueProperties.getDssp3state(""));
+ String foo = "0123 []<>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ String bar = " E E HHH ";
+ assertEquals(bar, ResidueProperties.getDssp3state(foo));
+ }
+
+ @Test(groups = { "Functional" })
public void testPhysicoChemicalProperties()
{
checkProperty("aromatic", "FYWH-*");