本文整理汇总了Python中tellurium.loada函数的典型用法代码示例。如果您正苦于以下问题:Python loada函数的具体用法?Python loada怎么用?Python loada使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loada函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_truth_table
def test_truth_table(testmodel, input_ids, output_ids, truth_table,
ht=0.8, lt=0.2, delay=99, plot=False):
import tellurium as te
r = te.loada(testmodel)
sims = []
for row in truth_table:
message = ['When']
for i, input_val in enumerate(row[0]):
message.append(input_ids[i] + ':' + str(input_val))
r[input_ids[i]] = input_val
sim = r.simulate(0, delay + 1, delay + 1, ['time'] + input_ids + output_ids)
sims.append(sim)
for i, output_val in enumerate(row[1]):
offset = len(input_ids) + 1 # Time + length of inputs
ind = i + offset
full_message = ' '.join(message + [
'then',
output_ids[i] + ':' + str(output_val),
'; Found %s = %f' % (output_ids[i], sim[delay][ind])
])
print full_message
if output_val == 0:
assert sim[delay][ind] < lt, full_message
else:
assert sim[delay][ind] > ht, full_message
return r, sims
示例2: run
def run(self,func=None):
"""Allows the user to set the data from a File
This data is to be compared with the simulated data in the process of parameter estimation
Args:
func: An Optional Variable with default value (None) which by default run differential evolution
which is from scipy function. Users can provide reference to their defined function as argument.
Returns:
The Value of the parameter(s) which are estimated by the function provided.
.. sectionauthor:: Shaik Asifullah <[email protected]>
"""
self._parameter_names = self.bounds.keys()
self._parameter_bounds = self.bounds.values()
self._model_roadrunner = te.loada(self.model.model)
x_data = self.data[:,0]
y_data = self.data[:,1:]
arguments = (x_data,y_data)
if(func is not None):
result = differential_evolution(self._SSE, self._parameter_bounds, args=arguments)
return(result.x)
else:
result = func(self._SSE,self._parameter_bounds,args=arguments)
return(result.x)
示例3: test_plot
def test_plot(self):
""" Regression tests for plotting.
The following calls should work. """
r = te.loada("""
S1 -> S2; k1*S1;
k1 = 0.1; S1 = 40; S2 = 0.0;
""")
print(type(r))
s = r.simulate(0, 100, 21)
# no argument version
r.plot()
# plot with data
r.plot(s)
# plot with named data
r.plot(result=s)
# plot without legend
r.plot(s)
# plot without showing
r.plot(s, show=False)
r.plot(s, show=True) # no show
# plot with label, title, axis and legend
r.plot(s, xlabel="x", ylabel="y", xlim=[0, 10], ylim=[0, 10], grid=True)
# plot with additional plot settings from matplotlib
r.plot(s, alpha=0.1, color="blue", linestyle="-", marker="o")
示例4: test_setSeed
def test_setSeed(self):
r = te.loada("""
S1 -> S2; k1*S1;
k1 = 0.1; S1 = 40; S2 = 0.0;
""")
r.setSeed(123)
self.assertEqual(123, r.getSeed())
示例5: test_getSeed
def test_getSeed(self):
r = te.loada("""
S1 -> S2; k1*S1;
k1 = 0.1; S1 = 40; S2 = 0.0;
""")
seed = r.getSeed()
self.assertIsNotNone(seed)
示例6: spark_work
def spark_work(model_with_parameters):
import tellurium as te
if(antimony == "antimony"):
model_roadrunner = te.loada(model_with_parameters[0])
else:
model_roadrunner = te.loadSBMLModel(model_with_parameters[0])
parameter_scan_initilisation = te.ParameterScan(model_roadrunner,**model_with_parameters[1])
simulator = getattr(parameter_scan_initilisation, function_name)
return(simulator())
示例7: test_loada
def test_loada(self):
rr = te.loada('''
model example0
S1 -> S2; k1*S1
S1 = 10
S2 = 0
k1 = 0.1
end
''')
self.assertIsNotNone(rr.getModel())
示例8: test_draw
def test_draw(self):
r = te.loada("""
S1 -> S2; k1*S1;
k1 = 0.1; S1 = 40; S2 = 0.0;
""")
try:
import pygraphviz
r.draw()
except ImportError:
pass
示例9: fromAntimony
def fromAntimony(cls, antimonyStr, location, master=None):
""" Create SBMLAsset from antimonyStr
:param antimonyStr:
:type antimonyStr:
:param location:
:type location:
:return:
:rtype:
"""
r = te.loada(antimonyStr)
raw = r.getSBML()
return cls.fromRaw(raw=raw, location=location, filetype='sbml', master=master)
示例10: test_README_example
def test_README_example(self):
""" Tests the source example in the main README.md. """
import tellurium as te
rr = te.loada('''
model example0
S1 -> S2; k1*S1
S1 = 10
S2 = 0
k1 = 0.1
end
''')
result = rr.simulate(0, 40, 500)
te.plotArray(result)
示例11: fromAntimony
def fromAntimony(cls, antimonyStr, location, master=None):
""" Create SBMLAsset from antimonyStr
:param antimonyStr:
:type antimonyStr:
:param location:
:type location:
:return:
:rtype:
"""
warnings.warn('Use inline_omex instead.', DeprecationWarning)
r = te.loada(antimonyStr)
raw = r.getSBML()
return cls.fromRaw(raw=raw, location=location, filetype='sbml', master=master)
示例12: stochastic_work
def stochastic_work(model_object):
import tellurium as te
if model_type == "antimony":
model_roadrunner = te.loada(model_object.model)
else:
model_roadrunner = te.loadSBMLModel(model_object.model)
model_roadrunner.integrator = model_object.integrator
# seed the randint method with the current time
random.seed()
# it is now safe to use random.randint
model_roadrunner.setSeed(random.randint(1000, 99999))
model_roadrunner.integrator.variable_step_size = model_object.variable_step_size
model_roadrunner.reset()
simulated_data = model_roadrunner.simulate(model_object.from_time, model_object.to_time, model_object.step_points)
return([simulated_data.colnames,np.array(simulated_data)])
示例13: test_seed
def test_seed(self):
r = te.loada('''
S1 -> S2; k1*S1; k1 = 0.1; S1 = 40; S2 = 0;
''')
# Simulate from time zero to 40 time units
result = r.gillespie(0, 40, 11)
# Simulate on a grid with 10 points from start 0 to end time 40
result = r.gillespie(0, 40, 10)
# Simulate from time zero to 40 time units using the given selection list
# This means that the first column will be time and the second column species S1
result = r.gillespie(0, 40, 11, ['time', 'S1'])
# Simulate from time zero to 40 time units, on a grid with 20 points
# using the give selection list
result = r.gillespie(0, 40, 20, ['time', 'S1'])
示例14: test_plot2DParameterScan
def test_plot2DParameterScan(self):
"""Test plot2DParameterScan."""
import tellurium as te
from tellurium.analysis.parameterscan import plot2DParameterScan
r = te.loada("""
model test
J0: S1 -> S2; Vmax * (S1/(Km+S1))
S1 = 10; S2 = 0;
Vmax = 1; Km = 0.5;
end
""")
s = r.simulate(0, 50, 101)
# r.plot(s)
import numpy as np
plot2DParameterScan(r,
p1='Vmax', p1Range=np.linspace(1, 10, num=5),
p2='Vmax', p2Range=np.linspace(0.1, 1.0, num=5),
start=0, end=50, points=101)
示例15: test_complex_simulation
def test_complex_simulation(self):
""" Test complex simulation. """
model = '''
model feedback()
// Reactions:
J0: $X0 -> S1; (VM1 * (X0 - S1/Keq1))/(1 + X0 + S1 + S4^h);
J1: S1 -> S2; (10 * S1 - 2 * S2) / (1 + S1 + S2);
J2: S2 -> S3; (10 * S2 - 2 * S3) / (1 + S2 + S3);
J3: S3 -> S4; (10 * S3 - 2 * S4) / (1 + S3 + S4);
J4: S4 -> $X1; (V4 * S4) / (KS4 + S4);
// Species initializations:
S1 = 0; S2 = 0; S3 = 0;
S4 = 0; X0 = 10; X1 = 0;
// Variable initialization:
VM1 = 10; Keq1 = 10; h = 10; V4 = 2.5; KS4 = 0.5;
end
'''
r = te.loada(model)
result = r.simulate(0, 40, 101)
r.plot(result)