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

GillesPy2 1.6.5 cannot read some SBML files #646

Closed
jonrkarr opened this issue Nov 23, 2021 · 0 comments · Fixed by #647 or #653
Closed

GillesPy2 1.6.5 cannot read some SBML files #646

jonrkarr opened this issue Nov 23, 2021 · 0 comments · Fixed by #647 or #653
Assignees
Labels
bug Something isn't working ✔️​ Issue / PR has been resolved
Milestone

Comments

@jonrkarr
Copy link
Contributor

This appears to be a new regression in 1.6.5. This issue was not present in 1.6.4 and earlier. Other tools such as COPASI, tellurium, and VCell are able to read such files.

Detected in biosimulators/Biosimulators#458.

Example: model_ODE_stochastic.xml

Steps to reproduce

import gillespy2
gillespy2.import_SBML('model_ODE_stochastic.xml')

Error

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/usr/local/lib/python3.9/dist-packages/gillespy2/core/parameter.py in _evaluate(self, namespace)
     82         try:
---> 83             self.value = (float(eval(self.expression, namespace)))
     84         except Exception as error:

<string> in <module>

NameError: name 'nan' is not defined

The above exception was the direct cause of the following exception:

ParameterError                            Traceback (most recent call last)
<ipython-input-2-11e49c19eadd> in <module>
----> 1 gillespy2.import_SBML('../Biosimulators_test_suite/examples/sbml-core/Vilar-PNAS-2002-minimal-circardian-clock-discrete-SSA/model_ODE_stochastic.xml')

/usr/local/lib/python3.9/dist-packages/gillespy2/core/model.py in import_SBML(filename, name, gillespy_model)
     61         raise ImportError('SBML conversion not imported successfully')
     62 
---> 63     return convert(filename, model_name=name, gillespy_model=gillespy_model)
     64 
     65 

/usr/local/lib/python3.9/dist-packages/gillespy2/sbml/SBMLimport.py in convert(filename, model_name, gillespy_model)
    393 
    394     __get_function_definitions(sbml_model, gillespy_model)
--> 395     __get_parameters(sbml_model, gillespy_model)
    396     __get_species(sbml_model, gillespy_model, errors)
    397     __get_compartments(sbml_model, gillespy_model)

/usr/local/lib/python3.9/dist-packages/gillespy2/sbml/SBMLimport.py in __get_parameters(sbml_model, gillespy_model)
    132         if parameter.isSetConstant():
    133             gillespy_parameter = gillespy2.Parameter(name=name, expression=value)
--> 134             gillespy_model.add_parameter([gillespy_parameter])
    135         else:
    136             gillespy_species = gillespy2.Species(name=name,initial_value=value)

/usr/local/lib/python3.9/dist-packages/gillespy2/core/model.py in add_parameter(self, params)
    415         if isinstance(params, list):
    416             for p in sorted(params):
--> 417                 self.add_parameter(p)
    418         else:
    419             if isinstance(params, Parameter) or type(params).__name__ == 'Parameter':

/usr/local/lib/python3.9/dist-packages/gillespy2/core/model.py in add_parameter(self, params)
    422                     raise problem
    423                 self.update_namespace()
--> 424                 params._evaluate(self.namespace)
    425                 self.listOfParameters[params.name] = params
    426                 self._listOfParameters[params.name] = 'P{}'.format(len(self._listOfParameters))

/usr/local/lib/python3.9/dist-packages/gillespy2/core/parameter.py in _evaluate(self, namespace)
     83             self.value = (float(eval(self.expression, namespace)))
     84         except Exception as error:
---> 85             raise ParameterError("Could not evaluate expression: {}.".format(str(error))) from error
     86 
     87     def sanitized_expression(self, species_mappings, parameter_mappings):

ParameterError: Could not evaluate expression: name 'nan' is not defined.

Environment

  • GillesPy2 1.6.5
  • libSBML 5.19.2 (the same problem also occurs with 5.19.0)
  • Python: 3.9.5
  • OS: Ubuntu 20
@BryanRumsey BryanRumsey linked a pull request Nov 29, 2021 that will close this issue
@BryanRumsey BryanRumsey self-assigned this Nov 29, 2021
@BryanRumsey BryanRumsey added the bug Something isn't working label Nov 29, 2021
@BryanRumsey BryanRumsey added this to the 1.6.6 milestone Nov 29, 2021
@BryanRumsey BryanRumsey added the ✔️​ Issue / PR has been resolved label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ✔️​ Issue / PR has been resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants