使用CupSodaSimulator类操作系统PySB时出错



我正在使用PySB库进行毕业设计。最初的目标是使用pysb.simulator.cupsoda模型的CupSodaSimulator类提供的pysb/cupSODA接口在GPU上模拟SBML。我写了一个简单的Python脚本

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)

但是我得到以下错误

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 modeln"
---> 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'

有人知道如何解决这个问题吗?

这是Sympy版本控制错误,1.6破坏了兼容性(https://github.com/pysb/pysb/issues/503)。已经有一个修复程序,但尚未合并。如果您安装的Sympy版本低于1.6(1.5工作(,那么这个错误应该会消失。此外,如果您有更多PySB错误问题,您可以随时在github上发布这些问题(https://github.com/pysb/pysb/issues),或查看我们的gitter(https://gitter.im/pysb)

最新更新