Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean formulas when processing askenet #184

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mira/sources/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
"""Sources of models."""


def clean_formula(f):
"""Return an expression that can be parsed using sympy."""
return f.replace('lambda', 'XXlambdaXX')
4 changes: 3 additions & 1 deletion mira/sources/askenet/petrinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import requests

from mira.metamodel import *
from .. import clean_formula


def model_from_url(url: str) -> TemplateModel:
Expand Down Expand Up @@ -256,7 +257,8 @@ def transition_to_templates(transition_rate, input_concepts, output_concepts,
controller_concepts, symbols):
"""Return a list of templates from a transition"""
rate_law_expression = transition_rate.get('expression')
rate_law = sympy.parse_expr(rate_law_expression, local_dict=symbols) \
rate_law = sympy.parse_expr(clean_formula(rate_law_expression),
local_dict=symbols) \
if rate_law_expression else None
if not controller_concepts:
if not input_concepts:
Expand Down
5 changes: 1 addition & 4 deletions mira/sources/sbml/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from mira.metamodel import *
from mira.resources import get_resource_file
from .. import clean_formula


class TqdmLoggingHandler(logging.Handler):
Expand Down Expand Up @@ -814,7 +815,3 @@ def parse_context_grounding(grounding_str):


grounding_map = _get_grounding_map()


def clean_formula(f):
return f.replace('lambda', 'XXlambdaXX')