Verified Commit 2d2a2a71 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

remove buggy version

parent cf55de4c
from operator import itemgetter
def one_enz_binding_site(dna, enzyme):
def one_enz_one_binding_site(dna, enzyme):
"""
return the first position of enzyme binding site in dna
or None if there is not
:return: the first position of enzyme binding site in dna or None if there is not
:rtype: int or None
"""
print("one_enz_binding_one_site", dna, enzyme)
pos = dna.find(enzyme.sequence)
print("one_enz_binding_one_site", pos)
if pos != -1:
return pos
def one_enz_binding_sites1(dna, enzyme):
"""
return all positions of enzyme binding sites in dna
"""
positions = []
pos = dna.find(enzyme.sequence)
if pos != -1:
positions.append(pos)
positions.extend(one_enz_binding_site1(dna[pos+1:], enzyme))
return positions
def one_enz_binding_sites(dna, enzyme):
def one_enz_all_binding_sites(dna, enzyme):
"""
return all positions of enzyme binding sites in dna
: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)
......@@ -38,13 +33,20 @@ def one_enz_binding_sites(dna, enzyme):
def binding_sites(dna, enzymes):
"""
return all positions of all enzymes binding sites present in dna
sort by the incresing position
sort by the increasing position.
: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 each enzyme binding sites in dna
:rtype: list of int
"""
positions = []
for enzyme in enzymes:
pos = one_enz_binding_sites(dna, enzyme)
pos = one_enz_all_binding_sites(dna, enzyme)
pos = [(enzyme.name, pos) for pos in pos]
positions.extend(pos)
positions.sort(key = itemgetter(1))
positions.sort(key=itemgetter(1))
return positions
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment