JAL-3725 restrict mapped virtual feature location to mapped region
[jalview.git] / src / jalview / viewmodel / PCAModel.java
index 3403887..1693294 100644 (file)
@@ -29,6 +29,7 @@ import jalview.datamodel.Point;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequencePoint;
 
+import java.util.List;
 import java.util.Vector;
 
 public class PCAModel
@@ -36,7 +37,7 @@ public class PCAModel
   /*
    * inputs
    */
-  private final AlignmentView seqstrings;
+  private AlignmentView inputData;
 
   private final SequenceI[] seqs;
 
@@ -56,7 +57,7 @@ public class PCAModel
 
   int top;
 
-  private Vector<SequencePoint> points;
+  private List<SequencePoint> points;
 
   /**
    * Constructor given sequence data, score model and score calculation
@@ -71,7 +72,7 @@ public class PCAModel
   public PCAModel(AlignmentView seqData, SequenceI[] sqs, boolean nuc,
           ScoreModelI modelName, SimilarityParamsI params)
   {
-    seqstrings = seqData;
+    inputData = seqData;
     seqs = sqs;
     nucleotide = nuc;
     scoreModel = modelName;
@@ -84,7 +85,7 @@ public class PCAModel
    */
   public void calculate()
   {
-    pca = new PCA(seqstrings, scoreModel, similarityParams);
+    pca = new PCA(inputData, scoreModel, similarityParams);
     pca.run(); // executes in same thread, wait for completion
 
     // Now find the component coordinates
@@ -105,7 +106,7 @@ public class PCAModel
     for (int i = 0; i < height; i++)
     {
       SequencePoint sp = new SequencePoint(seqs[i], scores[i]);
-      points.addElement(sp);
+      points.add(sp);
     }
   }
 
@@ -125,17 +126,22 @@ public class PCAModel
   }
 
   /**
+   * Answers the index of the principal dimension of the PCA
    * 
-   * 
-   * @return index of principle dimension of PCA
+   * @return
    */
   public int getTop()
   {
     return top;
   }
 
+  public void setTop(int t)
+  {
+    top = t;
+  }
+
   /**
-   * update the 2d coordinates for the list of points to the given dimensions
+   * Updates the 3D coordinates for the list of points to the given dimensions.
    * Principal dimension is getTop(). Next greatest eigenvector is getTop()-1.
    * Note - pca.getComponents starts counting the spectrum from rank-2 to zero,
    * rather than rank-1, so getComponents(dimN ...) == updateRcView(dimN+1 ..)
@@ -151,7 +157,7 @@ public class PCAModel
 
     for (int i = 0; i < pca.getHeight(); i++)
     {
-      points.elementAt(i).coord = scores[i];
+      points.get(i).coord = scores[i];
     }
   }
 
@@ -160,9 +166,14 @@ public class PCAModel
     return pca.getDetails();
   }
 
-  public AlignmentView getSeqtrings()
+  public AlignmentView getInputData()
   {
-    return seqstrings;
+    return inputData;
+  }
+
+  public void setInputData(AlignmentView data)
+  {
+    inputData = data;
   }
 
   public String getPointsasCsv(boolean transformed, int xdim, int ydim,
@@ -203,7 +214,7 @@ public class PCAModel
       }
       else
       {
-        Point p = points.elementAt(s).coord;
+        Point p = points.get(s).coord;
         csv.append(",").append(p.x);
         csv.append(",").append(p.y);
         csv.append(",").append(p.z);
@@ -213,29 +224,48 @@ public class PCAModel
     return csv.toString();
   }
 
+  public String getScoreModelName()
+  {
+    return scoreModel == null ? "" : scoreModel.getName();
+  }
+
+  public void setScoreModel(ScoreModelI sm)
+  {
+    this.scoreModel = sm;
+  }
+
   /**
+   * Answers the parameters configured for pairwise similarity calculations
    * 
-   * @return x,y,z positions of point s (index into points) under current
-   *         transform.
+   * @return
    */
-  public double[] getPointPosition(int s)
+  public SimilarityParamsI getSimilarityParameters()
   {
-    double pts[] = new double[3];
-    Point p = points.elementAt(s).coord;
-    pts[0] = p.x;
-    pts[1] = p.y;
-    pts[2] = p.z;
-    return pts;
+    return similarityParams;
   }
 
-  public String getScoreModelName()
+  public List<SequencePoint> getSequencePoints()
   {
-    return scoreModel == null ? "" : scoreModel.getName();
+    return points;
   }
 
-  public void setScoreModel(ScoreModelI sm)
+  public void setSequencePoints(List<SequencePoint> sp)
   {
-    this.scoreModel = sm;
+    points = sp;
+  }
+
+  /**
+   * Answers the object holding the values of the computed PCA
+   * 
+   * @return
+   */
+  public PCA getPcaData()
+  {
+    return pca;
   }
 
+  public void setPCA(PCA data)
+  {
+    pca = data;
+  }
 }