diff --git a/source/_static/code/restriction.py b/source/_static/code/restriction.py index f160bfa900457174da7b0aeb5a8c86d7c3988be8..4966eaf8f2cf90cda83fc632d6c7568d898784d8 100644 --- a/source/_static/code/restriction.py +++ b/source/_static/code/restriction.py @@ -30,6 +30,28 @@ def one_enz_all_binding_sites(dna, enzyme): return positions +def one_enz_all_binding_sites2(dna, enzyme): + """ + :param dna: the dna sequence to search enzyme binding sites + :type dna: str + :param enzyme: the enzyme to looking for + :type enzyme: a namedtuple RestrictEnzyme + :return: all positions of enzyme binding sites in dna + :rtype: list of int + """ + positions = [] + pos = dna.find(enzyme.sequence) + while pos != -1: + if positions: + positions.append(pos) + else: + positions = pos + positions[-1] + new_seq = dna[pos + 1:] + pos = new_seq.find(enzyme.sequence) + pos = pos + return positions + + def binding_sites(dna, enzymes): """ return all positions of all enzymes binding sites present in dna