update author list in license for (JAL-826)
[jalview.git] / src / jalview / analysis / Conservation.java
index b557c5a..8e3b6e4 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
  * 
  * This file is part of Jalview.
  * 
@@ -87,7 +87,6 @@ public class Conservation
   public Conservation(String name, Hashtable propHash, int threshold,
           Vector sequences, int start, int end)
   {
-
     this.name = name;
     this.propHash = propHash;
     this.threshold = threshold;
@@ -100,7 +99,7 @@ public class Conservation
     int s, sSize = sequences.size();
     SequenceI[] sarray = new SequenceI[sSize];
     this.sequences = sarray;
-
+    try {
     for (s = 0; s < sSize; s++)
     {
       sarray[s] = (SequenceI) sequences.elementAt(s);
@@ -109,6 +108,12 @@ public class Conservation
         maxLength = sarray[s].getLength();
       }
     }
+    } catch (ArrayIndexOutOfBoundsException ex)
+    {
+      // bail - another thread has modified the sequence array, so the current calculation is probably invalid. 
+      this.sequences=new SequenceI[0];
+      maxLength=0;
+    }
   }
 
   /**
@@ -271,7 +276,9 @@ public class Conservation
         }
       }
 
-      total[i - start] = resultHash;
+      if (total.length>0) {
+        total[i - start] = resultHash;
+      }
     }
   }