I'm using the PySB
library for a graduation project. The initial goal is to simulate an SBML
on a GPU using the pysb/cupSODA
interface provided by the CupSodaSimulator
class of the pysb.simulator.cupsoda
model. I wrote a simple Python script
from pysb.importers.sbml import model_from_sbml
from pysb.simulator.cupsoda import CupSodaSimulator
filename="BIOMD0000000005_url.xml"
model = model_from_sbml(filename=filename)
simulator = CupSodaSimulator(model=model)
but I get the following error
AttributeError Traceback (most recent call last)
<ipython-input-5-b1ba6e155a18> in <module>
----> 1 simulator = CupSodaSimulator(model=model)
~/anaconda3/lib/python3.8/site-packages/pysb/simulator/cupsoda.py in __init__(self, model, tspan, initials, param_values, verbose, **kwargs)
197
198 # generate the equations for the model
--> 199 pysb.bng.generate_equations(self._model, self._cleanup, self.verbose)
200
201 # build integrator options list from our defaults and any kwargs
~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in generate_equations(model, cleanup, verbose, **kwargs)
729 if model.reactions:
730 return
--> 731 lines = iter(generate_network(model, cleanup=cleanup,
732 verbose=verbose, **kwargs).split('\n'))
733 _parse_netfile(model, lines)
~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in generate_network(model, cleanup, append_stdout, verbose, **kwargs)
670 bngfile.action('generate_network', overwrite=True,
671 verbose=bng_action_debug, **kwargs)
--> 672 bngfile.execute()
673
674 output = bngfile.read_netfile()
~/anaconda3/lib/python3.8/site-packages/pysb/bng.py in execute(self, reload_netfile, skip_file_actions)
441 output = ''
442 if self.model and not reload_netfile:
--> 443 output += self.generator.get_content()
444 if reload_netfile:
445 filename = reload_netfile if \
~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in get_content(self)
24 def get_content(self):
25 if self.__content == None:
---> 26 self.generate_content()
27 return self.__content
28
~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in generate_content(self)
29 def generate_content(self):
30 self.__content = "begin model\n"
---> 31 self.generate_parameters()
32 self.generate_compartments()
33 self.generate_molecule_types()
~/anaconda3/lib/python3.8/site-packages/pysb/generator/bng.py in generate_parameters(self)
40
41 def generate_parameters(self):
---> 42 exprs = self.model.expressions_constant()
43 if not self.model.parameters and not exprs:
44 return
~/anaconda3/lib/python3.8/site-packages/pysb/core.py in expressions_constant(self)
1974 def expressions_constant(self):
1975 """Return a ComponentSet of constant expressions."""
-> 1976 cset = ComponentSet(e for e in self.expressions
1977 if e.is_constant_expression())
1978 return cset
~/anaconda3/lib/python3.8/site-packages/pysb/core.py in __init__(self, iterable)
2253 self._index_map = {}
2254 if iterable is not None:
-> 2255 for value in iterable:
2256 self.add(value)
2257
~/anaconda3/lib/python3.8/site-packages/pysb/core.py in <genexpr>(.0)
1975 """Return a ComponentSet of constant expressions."""
1976 cset = ComponentSet(e for e in self.expressions
-> 1977 if e.is_constant_expression())
1978 return cset
1979
~/anaconda3/lib/python3.8/site-packages/pysb/core.py in is_constant_expression(self)
1642 (isinstance(a, Expression) and a.is_constant_expression()) or
1643 isinstance(a, sympy.Number)
-> 1644 for a in self.expr.atoms())
1645
1646 def get_value(self):
~/anaconda3/lib/python3.8/site-packages/sympy/core/basic.py in atoms(self, *types)
521 result = {node for node in nodes if isinstance(node, types)}
522 else:
--> 523 result = {node for node in nodes if not node.args}
524 return result
525
~/anaconda3/lib/python3.8/site-packages/sympy/core/basic.py in <setcomp>(.0)
521 result = {node for node in nodes if isinstance(node, types)}
522 else:
--> 523 result = {node for node in nodes if not node.args}
524 return result
525
AttributeError: 'str' object has no attribute 'args'
Is there someone who knows how to resolve this problem?
This is a Sympy versioning error where 1.6 broke compatibility (https://github.com/pysb/pysb/issues/503). There is already a fix in place, but hasn't been merged in yet. If you install a Sympy with version less than 1.6 (1.5 works), then this error should go away. Also, if you have more issues with PySB errors, you can always post to the issues on github (https://github.com/pysb/pysb/issues), or check out our gitter (https://gitter.im/pysb)