sys-bio / tellurium

Python Environment for Modeling and Simulating Biological Systems
http://tellurium.analogmachine.org/
Apache License 2.0
110 stars 36 forks source link

Data generators who ids are equal to Python reserved words should be supported #450

Open jonrkarr opened 4 years ago

jonrkarr commented 4 years ago

The following SED-ML generates the following error:

<dataGenerator id="as" name="as">
      <math xmlns="http://www.w3.org/1998/Math/MathML">
        <ci> as </ci>
      </math>
      <listOfVariables>
        <variable id="as" name="as" target="/sbml:sbml/sbml:model/sbml:listOfParameters/sbml:parameter[@id=&apos;as&apos;]" taskReference="BIOMD0000000757_sim"/>
      </listOfVariables>
    </dataGenerator>
<dataSet id="as" label="as" dataReference="as"/>
Traceback (most recent call last):
  File "/usr/local/bin/tellurium", line 11, in <module>
    load_entry_point('Biosimulations-tellurium', 'console_scripts', 'tellurium')()
  File "/home/jonrkarr/Documents/Biosimulations_tellurium/Biosimulations_tellurium/__main__.py", line 51, in main
    app.run()
  File "/usr/local/lib/python3.7/site-packages/cement/core/foundation.py", line 916, in run
    return_val = self.controller._dispatch()
  File "/usr/local/lib/python3.7/site-packages/cement/ext/ext_argparse.py", line 808, in _dispatch
    return func()
  File "/home/jonrkarr/Documents/Biosimulations_tellurium/Biosimulations_tellurium/__main__.py", line 36, in _default
    exec_combine_archive(args.archive, args.out_dir)
  File "/home/jonrkarr/Documents/Biosimulations_tellurium/Biosimulations_tellurium/core.py", line 72, in exec_combine_archive
    factory.executePython()
  File "/usr/local/lib/python3.7/site-packages/tellurium/sedml/tesedml.py", line 505, in executePython
    exec(compile(code, filename, 'exec'), symbols)
  File "/tmp/te-generated-sedml.py", line 127
    as = __var__as

SyntaxError: invalid syntax
0u812 commented 4 years ago

Thanks for the report! Working on a branch to fix this and other sedml issues. For my / others' reference the BioModels test case for this is BIOMD0000000757 in the archive you provided.

jonrkarr commented 4 years ago

I tried to distill the issues I found down to minimal examples. If it would be helpful to have more examples, I can share the collection of SED-ML files I derived from BioModels (what I used to find these issues). These have been cleaned up, whereas the original SED-ML files from BioModels have a significant number of issues (mainly invalid references) which make them hard to work with. I have these both as SED-ML files and OMEX archives.

0u812 commented 4 years ago

Many thanks! The minimal examples you provided made it easy to find & fix the errors, but I wanted to have something to test against to make sure the fix actually worked. If you could share the OMEX archives you mentioned, that would be much appreciated! I'm mainly using the error logs you provided to run through the relevant BioModels that cause a given error.

jonrkarr commented 4 years ago

Here's the OMEX files. The SED-ML should be semantically valid. If you find any issues, please let me know.

FYI, these files have no repeated tasks. I removed all repeated tasks from the original SED-ML files because we're trying to handle these differently. The original files only have a few repeated tasks anyway.

The files also have no AddXML, RemoveXML, NewXML, ChangeXML or 3d plots because the original SED-ML files don't use these classes.

0u812 commented 4 years ago

Many thanks!