trailing slash regexed out
[jalview.git] / src / jalview / schemes / ResidueProperties.java
index 0ae3201..98868d2 100755 (executable)
@@ -277,7 +277,8 @@ public class ResidueProperties
       new Color(60, 136, 238), // T
       new Color(60, 136, 238) // U
   };
-  public static final Color[] color =
+  // Zappo
+  public static final Color[] zappo =
       {
       Color.pink, // A
       midBlue, // R
@@ -287,7 +288,7 @@ public class ResidueProperties
       Color.green, // Q
       Color.red, // E
       Color.magenta, // G
-      Color.red, // H
+      midBlue,// Color.red, // H
       Color.pink, // I
       Color.pink, // L
       midBlue, // K
@@ -1167,12 +1168,7 @@ public class ResidueProperties
 
   public static int getPAM250(String A1, String A2)
   {
-    int a = aaIndex[A1.charAt(0)];
-    int b = aaIndex[A2.charAt(0)];
-
-    int pog = ResidueProperties.PAM250[a][b];
-
-    return pog;
+    return getPAM250(A1.charAt(0), A2.charAt(0));
   }
 
   public static int getBLOSUM62(char c1, char c2)
@@ -1246,4 +1242,101 @@ public class ResidueProperties
     }
     return null;
   }
+
+  public static int getPAM250(char c, char d)
+  {
+    int a = aaIndex[c];
+    int b = aaIndex[d];
+
+    int pog = ResidueProperties.PAM250[a][b];
+
+    return pog;
+  }
+
+  public static Hashtable 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", " ");
+  }
+  /**
+   * translate from other dssp secondary structure alphabets to 3-state
+   * @param ssstring
+   * @return ssstring as a three-state secondary structure assignment.
+   */
+  public static String getDssp3state(String ssstring)
+  {
+    if (ssstring==null)
+    {
+      return null;
+    }
+    StringBuffer ss = new StringBuffer();
+    for (int i=0; i<ssstring.length(); i++)
+    {
+      String ssc = ssstring.substring(i, i+1);
+      if (toDssp3State.containsKey(ssc))
+      {
+        ss.append((String) toDssp3State.get(ssc));
+      } else {
+        ss.append(" ");
+      }
+    }
+    return ss.toString();
+  }
+  // main method generates perl representation of residue property hash
+  /// cut here
+  public static void main(String[] args)
+  {
+    Hashtable aa = new Hashtable(); 
+    System.out.println("my %aa = {");
+    // invert property hashes
+    Enumeration prop = propHash.keys();
+    while (prop.hasMoreElements())
+    {
+      String pname = (String) prop.nextElement();
+      Hashtable phash = (Hashtable) propHash.get(pname);
+      Enumeration res = phash.keys();
+      while (res.hasMoreElements())
+      {
+        String rname = (String) res.nextElement();
+        Vector aprops = (Vector) aa.get(rname);
+        if (aprops==null)
+        {
+          aprops = new Vector();
+          aa.put(rname, aprops);
+        }
+        Integer hasprop = (Integer) phash.get(rname);
+        if (hasprop.intValue()==1)
+        {
+          aprops.addElement(pname);
+        }
+      }
+    }
+    Enumeration res = aa.keys();
+    while (res.hasMoreElements())
+    {
+      String rname = (String) res.nextElement();
+      
+      System.out.print("'"+rname+"' => [");
+      Enumeration props = ((Vector) aa.get(rname)).elements();
+      while (props.hasMoreElements())
+      {
+        System.out.print("'"+(String)props.nextElement()+"'");
+        if (props.hasMoreElements())
+        {
+          System.out.println(", ");
+        }
+      }
+      System.out.println("]"+(res.hasMoreElements() ? "," : ""));
+    }
+    System.out.println("};");
+  }
+  // to here
 }