+ // 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 by
+ * substracting from the maximum value.
+ *
+ * @param av
+ * @return
+ */
+ MatrixI computeSimilarity(AlignmentView av)
+ {
+ MatrixI result = null;
+ if (scoreModel instanceof SimilarityScoreModelI)
+ {
+ result = ((SimilarityScoreModelI) scoreModel).findSimilarities(av);
+ }
+ else if (scoreModel instanceof DistanceScoreModelI)
+ {
+ result = ((DistanceScoreModelI) scoreModel).findDistances(av);
+ double maxDistance = result.getMaxValue();
+ result.subtractAllFrom(maxDistance);
+ }
+ 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;