+ /*
+ * for (int seq=0;seq<symm.rows;seq++) { ps.print("\"Seq"+seq+"\""); for
+ * (int ev=0;ev<symm.rows; ev++) {
+ *
+ * ps.print(","+component(seq, ev)); } ps.println(); }
+ */
+ // System.out.println(("PCA.run() took "
+ // + (System.currentTimeMillis() - now) + "ms"));
+ }
+
+ /**
+ * Computes a pairwise similarity matrix for the given sequence regions using
+ * the configured score model. If the score model is a similarity model, then
+ * it computes the result directly. If it is a distance model, then use it to
+ * compute pairwise distances, and convert these to similarity scores.
+ *
+ * @param av
+ * @return
+ */
+ MatrixI computeSimilarity(AlignmentView av)
+ {
+ MatrixI result = null;
+ if (scoreModel instanceof SimilarityScoreModelI)
+ {
+ result = ((SimilarityScoreModelI) scoreModel).findSimilarities(av,
+ similarityParams);
+ }
+ else if (scoreModel instanceof DistanceScoreModelI)
+ {
+ /*
+ * find distances and convert to similarity scores
+ * reverseRange(false) preserves but reverses the min-max range
+ */
+ result = ((DistanceScoreModelI) scoreModel).findDistances(av,
+ similarityParams);
+ result.reverseRange(false);
+ }
+ else
+ {
+ System.err
+ .println("Unexpected type of score model, cannot calculate similarity");
+ }
+
+ return result;
+ }
+
+ public void setJvCalcMode(boolean calcMode)
+ {
+ this.jvCalcMode = calcMode;
+ }
+
+ /**
+ * Answers the N dimensions of the NxN PCA matrix. This is the number of
+ * sequences involved in the pairwise score calculation.
+ *
+ * @return
+ */
+ public int getHeight()
+ {
+ // TODO can any of seqs[] be null?
+ return seqs.getSequences().length;