JAL-2599 fix for HMM logo not normalising correctly
authorTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Wed, 2 Aug 2017 12:06:43 +0000 (13:06 +0100)
committerTZVanaalten <TZVanaalten@LS30916.ad.lifesci.dundee.ac.uk>
Wed, 2 Aug 2017 12:06:43 +0000 (13:06 +0100)
src/jalview/analysis/AAFrequency.java

index d83f138..5ea892b 100755 (executable)
@@ -915,19 +915,27 @@ public class AAFrequency
 
       profile[0] = AlignmentAnnotation.SEQUENCE_PROFILE;
       profile[1] = size;
-      profile[2] = totalCount / 100;
+      profile[2] = 100;
 
       if (totalCount != 0)
       {
         int arrayPos = 3;
         for (int k = size - 1; k >= 0; k--)
         {
-          Double percentage;
+          Float percentage;
           Integer value = values[k];
-          percentage = (value.doubleValue() / totalCount.doubleValue())
-                  * 100d;
+          if (removeBelowBackground)
+          {
+            percentage = (value.floatValue() / totalCount.floatValue())
+                    * 100;
+          }
+          else
+          {
+            percentage = value.floatValue() / 100f;
+          }
+          int intPercent = Math.round(percentage);
           profile[arrayPos] = symbols[k];
-          profile[arrayPos + 1] = percentage.intValue();
+          profile[arrayPos + 1] = intPercent;
           arrayPos += 2;
         }
       }
@@ -969,6 +977,6 @@ public class AAFrequency
       }
     }
     value = value * 10000;
-    return value.intValue();
+    return Math.round(value.floatValue());
   }
 }