Commit 2548da8f authored by Nicolas  MAILLET's avatar Nicolas MAILLET
Browse files

Correct a major bug when a new enzyme is define and does not have anything...

Correct a major bug when a new enzyme is define and does not have anything before the cleaving site in the definition, and more than one following aa after the cleaving site, i.e. (,E)(E)(E). Closes #1
parent 3a5b976a
......@@ -582,25 +582,40 @@ def create_rules(all_rules):
exceptions.append(dict_rule)
# No exception
else:
# Parse all after cleaving site first
for i in reversed(sorted(dict_rule_no_main.keys())):
# Find the deepest rule: left if exist, otherwise, right
# Find the deepest rule: left if exist, otherwise, right
if len(dict_rule_no_main.keys()) > 0:
min_key = min(dict_rule_no_main.keys()) # Deep on left
max_key = max(dict_rule_no_main.keys()) # Deep on right
if min_key < 0: # Something left, change it (leftest)
if i == min_key:
cleav = not cleav
# Something left
if min_key < 0:
# Parse all after cleaving site first in reverse
for i in reversed(sorted(dict_rule_no_main.keys())):
# Deeper rule, change it (leftest)
if i == min_key:
cleav = not cleav
# Create the rule
this_rule = Rule(i, dict_rule_no_main[i], cleav, -1)
# Add this rule to upper-rule
if not previous_rule.equ(this_rule) and\
not previous_rule.contains_any_level(this_rule):
previous_rule.rules.append(this_rule)
# Current rule is the new down-rule
previous_rule = this_rule
else: # Nothing left, change deepest rule at right
if i == max_key:
cleav = not cleav
# Create the rule
this_rule = Rule(i, dict_rule_no_main[i], cleav, -1)
# Add this rule to upper-rule
if not previous_rule.equ(this_rule) and\
not previous_rule.contains_any_level(this_rule):
previous_rule.rules.append(this_rule)
# Current rule is the new down-rule
previous_rule = this_rule
# Parse all after cleaving site first
for i in sorted(dict_rule_no_main.keys()):
# Deeper rule, change it (rightest)
if i == max_key:
cleav = not cleav
# Create the rule
this_rule = Rule(i, dict_rule_no_main[i], cleav, -1)
# Add this rule to upper-rule
if not previous_rule.equ(this_rule) and\
not previous_rule.contains_any_level(this_rule):
previous_rule.rules.append(this_rule)
# Current rule is the new down-rule
previous_rule = this_rule
# Create the corresponding rule
add_rule(correct_rules, cleaving_zone)
......
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