import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class ScoreMatrixTest
{
@Test(groups = "Functional")
scores[1] = new float[] { -4f, 5f, 6f };
scores[2] = new float[] { 7f, 8f, 9f };
ScoreMatrix sm = new ScoreMatrix("Test", "ABC".toCharArray(), scores);
+ assertFalse(sm.isSymmetric());
assertEquals(sm.getSize(), 3);
assertArrayEquals(scores, sm.getMatrix());
assertEquals(sm.getPairwiseScore('A', 'a'), 1f);
+ "</table>";
assertEquals(html, expected);
}
+
+ @Test(groups = "Functional")
+ public void testIsSymmetric()
+ {
+ float[][] scores = new float[2][];
+ scores[0] = new float[] { 1f, -2f };
+ scores[1] = new float[] { -2f, 1f };
+ ScoreMatrix sm = new ScoreMatrix("Test", "AB".toCharArray(), scores);
+ assertTrue(sm.isSymmetric());
+
+ scores[1] = new float[] { 2f, 1f };
+ sm = new ScoreMatrix("Test", "AB".toCharArray(), scores);
+ assertFalse(sm.isSymmetric());
+
+ /*
+ * verify that forcing an asymmetric matrix to use
+ * symmetric calculation gives a different (wrong) result
+ */
+ SimilarityParamsI params = new SimilarityParams(true, true, true,
+ false);
+ String[] seqs = new String[] { "AAABBBAA", "AABBABBA" };
+ MatrixI res1 = sm.findSimilarities(seqs, params);
+ MatrixI res2 = sm.findSimilarities(seqs, params);
+ assertTrue(res1.equals(res2));
+ PA.setValue(sm, "symmetric", true);
+ assertTrue(sm.isSymmetric()); // it's not true!
+ res2 = sm.findSimilarities(seqs, params);
+ assertFalse(res1.equals(res2));
+ }
}