Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub-courses
python_one_week_4_biologists_solutions
Commits
a5c2a361
Verified
Commit
a5c2a361
authored
Mar 18, 2019
by
Bertrand NÉRON
Browse files
add2nd implementation for one_enz_all_binding_sites
parent
779fff97
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/_static/code/restriction.py
View file @
a5c2a361
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment