From 7b90c1cf89c40a68253ab60fa517031c302dbf45 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 23 Sep 2005 16:17:33 +0000 Subject: [PATCH] Capture output as details --- src/jalview/analysis/PCA.java | 67 +++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index 4d691c0..4e7100d 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -22,6 +22,7 @@ import jalview.datamodel.*; import jalview.math.*; +import java.io.*; /** * Performs Principal Component Analysis on given sequences @@ -36,6 +37,7 @@ public class PCA implements Runnable Matrix m2; double[] eigenvalue; Matrix eigenvector; + StringBuffer details = new StringBuffer(); /** @@ -181,6 +183,11 @@ public class PCA implements Runnable return out / eigenvector.d[n]; } + public String getDetails() + { + return details.toString(); + } + /** * DOCUMENT ME! @@ -189,47 +196,43 @@ public class PCA implements Runnable { Matrix mt = m.transpose(); - // System.out.println(" --- OrigT * Orig ---- "); + details.append(" --- OrigT * Orig ---- \n"); eigenvector = mt.preMultiply(m2); - // eigenvector.print(System.out); + 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(); - //TextArea ta = new TextArea(25,72); - //TextAreaPrintStream taps = new TextAreaPrintStream(System.out,ta); - //Frame f = new Frame("PCA output"); - //f.resize(500,500); - //f.setLayout(new BorderLayout()); - //f.add("Center",ta); - //f.show(); - //symm.print(taps); - long tstart = System.currentTimeMillis(); eigenvector.tred(); - long tend = System.currentTimeMillis(); + details.append(" ---Tridiag transform matrix ---\n"); + details.append(" --- D vector ---\n"); + eigenvector.printD(ps); + ps.println(); + details.append("--- E vector ---\n"); + eigenvector.printE(ps); + ps.println(); - //taps.println("Time take for tred = " + (tend-tstart) + "ms"); - //taps.println(" ---Tridiag transform matrix ---"); - //taps.println(" --- D vector ---"); - //eigenvector.printD(taps); - //taps.println(); - //taps.println(" --- E vector ---"); - // eigenvector.printE(taps); - //taps.println(); // Now produce the diagonalization matrix - tstart = System.currentTimeMillis(); eigenvector.tqli(); - tend = System.currentTimeMillis(); - - //System.out.println("Time take for tqli = " + (tend-tstart) + " ms"); - //System.out.println(" --- New diagonalization matrix ---"); - //System.out.println(" --- Eigenvalues ---"); - //eigenvector.printD(taps); - //System.out.println(); - // for (int i=0; i < eigenvector.cols; i++) { - // checkEigenvector(i,taps); - // taps.println(); - // } + + + details.append(" --- New diagonalization matrix ---\n"); + details.append(" --- Eigenvalues ---\n"); + eigenvector.printD(ps); + ps.println(); // taps.println(); // taps.println("Transformed sequences = "); // Matrix trans = m.preMultiply(eigenvector); -- 1.7.10.2