StochSS / GillesPy2

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

Bug in EventAssignment for SBML import #884

Closed vwiela closed 1 year ago

vwiela commented 2 years ago

While trying to use the gillespy2.importSBML('file') function, I got the following error:

EventError: GillesPy2 Event Assignment expression requires a valid string expression

Apparently, when one wants to import an SBML-model the gillespy2.import_SBML('file') will call the following lines (353-360) in the SBMLimport.py script.

 assignments = event.getListOfEventAssignments()
        for a in assignments:
            .
            .
            .
            gillespy_assignment = gillespy2.EventAssignment(a.getVariable(),
                __get_math(a.getMath()))
            gillespy_assignments.append(gillespy_assignment)

I checked my SBML model and the expressions where strings, so I checked all calls that are made within the EventAssignment function and everything worked. But looking into gillespy2/core/events.py script, where the EventAssignment function is defined, a bit closer, one sees that the function needs three arguments to be passed.

def __init__(self, name=None, variable=None, expression=None):

So if I call the function manually and specify a name or just call it with specification of the inputs as follows

 gillespy2.EventAssignment(variable=a.getVariable(),
                expression=__get_math(a.getMath()))

no error occurs. Hence, I guess the error is not in my SBML file but rather in the way the function is called in the SBMLimport.py script.

BryanRumsey commented 2 years ago

Thank you for reporting this issue it will be addressed in the next release.