def test7(self): s1 = "CCCAAAAATTTAAAAACCCCCGGG" s2 = "GGGAAAAAAAAAATTTCCCCCCCC" S = self.S3 o = 5 c = 2 correct_score = 128 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o, c) self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), s, "Returned alignment score does not match actual alignment score") self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), correct_score, "Score of returned alignment is not optimal")
def test3(self): s1 = "AAAAAGTGAAAAA" s2 = "AAAAACAAAAA" S = self.S2 o = 2 c = 1 correct_score = 35 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o, c) self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), s, "Returned alignment score does not match actual alignment score") self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), correct_score, "Score of returned alignment is not optimal")
def test7(self): s1 = "CCCAAAAATTTAAAAACCCCCGGG" s2 = "GGGAAAAAAAAAATTTCCCCCCCC" S = self.S3 o = 5 c = 2 correct_score = 128 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o, c) self.assertEqual( alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), s, "Returned alignment score does not match actual alignment score") self.assertEqual(alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), correct_score, "Score of returned alignment is not optimal")
def test3(self): s1 = "AAAAAGTGAAAAA" s2 = "AAAAACAAAAA" S = self.S2 o = 2 c = 1 correct_score = 35 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o, c) self.assertEqual( alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), s, "Returned alignment score does not match actual alignment score") self.assertEqual(alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), correct_score, "Score of returned alignment is not optimal")
def mcalliTest(self): s1 = 'CCCCCCCCCAAAAAAAAAAAAAAAAAAATAAACCCCCCC' s2 = 'CCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTCCCCCCC' S = {x:{y:100*self.S2[x][y] for y in "ACGT"} for x in "ACGT"} o = 500 c = 1 correct_score = 5462 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o,c) self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), s, "Returned alignment score does not match actual alignment") self.assertEqual(alignment_util.scoreAlignmentAffine(a1,a2,S,o,c), correct_score, "Score of returned alignment is not optimal") t, b1, b2 = alignment.SmithWatermanAffine(s2, s1, S, o,c) self.assertEqual(alignment_util.scoreAlignmentAffine(b1,b2,S,o,c), t, "Returned alignment score does not match actual alignment") self.assertEqual(alignment_util.scoreAlignmentAffine(b1,b2,S,o,c), correct_score, "Score of returned alignment is not optimal")
def test_SWA(seq1, seq2, S, o, c): s, a1, a2 = alignment.SmithWatermanAffine(seq1, seq2, S, o, c) s_sol, a1_sol, a2_sol = alignment_sol.SmithWatermanAffine(seq1, seq2, S, o, c) score = 0 # First: test that the function has returned has an optimal alignment if alignment_util.scoreAlignmentAffine(a1, a2, S, o, c) == s_sol: score += 70 # Second: test that the function has returned an optimal score if s == s_sol: score += 20 # Third: Test that the function has returned the correct score for the alignment if alignment_util.scoreAlignmentAffine(a1, a2, S, o, c) == s: score += 10 return score/100.0
def test_SWA(seq1, seq2, S, o, c): s, a1, a2 = alignment.SmithWatermanAffine(seq1, seq2, S, o, c) s_sol, a1_sol, a2_sol = alignment_sol.SmithWatermanAffine( seq1, seq2, S, o, c) score = 0 # First: test that the function has returned has an optimal alignment if alignment_util.scoreAlignmentAffine(a1, a2, S, o, c) == s_sol: score += 70 # Second: test that the function has returned an optimal score if s == s_sol: score += 20 # Third: Test that the function has returned the correct score for the alignment if alignment_util.scoreAlignmentAffine(a1, a2, S, o, c) == s: score += 10 return score / 100.0
def mcalliTest(self): s1 = 'CCCCCCCCCAAAAAAAAAAAAAAAAAAATAAACCCCCCC' s2 = 'CCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTCCCCCCC' S = {x: {y: 100 * self.S2[x][y] for y in "ACGT"} for x in "ACGT"} o = 500 c = 1 correct_score = 5462 s, a1, a2 = alignment.SmithWatermanAffine(s1, s2, S, o, c) self.assertEqual( alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), s, "Returned alignment score does not match actual alignment") self.assertEqual(alignment_util.scoreAlignmentAffine(a1, a2, S, o, c), correct_score, "Score of returned alignment is not optimal") t, b1, b2 = alignment.SmithWatermanAffine(s2, s1, S, o, c) self.assertEqual( alignment_util.scoreAlignmentAffine(b1, b2, S, o, c), t, "Returned alignment score does not match actual alignment") self.assertEqual(alignment_util.scoreAlignmentAffine(b1, b2, S, o, c), correct_score, "Score of returned alignment is not optimal")