我刚刚安装了 PySB 并试图让它工作。我运行附带下载文档的示例,但它不起作用。
import pysb as psb
from pysb.integrate import odesolve as psb
from pylab import linspace, plot, xlabel, ylabel, show:
psb.Model()
# Declare the monomers
psb.Monomer('L', ['s'])
psb.Monomer('R', ['s'])
# Declare the parameters
psb.Parameter('L_0', 100)
psb.Parameter('R_0', 200)
psb.Parameter('kf', 1e-3)
psb.Parameter('kr', 1e-3)
# Declare the initial conditions
psb.Initial(L(s=None), L_0)
psb.Initial(R(s=None), R_0)
# Declare the binding rule
psb.Rule('L_binds_R', L(s=None) + R(s=None) <> L(s=1) % R(s=1), kf, kr)
# Observe the complex
psb.Observable('LR', L(s=1) % R(s=1))
if __name__ == '__main__':
print __doc__
# Simulate the model through 40 seconds
time = linspace(0, 40, 100)
print "Simulating..."
x = psb.odesolve(model, time)
# Plot the trajectory of LR
plot(time, x['LR'])
xlabel('Time (seconds)')
ylabel('Amount of LR')
show()
我遇到的第一个错误是psb.odesolve()
:
AttributeError: 'function' object has no attribute 'Model'
你能建议吗?谢谢
我尝试了 pysb.org 的代码,但出现错误:
Traceback (most recent call last):
File "C:\Users\Ruda\Desktop\t2.py", line 33, in <module>
x = odesolve(model, time)
File "C:\Python27\lib\site-packages\pysb\integrate.py", line 298, in odesolve
solver = Solver(model, tspan, integrator, **integrator_options)
File "C:\Python27\lib\site-packages\pysb\integrate.py", line 86, in __init__
pysb.bng.generate_equations(model)
File "C:\Python27\lib\site-packages\pysb\bng.py", line 261, in generate_equations
lines = iter(generate_network(model).split('\n'))
File "C:\Python27\lib\site-packages\pysb\bng.py", line 220, in generate_network
bng_file = open(bng_filename, 'w')
IOError: [Errno 22] invalid mode ('w') or filename: '<interactive>_5136_5952_temp.bngl'