JAL-967, JAL-1114, JAL-1115 more concurrent access hacks
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 7 Jun 2012 17:07:46 +0000 (18:07 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 7 Jun 2012 17:07:46 +0000 (18:07 +0100)
src/jalview/analysis/StructureFrequency.java

index 1eab77e..67d8b9b 100644 (file)
@@ -310,7 +310,8 @@ public class StructureFrequency
     }
     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
@@ -318,29 +319,34 @@ public class StructureFrequency
         continue;
       }
       value = 0;
+      Float fv;
       if (ignoreGapsInConsensusCalculation)
       {
-        value = ((Float) hconsensus[i].get(StructureFrequency.PID_NOGAPS))
-                .floatValue();
+        fv =(Float) hci.get(StructureFrequency.PID_NOGAPS);
       }
       else
       {
-        value = ((Float) hconsensus[i].get(StructureFrequency.PID_GAPS))
-                .floatValue();
+        fv = (Float) hci.get(StructureFrequency.PID_GAPS);
       }
-
-      String maxRes = hconsensus[i].get(StructureFrequency.MAXRESIDUE)
+      if (fv==null)
+      {
+        consensus.annotations[i] = null;
+        // data has changed below us .. give up and
+        continue;
+      }
+      value = fv.floatValue();
+      String maxRes = hci.get(StructureFrequency.MAXRESIDUE)
               .toString();
-      String mouseOver = hconsensus[i].get(StructureFrequency.MAXRESIDUE)
+      String mouseOver = hci.get(StructureFrequency.MAXRESIDUE)
               + " ";
       if (maxRes.length() > 1)
       {
         mouseOver = "[" + maxRes + "] ";
         maxRes = "+";
       }
-      int[][] profile = (int[][]) hconsensus[i]
+      int[][] profile = (int[][]) hci
               .get(StructureFrequency.PROFILE);
-      int[][] pairs = (int[][]) hconsensus[i]
+      int[][] pairs = (int[][]) hci
               .get(StructureFrequency.PAIRPROFILE);
 
       if (pairs != null && includeAllConsSymbols) // Just responsible for the