Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rpg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas MAILLET
rpg
Commits
0f5fa6f7
Commit
0f5fa6f7
authored
7 years ago
by
Nicolas MAILLET
Browse files
Options
Downloads
Patches
Plain Diff
Correct bug when several rules apply at same time
parent
d2dda0e8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rpg/digest.py
+4
-3
4 additions, 3 deletions
rpg/digest.py
rpg/rule.py
+23
-6
23 additions, 6 deletions
rpg/rule.py
with
27 additions
and
9 deletions
rpg/digest.py
+
4
−
3
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
...
...
This diff is collapsed.
Click to expand it.
rpg/rule.py
+
23
−
6
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment