JAL-967, JAL-1114, JAL-1115 - modified render and calculation api to work on bare...
[jalview.git] / src / jalview / analysis / AAFrequency.java
index 375504d..7e77b0f 100755 (executable)
@@ -219,33 +219,40 @@ public class AAFrequency
     }
     for (int i = iStart; i < width; i++)
     {
-      if (i >= hconsensus.length)
+      Hashtable hci;
+      if (i >= hconsensus.length || ((hci=hconsensus[i])==null))
       {
         // happens if sequences calculated over were shorter than alignment
         // width
         consensus.annotations[i] = null;
         continue;
       }
+
       value = 0;
+      Float fv;
       if (ignoreGapsInConsensusCalculation)
       {
-        value = ((Float) hconsensus[i].get(AAFrequency.PID_NOGAPS))
-                .floatValue();
+        fv = (Float) hci.get(AAFrequency.PID_NOGAPS);
       }
       else
       {
-        value = ((Float) hconsensus[i].get(AAFrequency.PID_GAPS))
-                .floatValue();
+        fv = (Float) hci.get(AAFrequency.PID_GAPS);
       }
-
-      String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
-      String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
+      if (fv==null)
+      {
+        consensus.annotations[i] = null;
+        // data has changed below us .. give up and
+        continue;
+      }
+      value = fv.floatValue();
+      String maxRes = hci.get(AAFrequency.MAXRESIDUE).toString();
+      String mouseOver = hci.get(AAFrequency.MAXRESIDUE) + " ";
       if (maxRes.length() > 1)
       {
         mouseOver = "[" + maxRes + "] ";
         maxRes = "+";
       }
-      int[][] profile = (int[][]) hconsensus[i].get(AAFrequency.PROFILE);
+      int[][] profile = (int[][]) hci.get(AAFrequency.PROFILE);
       if (profile != null && includeAllConsSymbols)
       {
         mouseOver = "";