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
Nicolas MAILLET
rpg
Commits
0f5fa6f7
Commit
0f5fa6f7
authored
May 16, 2018
by
Nicolas MAILLET
Browse files
Correct bug when several rules apply at same time
parent
d2dda0e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
rpg/digest.py
View file @
0f5fa6f7
...
...
@@ -243,13 +243,14 @@ def one_digest(pep, enz):
ret
.
inc_nb_cleavage
()
# current position
previous_pos
=
pos
# Default: do not cut this position
cut
=
False
before
=
True
# Check each rules
for
rul
in
enz
.
rules
:
# Default: do not cut this position
cut
=
None
# Apply the rule: if we need to cut
if
rule
.
handle_rule
(
pep
.
sequence
,
pos
,
rul
,
cut
):
cut
=
rule
.
handle_rule
(
pep
.
sequence
,
pos
,
rul
,
cut
)
if
cut
is
True
:
# Random to handle miscleavage
tmp_rand
=
random
.
random
()
*
100
# Rand > ratio_miscleavage, no miscleavage occurs
...
...
rpg/rule.py
View file @
0f5fa6f7
...
...
@@ -786,7 +786,7 @@ def handle_rule(seq, pos, a_rule, cut):
:type cut: bool
:return: `True` if sequence must be cutted
:rtype: bool
:rtype: bool
or None
"""
# return of the function: should we cut this?
...
...
@@ -799,11 +799,28 @@ def handle_rule(seq, pos, a_rule, cut):
# If the rule applies, i.e. the letter to watch is the good one
if
(
pos
+
a_rule
.
index
)
>=
0
and
\
seq
[
pos
+
a_rule
.
index
]
==
a_rule
.
letter
:
ret
=
a_rule
.
cut
# Handle the rules (exceptions)
for
rul
in
a_rule
.
rules
:
# Apply the rule: do we need to cut?
ret
=
handle_rule
(
seq
,
pos
,
rul
,
ret
)
# If no previous 'False' and this is cutting
if
a_rule
.
cut
and
ret
is
not
False
:
ret
=
True
# Handle the sub-rules (exceptions)
for
rul
in
a_rule
.
rules
:
# Apply the rule: do we need to cut?
ret
=
handle_rule
(
seq
,
pos
,
rul
,
ret
)
# Is is not cutting
elif
not
a_rule
.
cut
:
# Reinit
ret
=
None
# Handle sub-rules
if
a_rule
.
rules
:
# Handle the rules (exceptions)
for
rul
in
a_rule
.
rules
:
# Apply the rule: do we need to cut?
ret
=
handle_rule
(
seq
,
pos
,
rul
,
ret
)
# No sub-rules and not cutting
else
:
# We are at the end a of rule that applies
# and say to NOT cut. So it will never cut.
ret
=
False
# Doesn't work: begin or end of sequence, don't change cut value
except
IndexError
:
pass
...
...
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