1 package jalview.analysis;
3 import static org.testng.Assert.assertEquals;
5 import jalview.math.MatrixI;
7 import org.testng.annotations.Test;
11 @Test(groups = "Functional")
12 public void testComputePairwiseScores()
14 String[] seqs = new String[] { "FKL", "R-D", "QIA", "GWC" };
15 PCA pca = new PCA(seqs, false, "BLOSUM62");
17 MatrixI pairwise = pca.computePairwiseScores();
20 * should be NxN where N = number of sequences
22 assertEquals(pairwise.height(), 4);
23 assertEquals(pairwise.width(), 4);
26 * should be symmetrical (because BLOSUM62 is)
28 for (int i = 0; i < pairwise.height(); i++)
30 for (int j = 0; j < pairwise.width(); j++)
32 assertEquals(pairwise.getValue(i, j), pairwise.getValue(j, i),
37 * verify expected BLOSUM dot product scores
38 * Note: gap is treated like 'X' [22] in the matrix
40 // F.F + K.K + L.L = 6 + 5 + 4 = 15
41 assertEquals(pairwise.getValue(0, 0), 15d);
42 // R.R + X.X + D.D = 5 + -1 + 6 = 10
43 assertEquals(pairwise.getValue(1, 1), 10d);
44 // Q.Q + I.I + A.A = 5 + 4 + 4 = 13
45 assertEquals(pairwise.getValue(2, 2), 13d);
46 // G.G + W.W + C.C = 6 + 11 + 9 = 26
47 assertEquals(pairwise.getValue(3, 3), 26d);
48 // F.R + K.X + L.D = -3 + -1 + -3 = -8
49 assertEquals(pairwise.getValue(0, 1), -8d);
50 // F.Q + K.I + L.A = -3 + -3 + -1 = -7
51 assertEquals(pairwise.getValue(0, 2), -7d);
52 // F.G + K.W + L.C = -3 + -3 + -1 = -7
53 assertEquals(pairwise.getValue(0, 3), -7d);
54 // R.Q + X.I + D.A = 1 + -1 + -2 = -2
55 assertEquals(pairwise.getValue(1, 2), -2d);
56 // R.G + X.W + D.C = -2 + -2 + -3 = -7
57 assertEquals(pairwise.getValue(1, 3), -7d);
58 // Q.G + I.W + A.C = -2 + -3 + 0 = -5
59 assertEquals(pairwise.getValue(2, 3), -5d);