transferred the storage position of the HMM to annotations
[jalview.git] / src / jalview / schemes / ResidueProperties.java
index 751175d..4a56fbc 100755 (executable)
@@ -39,14 +39,20 @@ public class ResidueProperties
 
   public static final int[] purinepyrimidineIndex;
 
-  public static final Map<String, Integer> aa3Hash = new HashMap<String, Integer>();
+  public static final Map<String, Integer> aa3Hash = new HashMap<>();
 
-  public static final Map<String, String> aa2Triplet = new HashMap<String, String>();
+  public static final Map<String, String> aa2Triplet = new HashMap<>();
 
-  public static final Map<String, String> nucleotideName = new HashMap<String, String>();
+  public static final Map<String, String> nucleotideName = new HashMap<>();
 
   // lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET)
-  public static final Map<String, String> modifications = new HashMap<String, String>();
+  public static final Map<String, String> modifications = new HashMap<>();
+
+  // amino acid background Frequencies
+  public static final Map<Character, Float> aminoBackgroundFrequencies = new HashMap<>();
+
+  // nucleotide background Frequencies
+  public static final Map<Character, Float> nucleotideBackgroundFrequencies = new HashMap<>();
 
   static
   {
@@ -500,18 +506,18 @@ public class ResidueProperties
   /**
    * Nucleotide Ambiguity Codes
    */
-  public static final Map<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
+  public static final Map<String, String[]> ambiguityCodes = new Hashtable<>();
 
   /**
    * Codon triplets with additional symbols for unambiguous codons that include
    * ambiguity codes
    */
-  public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
+  public static final Hashtable<String, String> codonHash2 = new Hashtable<>();
 
   /**
    * all ambiguity codes for a given base
    */
-  public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
+  public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<>();
 
   static
   {
@@ -635,7 +641,7 @@ public class ResidueProperties
         List<String> codesfor = _ambiguityCodes.get(r);
         if (codesfor == null)
         {
-          _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
+          _ambiguityCodes.put(r, codesfor = new ArrayList<>());
         }
         if (!codesfor.contains(acode.getKey()))
         {
@@ -751,27 +757,27 @@ public class ResidueProperties
   }
 
   // Stores residue codes/names and colours and other things
-  public static Map<String, Map<String, Integer>> propHash = new Hashtable<String, Map<String, Integer>>();
+  public static Map<String, Map<String, Integer>> propHash = new Hashtable<>();
 
-  public static Map<String, Integer> hydrophobic = new Hashtable<String, Integer>();
+  public static Map<String, Integer> hydrophobic = new Hashtable<>();
 
-  public static Map<String, Integer> polar = new Hashtable<String, Integer>();
+  public static Map<String, Integer> polar = new Hashtable<>();
 
-  public static Map<String, Integer> small = new Hashtable<String, Integer>();
+  public static Map<String, Integer> small = new Hashtable<>();
 
-  public static Map<String, Integer> positive = new Hashtable<String, Integer>();
+  public static Map<String, Integer> positive = new Hashtable<>();
 
-  public static Map<String, Integer> negative = new Hashtable<String, Integer>();
+  public static Map<String, Integer> negative = new Hashtable<>();
 
-  public static Map<String, Integer> charged = new Hashtable<String, Integer>();
+  public static Map<String, Integer> charged = new Hashtable<>();
 
-  public static Map<String, Integer> aromatic = new Hashtable<String, Integer>();
+  public static Map<String, Integer> aromatic = new Hashtable<>();
 
-  public static Map<String, Integer> aliphatic = new Hashtable<String, Integer>();
+  public static Map<String, Integer> aliphatic = new Hashtable<>();
 
-  public static Map<String, Integer> tiny = new Hashtable<String, Integer>();
+  public static Map<String, Integer> tiny = new Hashtable<>();
 
-  public static Map<String, Integer> proline = new Hashtable<String, Integer>();
+  public static Map<String, Integer> proline = new Hashtable<>();
 
   static
   {
@@ -1151,7 +1157,7 @@ public class ResidueProperties
   public static Hashtable<String, String> toDssp3State;
   static
   {
-    toDssp3State = new Hashtable<String, String>();
+    toDssp3State = new Hashtable<>();
     toDssp3State.put("H", "H");
     toDssp3State.put("E", "E");
     toDssp3State.put("C", " ");
@@ -2509,6 +2515,40 @@ public class ResidueProperties
 
   }
 
+  static
+  {
+    aminoBackgroundFrequencies.put('A', 0.0826f);
+    aminoBackgroundFrequencies.put('Q', 0.0393f);
+    aminoBackgroundFrequencies.put('L', 0.0965f);
+    aminoBackgroundFrequencies.put('S', 0.0661f);
+    aminoBackgroundFrequencies.put('R', 0.0553f);
+    aminoBackgroundFrequencies.put('E', 0.0674f);
+    aminoBackgroundFrequencies.put('K', 0.0582f);
+    aminoBackgroundFrequencies.put('T', 0.0535f);
+    aminoBackgroundFrequencies.put('N', 0.0406f);
+    aminoBackgroundFrequencies.put('G', 0.0708f);
+    aminoBackgroundFrequencies.put('M', 0.0241f);
+    aminoBackgroundFrequencies.put('W', 0.0109f);
+    aminoBackgroundFrequencies.put('D', 0.0546f);
+    aminoBackgroundFrequencies.put('H', 0.0227f);
+    aminoBackgroundFrequencies.put('F', 0.0386f);
+    aminoBackgroundFrequencies.put('Y', 0.0292f);
+    aminoBackgroundFrequencies.put('C', 0.0137f);
+    aminoBackgroundFrequencies.put('I', 0.0593f);
+    aminoBackgroundFrequencies.put('P', 0.0472f);
+    aminoBackgroundFrequencies.put('V', 0.0686f);
+
+  }
+
+  static
+  {
+    nucleotideBackgroundFrequencies.put('A', 0.25f);
+    nucleotideBackgroundFrequencies.put('C', 0.25f);
+    nucleotideBackgroundFrequencies.put('T', 0.25f);
+    nucleotideBackgroundFrequencies.put('G', 0.25f);
+
+  }
+
   public static String getCanonicalAminoAcid(String aA)
   {
     String canonical = modifications.get(aA);
@@ -2519,7 +2559,7 @@ public class ResidueProperties
   // / cut here
   public static void main(String[] args)
   {
-    Hashtable<String, Vector<String>> aaProps = new Hashtable<String, Vector<String>>();
+    Hashtable<String, Vector<String>> aaProps = new Hashtable<>();
     System.out.println("my %aa = {");
     // invert property hashes
     for (String pname : propHash.keySet())
@@ -2530,7 +2570,7 @@ public class ResidueProperties
         Vector<String> aprops = aaProps.get(rname);
         if (aprops == null)
         {
-          aprops = new Vector<String>();
+          aprops = new Vector<>();
           aaProps.put(rname, aprops);
         }
         Integer hasprop = phash.get(rname);
@@ -2572,7 +2612,7 @@ public class ResidueProperties
   public static List<String> getResidues(boolean forNucleotide,
           boolean includeAmbiguous)
   {
-    List<String> result = new ArrayList<String>();
+    List<String> result = new ArrayList<>();
     if (forNucleotide)
     {
       for (String nuc : nucleotideName.keySet())