JAL-2668 add tests for HMMER commands, annotation and io
[jalview.git] / src / jalview / analysis / AAFrequency.java
index 9f905f6..6a69c73 100755 (executable)
@@ -228,14 +228,13 @@ public class AAFrequency
   {
     ProfileI[] result = new ProfileI[width];
     int symbolCount = hmm.getNumberOfSymbols();
-    String alph = hmm.getAlphabetType();
     for (int column = start; column < end; column++)
     {
       ResidueCount counts = new ResidueCount();
       for (char symbol : hmm.getSymbols())
       {
-        int value = getAnalogueCount(hmm, column, removeBelowBackground,
-                alph, symbol);
+        int value = getAnalogueCount(hmm, column, symbol,
+                removeBelowBackground);
         counts.put(symbol, value);
       }
       int maxCount = counts.getModalCount();
@@ -902,7 +901,6 @@ public class AAFrequency
 
     if (hmm != null)
     {
-      String alph = hmm.getAlphabetType();
       int size = hmm.getNumberOfSymbols();
       char symbols[] = new char[size];
       int values[] = new int[size];
@@ -913,8 +911,8 @@ public class AAFrequency
       {
         char symbol = charList.get(i);
         symbols[i] = symbol;
-        int value = getAnalogueCount(hmm, column, removeBelowBackground,
-                alph, symbol);
+        int value = getAnalogueCount(hmm, column, symbol,
+                removeBelowBackground);
         values[i] = value;
         totalCount += value;
       }
@@ -961,20 +959,21 @@ public class AAFrequency
    * @param hmm
    * @param column
    * @param removeBelowBackground
-   * @param alph
-   *          The alphabet the HMM is based on
+   *          When true, this method returns 0 for any symbols with a match
+   *          emission probability less than the background frequency.
    * @param symbol
    * @return
    */
-  private static int getAnalogueCount(HiddenMarkovModel hmm, int column,
-          boolean removeBelowBackground, String alph, char symbol)
+  static int getAnalogueCount(HiddenMarkovModel hmm, int column,
+          char symbol, boolean removeBelowBackground)
   {
     Double value;
 
     value = hmm.getMatchEmissionProbability(column, symbol);
     double freq;
 
-    freq = ResidueProperties.backgroundFrequencies.get(alph).get(symbol);
+    freq = ResidueProperties.backgroundFrequencies
+            .get(hmm.getAlphabetType()).get(symbol);
     if (value < freq && removeBelowBackground)
     {
       return 0;