def test_simple_amino(self): simple_result = pattern_search.SimpleAmino('A') assert simple_result.amino == 'A' with self.assertRaisesRegex(ValueError, 'Invalid amino acid'): pattern_search.SimpleAmino('B') assert simple_result.match('A') assert not simple_result.match('C')
def test_offset_ok_element(self): sequence = 'MAGICHAT' simple_amino = pattern_search.SimpleAmino('A') assert simple_amino.offset_ok(sequence, 0) assert not simple_amino.offset_ok(sequence, 8) simple_with_repeats = pattern_search.SimpleAmino('A(2)') assert simple_with_repeats.offset_ok(sequence, 0) assert not simple_with_repeats.offset_ok(sequence, 8)
def test_offset_ok_element_cterm(self): sequence = 'MAGICHAT' simple_cterm = pattern_search.SimpleAmino('M', cterm=True) assert simple_cterm.offset_ok(sequence, 7) assert not simple_cterm.offset_ok(sequence, 6) cterm_with_repeats = pattern_search.SimpleAmino('M(2)', cterm=True) assert cterm_with_repeats.offset_ok(sequence, 7) assert cterm_with_repeats.offset_ok(sequence, 6) assert not cterm_with_repeats.offset_ok(sequence, 2) cterm_range = pattern_search.SimpleAmino('M(1,4)', cterm=True) assert cterm_range.offset_ok(sequence, 7) assert cterm_range.offset_ok(sequence, 4) assert not cterm_range.offset_ok(sequence, 0)
def test_match_with_next(self): simple_amino = pattern_search.SimpleAmino('A') any_amino = pattern_search.AnyAmino('x', simple_amino) assert any_amino.match_including_following('MAGICHAT') assert any_amino.match_including_following('MAGICHAT').distance == 2 assert any_amino.match_including_following('MAGICHAT', 5)
def test_match_all_lengths_03(self): sequence = 'AAATAAAA' multi_a_1 = pattern_search.SimpleAmino('A(0,3)') simple_t = pattern_search.SimpleAmino('T', multi_a_1) multi_a_2 = pattern_search.SimpleAmino('A(0,3)', simple_t) assert len(multi_a_2.match_all_possible(sequence)) == 4
def test_match_all_lengths_04(self): sequence = 'MAAAAGIC' multiple_as = pattern_search.SimpleAmino('A(0,4)') simple_m = pattern_search.SimpleAmino('M', multiple_as) assert len(simple_m.match_all_possible(sequence)) == 5
def test_match_all_lengths_12(self): sequence = 'MAAGGIC' multiple_as = pattern_search.SimpleAmino( 'A(1,2)', pattern_search.SimpleAmino('G(1,2)')) simple_m = pattern_search.SimpleAmino('M', multiple_as) assert len(simple_m.match_all_possible(sequence)) == 2