JAL-4134 catch NPE - though in principle this should never happen…
[jalview.git] / src / jalview / analysis / AverageDistanceEngine.java
index 20b3e83..f4d69d5 100644 (file)
@@ -100,10 +100,13 @@ public class AverageDistanceEngine extends TreeEngine
 
       // compute distance matrix element
       ContactListI ith = cm.getContactList(i);
-
+      distances.setValue(i, i, 0);
+      if (ith==null)
+      {
+        continue;
+      }
       for (int j = 0; j < i; j++)
       {
-        distances.setValue(i, i, 0);
         ContactListI jth = cm.getContactList(j);
         if (jth == null)
         {