applied 2009 GPL license
[jalview.git] / src / jalview / analysis / PCA.java
index 0cc2e76..58c1345 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -25,24 +25,29 @@ import jalview.math.*;
 
 /**
  * Performs Principal Component Analysis on given sequences
- *
+ * 
  * @author $author$
  * @version $Revision$
  */
-public class PCA
-    implements Runnable
+public class PCA implements Runnable
 {
   Matrix m;
+
   Matrix symm;
+
   Matrix m2;
+
   double[] eigenvalue;
+
   Matrix eigenvector;
+
   StringBuffer details = new StringBuffer();
 
   /**
    * Creates a new PCA object.
-   *
-   * @param s Set of sequences to perform PCA on
+   * 
+   * @param s
+   *                Set of sequences to perform PCA on
    */
   public PCA(String[] s)
   {
@@ -50,7 +55,7 @@ public class PCA
     BinarySequence[] bs = new BinarySequence[s.length];
     int ii = 0;
 
-    while ( (ii < s.length) && (s[ii] != null))
+    while ((ii < s.length) && (s[ii] != null))
     {
       bs[ii] = new BinarySequence(s[ii]);
       bs[ii].encode();
@@ -60,18 +65,18 @@ public class PCA
     BinarySequence[] bs2 = new BinarySequence[s.length];
     ii = 0;
 
-    while ( (ii < s.length) && (s[ii] != null))
+    while ((ii < s.length) && (s[ii] != null))
     {
       bs2[ii] = new BinarySequence(s[ii]);
       bs2[ii].blosumEncode();
       ii++;
     }
 
-    //System.out.println("Created binary encoding");
-    //printMemory(rt);
+    // System.out.println("Created binary encoding");
+    // printMemory(rt);
     int count = 0;
 
-    while ( (count < bs.length) && (bs[count] != null))
+    while ((count < bs.length) && (bs[count] != null))
     {
       count++;
     }
@@ -87,9 +92,9 @@ public class PCA
       i++;
     }
 
-    //System.out.println("Created array");
-    //printMemory(rt);
-    //    System.out.println(" --- Original matrix ---- ");
+    // System.out.println("Created array");
+    // printMemory(rt);
+    // System.out.println(" --- Original matrix ---- ");
     m = new Matrix(seqmat, count, bs[0].getDBinary().length);
     m2 = new Matrix(seqmat2, count, bs2[0].getDBinary().length);
 
@@ -97,7 +102,7 @@ public class PCA
 
   /**
    * Returns the matrix used in PCA calculation
-   *
+   * 
    * @return java.math.Matrix object
    */
 
@@ -108,9 +113,10 @@ public class PCA
 
   /**
    * Returns Eigenvalue
-   *
-   * @param i Index of diagonal within matrix
-   *
+   * 
+   * @param i
+   *                Index of diagonal within matrix
+   * 
    * @return Returns value of diagonal from matrix
    */
   public double getEigenvalue(int i)
@@ -120,12 +126,16 @@ public class PCA
 
   /**
    * DOCUMENT ME!
-   *
-   * @param l DOCUMENT ME!
-   * @param n DOCUMENT ME!
-   * @param mm DOCUMENT ME!
-   * @param factor DOCUMENT ME!
-   *
+   * 
+   * @param l
+   *                DOCUMENT ME!
+   * @param n
+   *                DOCUMENT ME!
+   * @param mm
+   *                DOCUMENT ME!
+   * @param factor
+   *                DOCUMENT ME!
+   * 
    * @return DOCUMENT ME!
    */
   public float[][] getComponents(int l, int n, int mm, float factor)
@@ -144,9 +154,10 @@ public class PCA
 
   /**
    * DOCUMENT ME!
-   *
-   * @param n DOCUMENT ME!
-   *
+   * 
+   * @param n
+   *                DOCUMENT ME!
+   * 
    * @return DOCUMENT ME!
    */
   public double[] component(int n)
@@ -164,10 +175,12 @@ public class PCA
 
   /**
    * DOCUMENT ME!
-   *
-   * @param row DOCUMENT ME!
-   * @param n DOCUMENT ME!
-   *
+   * 
+   * @param row
+   *                DOCUMENT ME!
+   * @param n
+   *                DOCUMENT ME!
+   * 
    * @return DOCUMENT ME!
    */
   double component(int row, int n)
@@ -231,9 +244,9 @@ public class PCA
     details.append(" --- Eigenvalues ---\n");
     eigenvector.printD(ps);
     ps.println();
-    //  taps.println();
-    //  taps.println("Transformed sequences = ");
-    // Matrix trans =  m.preMultiply(eigenvector);
-    //  trans.print(System.out);
+    // taps.println();
+    // taps.println("Transformed sequences = ");
+    // Matrix trans = m.preMultiply(eigenvector);
+    // trans.print(System.out);
   }
 }