Skip to content

Commit

Permalink
Fixed a couple of typos in comments. PEP8 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed Jan 28, 2013
1 parent 708d3ee commit 6a31cb3
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions Tests/test_pairwise2.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -379,22 +379,24 @@ def test_align_one_char3(self):




class TestPersiteGapPenalties(unittest.TestCase): class TestPersiteGapPenalties(unittest.TestCase):
""" """Check gap penalty callbacks use correct gap opening position.
This tests that the gap penalty callbacks are really being used with the correct gap opening position.
The second test forces a bad alignment by having a very expsive gap penalty where one would noremally expect a gap, and a cheap gap pentaly in another place.
"""
This tests that the gap penalty callbacks are really being used
with the correct gap opening position.
"""


def test_gap_here_only_1(self): def test_gap_here_only_1(self):
seq1 = "AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA" seq1 = "AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA"
seq2 = "AABBBAAAACCCCAAAABBBAA" seq2 = "AABBBAAAACCCCAAAABBBAA"
breaks = [0,11,len(seq2)] breaks = [0, 11, len(seq2)]
nogaps = lambda x,y: -2000 -y#Very expensive to open a gap in seq1 # Very expensive to open a gap in seq1:
specificgaps = lambda x,y: (-2 -y) if x in breaks else (-2000 -y)#Very expensive to open a gap in seq2 unless it is in one of the allowed positions nogaps = lambda x, y: -2000 - y
alignments = pairwise2.align.globalmc(seq1,seq2,1,-1,nogaps,specificgaps) # Very expensive to open a gap in seq2 unless it is in one of the allowed positions
self.assertEqual(len(alignments),1) specificgaps = lambda x, y: (-2 -y) if x in breaks else (-2000 - y)
alignments = pairwise2.align.globalmc(seq1, seq2, 1, -1, nogaps, specificgaps)
self.assertEqual(len(alignments), 1)
formatted = pairwise2.format_alignment(*alignments[0]) formatted = pairwise2.format_alignment(*alignments[0])
self.assertEqual(formatted,"""\ self.assertEqual(formatted, """\
AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA
|||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||||||||||
--AABBBAAAACC----------CCAAAABBBAA-- --AABBBAAAACC----------CCAAAABBBAA--
Expand All @@ -403,15 +405,23 @@ def test_gap_here_only_1(self):




def test_gap_here_only_2(self): def test_gap_here_only_2(self):
"""Force a bad alignment.
Forces a bad alignment by having a very expensive gap penalty
where one would normally expect a gap, and a cheap gap penalty
in another place.
"""
seq1 = "AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA" seq1 = "AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA"
seq2 = "AABBBAAAACCCCAAAABBBAA" seq2 = "AABBBAAAACCCCAAAABBBAA"
breaks = [0,3,len(seq2)] breaks = [0, 3, len(seq2)]
nogaps = lambda x,y: -2000 -y#Very expensive to open a gap in seq1 #Very expensive to open a gap in seq1:
specificgaps = lambda x,y: (-2 -y) if x in breaks else (-2000 -y)#Very expensive to open a gap in seq2 unless it is in one of the allowed positions nogaps = lambda x, y: -2000 - y
alignments = pairwise2.align.globalmc(seq1,seq2,1,-1,nogaps,specificgaps) #Very expensive to open a gap in seq2 unless it is in one of the allowed positions:
self.assertEqual(len(alignments),1) specificgaps = lambda x, y: (-2 - y) if x in breaks else (-2000 - y)
alignments = pairwise2.align.globalmc(seq1, seq2, 1, -1, nogaps, specificgaps)
self.assertEqual(len(alignments), 1)
formatted = pairwise2.format_alignment(*alignments[0]) formatted = pairwise2.format_alignment(*alignments[0])
self.assertEqual(formatted,"""\ self.assertEqual(formatted, """\
AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA AAAABBBAAAACCCCCCCCCCCCCCAAAABBBAAAA
|||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||||||||||
--AAB----------BBAAAACCCCAAAABBBAA-- --AAB----------BBAAAACCCCAAAABBBAA--
Expand Down

0 comments on commit 6a31cb3

Please sign in to comment.