biosimulators / Biosimulators_GillesPy2

GillesPy2 biochemical network simulation program via BioSimulators-compliant command-line interface and Docker container
https://docs.biosimulators.org/Biosimulators_GillesPy2
MIT License
1 stars 1 forks source link

Providing BIOMD0000000028.omex as input gives error #9

Closed bilalshaikh42 closed 3 years ago

bilalshaikh42 commented 3 years ago

using the file BIOMD0000000028.omex give the following error. The BIOMD0000000297.omex file is parsed correctly. The root level tag differs between the two. Biomod28 has the tag below, which may be causing the error with parsing the namespace.

<sedML xmlns="http://sed-ml.org/sed-ml/level1/version3"
   xmlns:addedPrefix="http://sed-ml.org/sed-ml/level1/version2" level="1" version="3">
File "gillespy2/lib/python3.8/site-packages/Biosimulations_utils/simulator/utils.py", line 74, in exec_simulations_in_archive
    task_executer(os.path.join(working_dir, model.file.name), model.format.sed_urn, simulation, working_dir, out_filename, 'csv')
  File "Biosimulators_GillesPy2/Biosimulators_gillespy2/core.py", line 260, in exec_simulation
    modify_xml_model_for_simulation(
  File "gillespy2/lib/python3.8/site-packages/Biosimulations_utils/simulation/sedml.py", line 1346, in modify_xml_model_for_simulation
    objs = et.xpath(obj_xpath, namespaces=namespaces)
  File "src/lxml/etree.pyx", line 2293, in lxml.etree._ElementTree.xpath
  File "src/lxml/xpath.pxi", line 325, in lxml.etree.XPathDocumentEvaluator.__init__
  File "src/lxml/xpath.pxi", line 259, in lxml.etree.XPathElementEvaluator.__init__
  File "src/lxml/xpath.pxi", line 131, in lxml.etree._XPathEvaluatorBase.__init__
  File "src/lxml/xpath.pxi", line 55, in lxml.etree._XPathContext.__init__
  File "src/lxml/extensions.pxi", line 81, in lxml.etree._BaseContext.__init__
TypeError: empty namespace prefix is not supported in XPath

@jonrkarr Do you know how to debug this? Is the sedml formatted incorrectly?

jonrkarr commented 3 years ago

It sounds like SED-ML may be treating the two versions slightly differently. One gathers the namespace prefix (maybe sedML). The other does not. I'll have to investigate further.

bilalshaikh42 commented 3 years ago

If i remember correctly, biomd28 was working correctly previously when I was using it to test the simulator. Was there a recent change to the utils that parses the sedml?

bilalshaikh42 commented 3 years ago

It seems the other omex archives in the test_utils use unsupported algorithms for gillespy. @jonrkarr do you have any other archives in mind, or should I try to create another?

jonrkarr commented 3 years ago

You can simply create another example by copying one of the existing examples and replace the KISAO algorithm term with one of the terms supported by GillesPy2.

To a degree, the terms for ODE and stochastic simulation are interchangeable. The differences matter in terms of the computational cost of simulation and whether a single trajectory is sampled vs the ensemble is integrated. But this isn't relevant to testing the interface of GillesPy2.

bilalshaikh42 commented 3 years ago

I am having some trouble with this. I updated the algorithms and was able to get the model to load. However, gillespy2 is throwing C++ compilation errors. I am trying to determine if this is due to my specific environment, but the docker image is not building due to a problem with setup tools. I can pip install on my local environment without any issues.

bilalshaikh42 commented 3 years ago

@jonrkarr are you able to pip install and then run gillespy2 -i tests/fixtures/BIOMD0000000297.omex in your env?

jonrkarr commented 3 years ago

I also see the same problem. This problem looks to be a GillesPy2 issue. I don't think this relates to libSBML or libSED-ML.

My environment

KISAO_0000029
140.0
2020-11-05 18:20:17,173 - root - WARNING - Please install/configure 'g++' and 'make' on your system, to ensure that GillesPy2 C solvers will run properly.
2020-11-05 18:20:17,173 - root - WARNING - Please install/configure 'g++' and 'make' on your system, to ensure that GillesPy2 C solvers will run properly.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/gillespy2/core/model.py", line 806, in run
    timeout=timeout, **solver_args)
  File "/usr/local/lib/python3.7/site-packages/gillespy2/solvers/cpp/ssa_c_solver.py", line 179, in run
    self = SSACSolver(model, resume=resume)
  File "/usr/local/lib/python3.7/site-packages/gillespy2/solvers/cpp/ssa_c_solver.py", line 105, in __init__
    self.__compile()
  File "/usr/local/lib/python3.7/site-packages/gillespy2/solvers/cpp/ssa_c_solver.py", line 160, in __compile
    built.stderr.decode('utf-8')))
gillespy2.core.gillespyError.BuildError: Error encountered while compiling file:
Return code: 2.
Error:
make: Entering directory '/tmp/tmpnx3lf9cy'
g++ -c -o model.o model.cpp -c -std=c++14 -Wall -O3
g++ -c -o ssa.o ssa.cpp -c -std=c++14 -Wall -O3
g++ -c -o UserSimulation.o UserSimulation.cpp -c -std=c++14 -Wall -O3
/usr/local/lib/python3.7/site-packages/gillespy2/solvers/cpp/c_base/makefile:14: recipe for target 'UserSimulation.o' failed
make: Leaving directory '/tmp/tmpnx3lf9cy'

model.cpp: In member function ‘void Gillespy::Simulation::output_results_buffer(std::ostream&)’:
model.cpp:86:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0 ; i < number_trajectories; i++){
                      ~~^~~~~~~~~~~~~~~~~~~~~
model.cpp:87:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j<number_timesteps;j++){
                         ~^~~~~~~~~~~~~~~~~
model.cpp:89:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int k = 0; k<model->number_species; k++){
                             ~^~~~~~~~~~~~~~~~~~~~~~
UserSimulation.cpp: In member function ‘virtual double PropensityFunction::evaluate(unsigned int, unsigned int*)’:
UserSimulation.cpp:105:34: error: ‘Clog’ was not declared in this scope
             return (S[24]*(((P46*Clog)+(P45*S[6]))+P44));
                                  ^~~~
UserSimulation.cpp:105:34: note: suggested alternative: ‘log’
             return (S[24]*(((P46*Clog)+(P45*S[6]))+P44));
                                  ^~~~
                                  log
UserSimulation.cpp:231:21: error: ‘kdclog’ was not declared in this scope
             return (kdclog*Clog);
                     ^~~~~~
UserSimulation.cpp:231:21: note: suggested alternative: ‘__log’
             return (kdclog*Clog);
                     ^~~~~~
                     __log
UserSimulation.cpp:234:21: error: ‘ksclog’ was not declared in this scope
             return (ksclog*S[18]);
                     ^~~~~~
UserSimulation.cpp:234:21: note: suggested alternative: ‘__log’
             return (ksclog*S[18]);
                     ^~~~~~
                     __log
make: *** [UserSimulation.o] Error 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/gillespy2", line 33, in <module>
    sys.exit(load_entry_point('biosimulators-gillespy2', 'console_scripts', 'gillespy2')())
  File "/home/jonrkarr/Documents/Biosimulators_GillesPy2/biosimulators_gillespy2/__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/Biosimulators_GillesPy2/biosimulators_gillespy2/__main__.py", line 36, in _default
    exec_combine_archive(args.archive, args.out_dir)
  File "/home/jonrkarr/Documents/Biosimulators_GillesPy2/biosimulators_gillespy2/core.py", line 216, in exec_combine_archive
    exec_simulations_in_archive(archive_file, exec_simulation, out_dir)
  File "/home/jonrkarr/Documents/Biosimulations_utils/Biosimulations_utils/simulator/utils.py", line 74, in exec_simulations_in_archive
    task_executer(os.path.join(working_dir, model.file.name), model.format.sed_urn, simulation, working_dir, out_filename, 'csv')
  File "/home/jonrkarr/Documents/Biosimulators_GillesPy2/biosimulators_gillespy2/core.py", line 281, in exec_simulation
    **algorithm_params, t=simulation.end_time)
  File "/usr/local/lib/python3.7/site-packages/gillespy2/core/model.py", line 818, in run
    "argument 'solver={}' to run() failed.  Reason Given: {}".format(solver, e))
gillespy2.core.gillespyError.SimulationError: argument 'solver=<class 'gillespy2.solvers.cpp.ssa_c_solver.SSACSolver'>' to run() failed.  Reason Given: Error encountered while compiling file:
Return code: 2.
Error:
make: Entering directory '/tmp/tmpnx3lf9cy'
g++ -c -o model.o model.cpp -c -std=c++14 -Wall -O3
g++ -c -o ssa.o ssa.cpp -c -std=c++14 -Wall -O3
g++ -c -o UserSimulation.o UserSimulation.cpp -c -std=c++14 -Wall -O3
/usr/local/lib/python3.7/site-packages/gillespy2/solvers/cpp/c_base/makefile:14: recipe for target 'UserSimulation.o' failed
make: Leaving directory '/tmp/tmpnx3lf9cy'

model.cpp: In member function ‘void Gillespy::Simulation::output_results_buffer(std::ostream&)’:
model.cpp:86:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0 ; i < number_trajectories; i++){
                      ~~^~~~~~~~~~~~~~~~~~~~~
model.cpp:87:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j<number_timesteps;j++){
                         ~^~~~~~~~~~~~~~~~~
model.cpp:89:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int k = 0; k<model->number_species; k++){
                             ~^~~~~~~~~~~~~~~~~~~~~~
UserSimulation.cpp: In member function ‘virtual double PropensityFunction::evaluate(unsigned int, unsigned int*)’:
UserSimulation.cpp:105:34: error: ‘Clog’ was not declared in this scope
             return (S[24]*(((P46*Clog)+(P45*S[6]))+P44));
                                  ^~~~
UserSimulation.cpp:105:34: note: suggested alternative: ‘log’
             return (S[24]*(((P46*Clog)+(P45*S[6]))+P44));
                                  ^~~~
                                  log
UserSimulation.cpp:231:21: error: ‘kdclog’ was not declared in this scope
             return (kdclog*Clog);
                     ^~~~~~
UserSimulation.cpp:231:21: note: suggested alternative: ‘__log’
             return (kdclog*Clog);
                     ^~~~~~
                     __log
UserSimulation.cpp:234:21: error: ‘ksclog’ was not declared in this scope
             return (ksclog*S[18]);
                     ^~~~~~
UserSimulation.cpp:234:21: note: suggested alternative: ‘__log’
             return (ksclog*S[18]);
                     ^~~~~~
                     __log
make: *** [UserSimulation.o] Error 1
jonrkarr commented 3 years ago

@bilalshaikh42 what is the last commit that worked? 5e26f8d459add3be5be7dddac05d4bcb9181c492?

The history of this repo is strange. Somehow your work in core.py at 5e26f8d459add3be5be7dddac05d4bcb9181c492 got lost by 739d730335d7afc26418e98524589ee13f90a4ad, but 739d730335d7afc26418e98524589ee13f90a4ad doesn't show any changes in that file. Apologies for accidentally overwriting your changes. Not sure how GitHub allowed me to do this without recording the changes.

bilalshaikh42 commented 3 years ago

Yup, that was it. I don't remember the exact reason, but I was a bit confused about how the changes got merged in when I pulled. I had assumed that I just didn't push, but now I see that they are on the network graph.

Anyway, that was the commit that was working. It was reading both archives without issues, and simulating them. The mapping that I had was less precise however, so the algorithms may not be supported. The parsing of the sedml must be a change outside the repo right? I dont see how any of the code here could make that change.

jonrkarr commented 3 years ago

I don't think its related to the version of gillespy2. I see the same error in the earlier version 1.5.3.

The error looks to be in C++ code that's generated for the simulation of the SBML model. It makes me think that gillespy2 is not handling some edge case of variable names. tellurium has similar issues.

jonrkarr commented 3 years ago

I doubt that BIOMD0000000297 ran earlier. GillesPy2 has two issues with this

jonrkarr commented 3 years ago

I distilled the problem with 297 down and submitted it as issue StochSS/GillesPy2#459.

jonrkarr commented 3 years ago

28 simulates fine. The issue is with modify_xml_model_for_simulation from biosimulations_utils. I still need to investigate this.

I do see one issue with tests/fixtures/BIOMD0000000028/ex2/BIOMD0000000028.sedml. See #12.

jonrkarr commented 3 years ago

The issue is due to no longer passing the default_namespace argument to modify_xml_model_for_simulation. I fixed modify_xml_model_for_simulation so this argument is no longer necessary. The change is in the align-api branch. I'm going to work on getting that done and merged with master.

jonrkarr commented 3 years ago

I've debugged the code and Dockerfile. Both seems to work, although the code still needs to be tested. The code currently requires the align-with-api branch of Biosimulations_utils. I'll work on merging that branch into master.