{
AlignSeq as = new AlignSeq(new Sequence("s1", "PFY"), new Sequence(
"s2", "RQW"), AlignSeq.PEP);
- int[] expected = new int[] { 0, 0, 1, 1, 2, 2, 21, 21, 22, 22, -1, 24,
+ int[] expected = new int[] { 0, 0, 1, 1, 2, 2, 21, 21, 22, 22, -1, -1,
-1, 23, -1 };
String s = "aArRnNzZxX *.-?";
assertArrayEquals(expected, as.indexEncode(s));
// note score matrix does not have to be symmetric (though it should be!)
float[][] scores = new float[3][];
scores[0] = new float[] { 1f, 2f, 3f };
- scores[1] = new float[] { 4f, 5f, 6f };
+ scores[1] = new float[] { -4f, 5f, 6f };
scores[2] = new float[] { 7f, 8f, 9f };
ScoreMatrix sm = new ScoreMatrix("Test", "ABC".toCharArray(), scores);
assertEquals(sm.getSize(), 3);
assertEquals(sm.getPairwiseScore('A', 'a'), 1f);
assertEquals(sm.getPairwiseScore('b', 'c'), 6f);
assertEquals(sm.getPairwiseScore('c', 'b'), 8f);
- assertEquals(sm.getPairwiseScore('A', 'D'), 0f);
assertEquals(sm.getMatrixIndex('c'), 2);
assertEquals(sm.getMatrixIndex(' '), -1);
+ // substitution to or from unknown symbol gets minimum score
+ assertEquals(sm.getPairwiseScore('A', 'D'), -4f);
+ assertEquals(sm.getPairwiseScore('D', 'A'), -4f);
+ // unknown-to-self gets a score of 1
+ assertEquals(sm.getPairwiseScore('D', 'D'), 1f);
+
assertEquals(sm.getGapIndex(), -1); // no gap symbol
}
{
float[][] scores = new float[2][];
scores[0] = new float[] { 1f, 2f };
- scores[1] = new float[] { 4f, 5f };
+ scores[1] = new float[] { -4f, 5f };
ScoreMatrix sm = new ScoreMatrix("Test", new char[] { 'A', 'B' },
scores);
assertEquals(sm.getPairwiseScore('A', 'A'), 1f);
assertEquals(sm.getPairwiseScore('A', 'a'), 1f);
assertEquals(sm.getPairwiseScore('A', 'B'), 2f);
- assertEquals(sm.getPairwiseScore('b', 'a'), 4f);
+ assertEquals(sm.getPairwiseScore('b', 'a'), -4f);
assertEquals(sm.getPairwiseScore('B', 'b'), 5f);
/*
- * unknown symbols currently score zero
+ * unknown symbols currently score minimum score
+ * or 1 for identity with self
*/
- assertEquals(sm.getPairwiseScore('A', '-'), 0f);
- assertEquals(sm.getPairwiseScore('-', '-'), 0f);
- assertEquals(sm.getPairwiseScore('Q', 'W'), 0f);
+ assertEquals(sm.getPairwiseScore('A', '-'), -4f);
+ assertEquals(sm.getPairwiseScore('-', 'A'), -4f);
+ assertEquals(sm.getPairwiseScore('-', '-'), 1f);
+ assertEquals(sm.getPairwiseScore('Q', 'W'), -4f);
+ assertEquals(sm.getPairwiseScore('Q', 'Q'), 1f);
/*
* symbols not in basic ASCII set score zero
assertNull(sm.getDescription());
assertTrue(sm.isDNA());
assertFalse(sm.isProtein());
+ assertEquals(sm.getMinimumScore(), 1.1f);
assertEquals(sm.getPairwiseScore('A', 'A'), 1.1f);
assertEquals(sm.getPairwiseScore('A', 'T'), 1.2f);
assertEquals(sm.getPairwiseScore('a', 'T'), 1.2f); // A/a equivalent
assertEquals(sm.getPairwiseScore('a', 't'), 1.4f);
assertEquals(sm.getPairwiseScore('U', 'x'), 3.5f);
assertEquals(sm.getPairwiseScore('u', 'x'), 3.5f);
- assertEquals(sm.getPairwiseScore('U', 'X'), 0f); // X (upper) unmapped
- assertEquals(sm.getPairwiseScore('A', '.'), 0f); // . unmapped
+ // X (upper) and '.' unmapped - get minimum score
+ assertEquals(sm.getPairwiseScore('U', 'X'), 1.1f);
+ assertEquals(sm.getPairwiseScore('A', '.'), 1.1f);
assertEquals(sm.getPairwiseScore('-', '-'), 7.6f);
assertEquals(sm.getPairwiseScore('A', (char) 128), 0f); // out of range
}