Skip to content
Snippets Groups Projects
Commit 6227ecc3 authored by Ariane Delrocq's avatar Ariane Delrocq
Browse files

testing align2steps; Closes #1

parent 9fad68fe
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,49 @@ class AlignmentSeqTestCase(unittest.TestCase):
print(ex_r1)
print(ex_r2)
raise
def test_blosum_align2steps(self):
"""Tests alignments with blosum and gap extension.
"""
from alignementseq import align2steps
for s1, s2, filename in self.get_dataset_heads():
(ex_r1, ex_r2, exp_score, *_) = Bio.pairwise2.align.globaldd(
s1.seq, s2.seq, blosum62, -8, -4, -8, -4, one_alignment_only=True)[0]
score, r1, r2 = align2steps(s1, s2)
try:
self.assertSameResidues(r1.seq, s1.seq)
self.assertSameResidues(r2.seq, s2.seq)
calc_score = 0 # score calculated from r1 and r2
gap1, gap2 = False, False
for a,b in zip(r1.seq, r2.seq):
if a == '-':
if not gap1:
gap1 = True
gap2 = False # suppose 2 gaps are never aligned
calc_score -= 8
else:
calc_score -= 4
elif b == '-':
if not gap2:
gap2 = True
gap1 = False
calc_score -= 8
else:
calc_score -= 4
else:
gap1, gap2 = False, False
calc_score += blosum62[a,b] if (a,b) in blosum62 else blosum62[b,a]
self.assertEqual(score, calc_score)
self.assertEqual(score, exp_score)
except AssertionError:
print('from', filename, "with", align2steps, ":")
print(r1.seq)
print(r2.seq)
print('')
print(ex_r1)
print(ex_r2)
raise
class PerformanceTestCase(AlignmentSeqTestCase):
"""Performance tests, slow.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment