*/
package jalview.analysis;
+import jalview.analysis.scoremodels.PIDModel;
import jalview.api.analysis.DistanceScoreModelI;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
{
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)
{
}
}
}
+
+ /**
+ * Multiply every entry in the matrix by the given value. This method is not
+ * thread-safe.
+ */
+ @Override
+ public void multiply(double d)
+ {
+ for (double[] row : value)
+ {
+ if (row != null)
+ {
+ for (int i = 0; i < row.length; i++)
+ {
+ row[i] *= d;
+ }
+ }
+ }
+ }
}
assertEquals(m1.getValue(1, 2), 15d, DELTA);
}
+ @Test(groups = "Functional")
+ public void testMultiply()
+ {
+ Matrix m = new Matrix(new double[][] { { 2, 3.5, 4 }, { -3.4, 4, 15 } });
+ m.multiply(2d);
+ assertEquals(m.getValue(0, 0), 4d, DELTA);
+ assertEquals(m.getValue(0, 1), 7d, DELTA);
+ assertEquals(m.getValue(0, 2), 8d, DELTA);
+ assertEquals(m.getValue(1, 0), -6.8d, DELTA);
+ assertEquals(m.getValue(1, 1), 8d, DELTA);
+ assertEquals(m.getValue(1, 2), 30d, DELTA);
+ }
}