本文整理汇总了Python中pysb.integrate.Solver.run方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.run方法的具体用法?Python Solver.run怎么用?Python Solver.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysb.integrate.Solver
的用法示例。
在下文中一共展示了Solver.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_lipo_sites_builder
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_lipo_sites_builder():
"""lipo_sites_builder builds and runs without error."""
lsb = lipo_sites.Builder()
lsb.translocate_Bax()
t = np.linspace(0, 100)
sol = Solver(lsb.model, t)
sol.run()
示例2: plot_func_single
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def plot_func_single(self, x, data_ix, ax=None, alpha=1.0):
x = 10 ** x
s = Solver(self.builder.model, self.time)
# Set the parameters appropriately for the simulation:
# Iterate over the globally fit parameters
for g_ix, p in enumerate(self.builder.global_params):
p.value = x[g_ix]
# Iterate over the locally fit parameters
for l_ix, p in enumerate(self.builder.local_params):
ix_offset = len(self.builder.global_params) + \
data_ix * len(self.builder.local_params)
p.value = x[l_ix + ix_offset]
# Now fill in the initial condition parameters
for p_name, values in self.params.iteritems():
p = self.builder.model.parameters[p_name]
p.value = values[data_ix]
# Now run the simulation
s.run()
# Plot the observable
if ax is None:
ax = plt.gca()
if self.use_expr:
ax.plot(self.time, s.yexpr[self.obs_name], color='r',
alpha=alpha)
else:
ax.plot(self.time, s.yobs[self.obs_name], color='r',
alpha=alpha)
示例3: test_one_cpt_lipo_sites_comparison_tBid
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_one_cpt_lipo_sites_comparison_tBid():
"""Simulation of one_cpt and the lipo_sites model with tBid_0 numbers
of sites per liposome should give the same result."""
sites_per_liposome_list = [10., 1000.]
for test_ix, sites_per_liposome in enumerate(sites_per_liposome_list):
params_dict = {'tBid_0': 10., 'sites_per_liposome': sites_per_liposome}
ocb = one_cpt.Builder(params_dict=params_dict)
lsb = lipo_sites.Builder(params_dict=params_dict)
t = np.linspace(0, 100, 1000)
y_list = []
for builder in (ocb, lsb):
builder.translocate_tBid()
sol = Solver(builder.model, t)
sol.run()
y_list.append(sol.yobs['mtBid'])
if test_ix == 0:
ok_(not np.allclose(y_list[0], y_list[1], atol=1.5e-3),
'one_cpt and lipo_sites simulations should be different '
'under these conditions.')
elif test_ix == 1:
# The two arrays have a maximal absolute difference of 1.5e-3
ok_(np.allclose(y_list[0], y_list[1], atol=1.5e-3),
'one_cpt and lipo_sites simulations should be approximately '
'equal under these conditions.')
else:
raise Exception('Unexpected test index.')
示例4: run_query
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def run_query(model, query):
m = re.match('Is the amount of (.+) ([^ ]+) in time?', query)
target_str = m.groups()[0]
pattern_str = m.groups()[1]
ts = numpy.linspace(0, 100, 10)
solver = Solver(model, ts)
solver.run()
if target_str == 'A-B complex':
target = 'AB'
if target_str == 'A':
target = 'A'
for i, a in enumerate(solver.yobs[target]):
solver.yobs[target][i] = 1 if a > 50 else 0
if pattern_str == 'sustained':
fstr = sustained_formula(target)
elif pattern_str == 'transient':
fstr = transient_formula(target)
elif pattern_str == 'unchanged':
fstr = noact_formula(target)
print '\n\n'
print '-----------'
print query
print 'LTL formula: %s' % fstr
mc = ModelChecker(fstr, solver.yobs)
print solver.yobs[target]
print 'Result:', mc.truth
print '-----------'
示例5: test_integrate_with_expression
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_integrate_with_expression():
"""Ensure a model with Expressions simulates."""
Monomer('s1')
Monomer('s9')
Monomer('s16')
Monomer('s20')
# Parameters should be able to contain s(\d+) without error
Parameter('ks0',2e-5)
Parameter('ka20', 1e5)
Initial(s9(), Parameter('s9_0', 10000))
Observable('s1_obs', s1())
Observable('s9_obs', s9())
Observable('s16_obs', s16())
Observable('s20_obs', s20())
Expression('keff', (ks0*ka20)/(ka20+s9_obs))
Rule('R1', None >> s16(), ks0)
Rule('R2', None >> s20(), ks0)
Rule('R3', s16() + s20() >> s16() + s1(), keff)
time = np.linspace(0, 40)
solver = Solver(model, time)
solver.run()
assert solver.yexpr_view.shape == (len(time),
len(model.expressions_dynamic()))
assert solver.yobs_view.shape == (len(time), len(model.observables))
示例6: plot_liposome_titration_insertion_kinetics
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def plot_liposome_titration_insertion_kinetics(model):
"""Plot the insertion kinetics of Bax over a liposome titration."""
lipo_concs = np.logspace(-2, 2, 40)
t = np.linspace(0, 12000, 100)
fmax_list = []
k_list = []
for lipo_conc in lipo_concs:
model.parameters['Vesicles_0'].value = lipo_conc
# Get the SS mBax value
#b_trans.model.parameters['Vesicles_0'].value = lipo_conc
#s = Solver(b_trans.model, t)
#s.run()
#max_mBax = s.yobs['mBax'][-1]
# Get the iBax curve
s = Solver(model, t)
s.run()
iBax = s.yobs['iBax'] / model.parameters['Bax_0'].value
plt.plot(t, iBax, 'r')
# Fit to single exponential
fmax = fitting.Parameter(0.9)
k = fitting.Parameter(0.01)
def single_exp(t):
return (fmax() * (1 - np.exp(-k()*t)))
fitting.fit(single_exp, [fmax, k], iBax, t)
plt.plot(t, single_exp(t), 'b')
fmax_list.append(fmax())
k_list.append(k())
plt.title('Inserted Bax with liposome titration')
plt.xlabel('Time')
plt.ylabel('Fraction of inserted Bax')
plt.show()
# Make plots of k and fmax as a function of lipo concentration
fmax_list = np.array(fmax_list)
k_list = np.array(k_list)
# k
plt.figure()
plt.plot(lipo_concs, k_list, 'ro')
plt.xlabel('Liposomes (nM)')
plt.ylabel('$k$')
plt.title("$k$ vs. Liposome conc")
plt.ylim([0, 0.0020])
plt.show()
# Fmax
plt.figure()
plt.plot(lipo_concs, fmax_list, 'ro')
plt.xlabel('Liposomes (nM)')
plt.ylabel('$F_{max}$')
plt.title("$F_{max}$ vs. Liposome conc")
plt.show()
示例7: lipo_titration
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def lipo_titration(builder, ax):
t = np.linspace(0, tmax, 1e3)
sol = Solver(bd.model, t)
lipo_concs = np.logspace(-1, 1.5, 7)
for i, lipo_conc in enumerate(lipo_concs):
bd['Vesicles_0'].value = lipo_conc
sol.run()
ax.plot(t, sol.yexpr['NBD'], color=color_list[i])
示例8: test_earm_integration
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_earm_integration():
t = np.linspace(0, 1e4, 1000)
# Run with and without inline
Solver._use_inline = False
sol = Solver(earm_1_0.model, t, use_analytic_jacobian=True)
sol.run()
Solver._use_inline = True
sol = Solver(earm_1_0.model, t, use_analytic_jacobian=True)
sol.run()
示例9: check_runtime
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def check_runtime(model, tspan, iterations, use_inline, use_analytic_jacobian):
Solver._use_inline = use_inline
sol = Solver(model, tspan, use_analytic_jacobian=use_analytic_jacobian)
start_time = timeit.default_timer()
for i in range(iterations):
sol.run()
elapsed = timeit.default_timer() - start_time
print "use_inline=%s, use_analytic_jacobian=%s, %d iterations" % \
(use_inline, use_analytic_jacobian, iterations)
print "Time: %f sec\n" % elapsed
示例10: test_ic_expression_with_one_parameter
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_ic_expression_with_one_parameter():
Monomer('A')
Parameter('k1', 1)
Expression('e1', k1)
Rule('A_deg', A() >> None, k1)
Initial(A(), e1)
generate_equations(model)
t = np.linspace(0, 1000, 100)
sol = Solver(model, t, use_analytic_jacobian=True)
sol.run()
示例11: test_robertson_integration
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_robertson_integration():
t = np.linspace(0, 100)
# Run with and without inline
Solver._use_inline = False
sol = Solver(robertson.model, t, use_analytic_jacobian=True)
sol.run()
assert sol.y.shape[0] == t.shape[0]
# Run with and without inline
Solver._use_inline = True
sol = Solver(robertson.model, t, use_analytic_jacobian=True)
sol.run()
示例12: test_2conf_irrev_formula
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_2conf_irrev_formula():
params_dict = {'c1_scaling': 5}
bd = Builder(params_dict=params_dict)
bd.build_model_multiconf(2, 1., reversible=False, normalized_data=True)
t = np.linspace(0, 4000, 100)
sol = Solver(bd.model, t)
sol.run()
nbd_sol = sol.yexpr['NBD']
nbd_func = bd.obs_func(t)
ok_(np.allclose(nbd_sol, nbd_func),
'Integrated NBD does not match closed form NBD for 2conf model')
示例13: simulate_vemurafenib_treatment
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def simulate_vemurafenib_treatment(model, ts, y0):
# New initial conditions for simulation post event
y_init = y0
y_init[model.observables['Vem_free'].species[0]] = 2e5
# Continue model simulation with y_init as new initial condition
solver = Solver(model, ts)
solver.run(y0=y_init)
# Concatenate the two simulations
return solver.yobs, solver.y
示例14: test_earm_integration
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def test_earm_integration():
"""Ensure earm_1_0 model simulates."""
t = np.linspace(0, 1e3)
# Run with or without inline
sol = Solver(earm_1_0.model, t)
sol.run()
if Solver._use_inline:
# Also run without inline
Solver._use_inline = False
sol = Solver(earm_1_0.model, t)
sol.run()
Solver._use_inline = True
示例15: plot_bax_titration_insertion_kinetics
# 需要导入模块: from pysb.integrate import Solver [as 别名]
# 或者: from pysb.integrate.Solver import run [as 别名]
def plot_bax_titration_insertion_kinetics(model):
"""Plot the insertion kinetics of Bax over a Bax titration."""
bax_concs = np.logspace(-1, 3, 40)
t = np.linspace(0, 12000, 100)
fmax_list = []
k_list = []
for bax_conc in bax_concs:
model.parameters['Bax_0'].value = bax_conc
# Get the iBax curve
s = Solver(model, t)
s.run()
iBax = s.yobs['iBax'] / model.parameters['Bax_0'].value
plt.plot(t, iBax, 'r')
# Fit to single exponential
fmax = fitting.Parameter(0.9)
k = fitting.Parameter(0.01)
def single_exp(t):
return (fmax() * (1 - np.exp(-k()*t)))
fitting.fit(single_exp, [fmax, k], iBax, t)
plt.plot(t, single_exp(t), 'b')
fmax_list.append(fmax())
k_list.append(k())
plt.title('Inserted Bax with Bax titration')
plt.xlabel('Time')
plt.ylabel('Fraction of inserted Bax')
plt.show()
# Make plots of k and fmax as a function of lipo concentration
fmax_list = np.array(fmax_list)
k_list = np.array(k_list)
# k
plt.figure()
plt.plot(bax_concs, k_list, 'ro')
plt.xlabel('Bax (nM)')
plt.ylabel('$k$')
plt.title("$k$ vs. Bax conc")
plt.show()
# Fmax
plt.figure()
plt.plot(bax_concs, fmax_list, 'ro')
plt.xlabel('Bax (nM)')
plt.ylabel('$F_{max}$')
plt.title("$F_{max}$ vs. Bax conc")
plt.show()