微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用CupSodaSimulator类os PySB时出错

如何解决使用CupSodaSimulator类os PySB时出错

我正在使用PySB库进行毕业设计。最初的目标是使用SBML模型的pysb/cupSODA类提供的CupSodaSimulator接口在GPU上模拟pysb.simulator.cupsoda。我写了一个简单的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,**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,append_stdout,**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'

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

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。