In [1]:
%matplotlib inline
from __future__ import print_function, division
import tellurium as te
import roadrunner
from roadrunner import SelectionRecord
from matplotlib import pyplot as plt
In [2]:
# load model
import Cell
r = te.loads('results/{}_{}.xml'.format(Cell.mid, Cell.version))
print(r.getCurrentAntimony())
In [3]:
for dose in [0, 10, 20, 30]:
r.setValue('init(IVDOSE)', dose) # oral dose in [mg]
r.resetAll()
print(r.Ave)
s = r.simulate(0,24,1001)
plt.plot(s['time'], s['Ave'], color='black')
plt.xlabel('time')
plt.ylabel('amount [mg]')
plt.show()
resetToOrigin
resets initial values (and everything else) from the originally loaded model.
In [23]:
from __future__ import print_function, division
import tellurium as te
import roadrunner
r = te.loada("""
species S1, S2, S3
J1:S1 -> S2; k1*S1;
S1 = 1; k1 = 0.1;
// S2 via initial assignment
S2 = S1 + 10
// S3 via rule
S3 := S1/2
// p1 via initial assignment
p1 = 10
// p2 via rule
p2 := p1/2
""")
r.timeCourseSelections = r.getFloatingSpeciesIds() + r.getGlobalParameterIds()
def print_values(r, msg):
print('***', msg, '***')
print('<initial values>')
for sid in r.getFloatingSpeciesIds():
print("\t{sid} = {value}".format(sid=sid, value=r['init({})'.format(sid)]))
print('<values>')
for sid in r.getFloatingSpeciesIds() + r.getGlobalParameterIds():
print("\t{sid} = {value}".format(sid=sid, value=r['{}'.format(sid)]))
print('\n')
# plot the initial values of models
print_values(r, "Initial values")
# make a change to S1 and p1
r.S1 = 99
r.p1 = 99
print_values(r, "Change S1 and p1")
# -> S3 and p2 are updated also via rule
# reset() after change
r.reset()
print_values(r, "reset() after changes")
# -> S1 is reset to intial value (S3 via rule)
# -> parameters are not effected
r.resetToOrigin()
print_values(r, "resetToOrigin()")
# make a change to init(S1) and init(p1)
r['init(S1)'] = 99
r['init(p1)'] = 99
print_values(r, "Change init(S1) and init(p1)")
# -> the values of species are updated immediatly,
# -> ! the dependencies of the parameters are not !!!
# resetAll() after init change
r.resetAll()
print_values(r, "resetAll() to apply changes from changed initial conditions")
# -> the values of the parameters are updated in the model from the init(p1) values
r.resetToOrigin()
print_values(r, "resetToOrigin()")
# This is not possible (the init(p1) is set, but cannot be plotted)
print('init(p1) = ', r['init(p1)'])
In [24]:
r.getValue('init(p1)')
In [ ]: