JAL-2629 moved HMM storage location to placeholder sequence
[jalview.git] / src / jalview / analysis / AAFrequency.java
index 3cc57bf..900209d 100755 (executable)
@@ -61,6 +61,8 @@ public class AAFrequency
 
   private static final String DNA = "DNA";
 
+  private static final String RNA = "RNA";
+
   /*
    * Quick look-up of String value of char 'A' to 'Z'
    */
@@ -107,6 +109,7 @@ public class AAFrequency
     }
   }
 
+
   /**
    * Calculate the consensus symbol(s) for each column in the given range.
    * 
@@ -727,23 +730,21 @@ public class AAFrequency
   }
 
   /**
-   * produces a HMM profile for a column in an alignment
+   * Produces a HMM profile for a column in an alignment
    * 
    * @param aa
-   *          Alignment annotation for which the profile is being calculated
+   *          Alignment annotation for which the profile is being calculated.
    * @param column
-   *          column in the alignment the profile is being made for
+   *          Column in the alignment the profile is being made for.
    * @param removeBelowBackground
-   *          boolean, indicating whether to ignore residues with probabilities
-   *          less than their background frequencies
+   *          Boolean indicating whether to ignore residues with probabilities
+   *          less than their background frequencies.
    * @return
    */
-  public static int[] getHMMProfileFor(AlignmentAnnotation aa, int column,
+  public static int[] getHMMProfileFor(HiddenMarkovModel hmm, int column,
           boolean removeBelowBackground)
   {
 
-    HiddenMarkovModel hmm;
-    hmm = aa.getHMM();
     if (hmm != null)
     {
       String alph = hmm.getAlphabetType();
@@ -762,7 +763,7 @@ public class AAFrequency
         value = hmm.getMatchEmissionProbability(column, symbol);
         double freq;
 
-        if (alph == AMINO && removeBelowBackground)
+        if (AMINO.equals(alph) && removeBelowBackground)
         {
           freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol);
           if (value < freq)
@@ -770,9 +771,17 @@ public class AAFrequency
             value = 0d;
           }
         }
-        else if (alph == DNA && removeBelowBackground)
+        else if (DNA.equals(alph) && removeBelowBackground)
+        {
+          freq = ResidueProperties.dnaBackgroundFrequencies.get(symbol);
+          if (value < freq)
+          {
+            value = 0d;
+          }
+        }
+        else if (RNA.equals(alph) && removeBelowBackground)
         {
-          freq = ResidueProperties.nucleotideBackgroundFrequencies
+          freq = ResidueProperties.rnaBackgroundFrequencies
                   .get(symbol);
           if (value < freq)
           {