StochSS / GillesPy2

Modeling toolkit for biochemical simulation
http://gillespy2.readthedocs.io/
GNU General Public License v3.0
72 stars 32 forks source link

GillesPy2 lost capabilities for assignment rules between 1.5.7 and 1.5.9 #515

Closed jonrkarr closed 3 years ago

jonrkarr commented 3 years ago

This example (BIOMD0000000297.xml.zip) executed with 1.5.7, but now fails with 1.5.9 and 1.5.10

Error

import gillespy2

gillespy2.import_SBML('tests/fixtures/BIOMD0000000297.edited/ex1/BIOMD0000000297.xml')
---------------------------------------------------------------------------
ModelError                                Traceback (most recent call last)
~/.local/lib/python3.9/site-packages/gillespy2/core/model.py in add_assignment_rule(self, assignment_rules)
    564                 if problem is not None:
--> 565                     raise problem
    566                 if len(self.listOfRateRules) != 0:

ModelError: Name "kswe" is unavailable. A species with that name exists.

During handling of the above exception, another exception occurred:

ParameterError                            Traceback (most recent call last)
<ipython-input-2-38951b6d0dac> in <module>
----> 1 gillespy2.import_SBML('tests/fixtures/BIOMD0000000297.edited/ex1/BIOMD0000000297.xml')

~/.local/lib/python3.9/site-packages/gillespy2/core/model.py in import_SBML(filename, name, gillespy_model)
     42         raise ImportError('SBML conversion not imported successfully')
     43 
---> 44     return convert(filename, model_name=name, gillespy_model=gillespy_model)
     45 
     46 

~/.local/lib/python3.9/site-packages/gillespy2/sbml/SBMLimport.py in convert(filename, model_name, gillespy_model)
    364     __get_compartments(sbml_model, gillespy_model)
    365     __get_reactions(sbml_model, gillespy_model, errors)
--> 366     __get_rules(sbml_model, gillespy_model, errors)
    367     __get_constraints(sbml_model, gillespy_model)
    368     __get_events(sbml_model, gillespy_model)

~/.local/lib/python3.9/site-packages/gillespy2/sbml/SBMLimport.py in __get_rules(sbml_model, gillespy_model, errors)
    232             gillespy_rule = gillespy2.AssignmentRule(name=rule_name, variable=rule_variable,
    233                 formula=rule_string)
--> 234             gillespy_model.add_assignment_rule(gillespy_rule)
    235             init_state[gillespy_rule.variable]=eval(gillespy_rule.formula, {**init_state, **eval_globals})
    236 

~/.local/lib/python3.9/site-packages/gillespy2/core/model.py in add_assignment_rule(self, assignment_rules)
    582                 self.listOfAssignmentRules[assignment_rules.name] = assignment_rules
    583             except Exception as e:
--> 584                 raise ParameterError("Error using {} as a Assignment Rule. Reason given: ".format(assignment_rules, e))
    585 
    586     def timespan(self, time_span):

ParameterError: Error using kswe: kswe_prime * Swe1 + kswe_doubleprime * Swe1M + kswe_tripleprime * PSwe1 as a Assignment Rule. Reason given: 
ethangreen-dev commented 3 years ago

Fixed in release v1.5.11