JAL-1454 catch exceptions during calculation and report any warnings in the PCA ...
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 25 Feb 2014 16:44:29 +0000 (16:44 +0000)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 25 Feb 2014 16:44:29 +0000 (16:44 +0000)
src/jalview/analysis/PCA.java

index 7a506cc..89c6353 100755 (executable)
@@ -237,6 +237,20 @@ public class PCA implements Runnable
    */
   public void run()
   {
+    PrintStream ps = new PrintStream(System.out)
+    {
+      public void print(String x)
+      {
+        details.append(x);
+      }
+
+      public void println()
+      {
+        details.append("\n");
+      }
+    };
+
+    try {
     details.append("PCA Calculation Mode is "
             + (jvCalcMode ? "Jalview variant" : "Original SeqSpace") + "\n");
     Matrix mt = m.transpose();
@@ -251,19 +265,6 @@ public class PCA implements Runnable
       eigenvector = mt.preMultiply(m2); // jalview variation on seqsmace method
     }
 
-    PrintStream ps = new PrintStream(System.out)
-    {
-      public void print(String x)
-      {
-        details.append(x);
-      }
-
-      public void println()
-      {
-        details.append("\n");
-      }
-    };
-
     eigenvector.print(ps);
 
     symm = eigenvector.copy();
@@ -280,6 +281,12 @@ public class PCA implements Runnable
 
     // Now produce the diagonalization matrix
     eigenvector.tqli();
+    } catch (Exception q)
+    {
+      q.printStackTrace();
+      details.append("\n*** Unexpected exception when performing PCA ***\n"+q.getLocalizedMessage());
+      details.append("*** Matrices below may not be fully diagonalised. ***\n");
+    }
 
     details.append(" --- New diagonalization matrix ---\n");
     eigenvector.print(ps);