Merge branch 'develop' into features/JAL-2393customMatrices
[jalview.git] / src / jalview / analysis / PCA.java
index 43f2161..5d2e7e7 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.analysis;
 
+import jalview.analysis.scoremodels.PIDModel;
 import jalview.api.analysis.DistanceScoreModelI;
 import jalview.api.analysis.ScoreModelI;
 import jalview.api.analysis.SimilarityParamsI;
@@ -223,8 +224,7 @@ public class PCA implements Runnable
    * 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.
+   * compute pairwise distances, and convert these to similarity scores.
    * 
    * @param av
    * @return
@@ -236,9 +236,21 @@ public class PCA implements Runnable
     {
       result = ((SimilarityScoreModelI) scoreModel).findSimilarities(av,
               similarityParams);
+      if (scoreModel instanceof PIDModel)
+      {
+        /*
+         * scale % identities to width of alignment for backwards
+         * compatibility with Jalview 2.10.1 SeqSpace PCA calculation 
+         */
+        result.multiply(av.getWidth() / 100d);
+      }
     }
     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);