In [1]:
from cellerator import cellerator as c
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
%matplotlib inline
In [2]:
model="Gold1.model"
In [3]:
c.PrintModel(model)
In [4]:
c.PrintODES(model)
In [5]:
t, v, s = c.Solve(model, step=.2)
In [6]:
someplot=c.PlotAll(t,v,s,loc="lower right",bg="white")
In [7]:
t[:10], v, s[:10]
Out[7]:
In [8]:
variables, pscan=c.Solve(model, scan=["Kc",0.1,0.4,0.01])
In [9]:
print variables
In [10]:
pscan = np.array(pscan)
kvals=pscan[:,0]; MVals=pscan[:,2]
plt.plot(kvals, MVals)
plt.xlabel("Kc"); plt.ylabel("Final Value of M")
Out[10]:
In [11]:
c.PlotParametric(t,v,s,1,2, color="Green", bg="pink")
Out[11]:
In [12]:
c.PlotParametric(t,v,s,"X","C",color="Purple", bg="white")
Out[12]:
In [20]:
c.PlotSize(9, 2) # change the plot size
someplots=c.PlotColumns(t,v,s, ncols=3, colors=["red","blue","green"])
In [21]:
mpl.rcParams["figure.figsize"]=15, 3 # another way of changing the plot size
someotherplots=c.PlotColumns(t,v,s, colors=["red","blue","green"])
In [22]:
r="""
[C <-> Nil, rates[kd, vi]]
[C |--> Nil, mod[X], Hill[vd, 1, Kd, 0,1 ]]
[M |--> Nil, mod[Nil], Hill[v2, 1, K2, 0, 1]]
[X |--> Nil, mod[Nil], Hill[v4, 1, K4, 0, 1]]
[Nil -> X, P]
[C |-> M, Hill["vm1*g(M)", 1, Kc, 0, 1]]
"""
In [23]:
ic="""C = 0.1;M = 0.2; X = 0.3"""
rates="""
vd = 0.1
vi = 0.023
v2 = 0.167; v4 = 0.1
vm1 = 0.5; vm3 = 0.2
kd = 0.00333
K1 = 0.1; K2 = 0.1; K3 = 0.1
K4 = 0.1
Kc = 0.3
Kd = 0.02"""
ass="""P = M * (1-X)/(K3+1-X)"""
func="""g(m) = (1-m)/(K1+1-m)"""
The function newModel creates a model from text strings rather than by reading a file
In [24]:
q = c.newModel(r, ic, rates, func, ass)
In [25]:
t,v,s=c.Solve(q,step=1, duration=200)
In [34]:
c.PlotSize(20,3)
newplot=c.PlotAll(t,v,s,bg="lightgreen")
In [35]:
newsbmlfile = c.GenerateSBML("Gold1.model", output="foo.xml")
print newsbmlfile
In [36]:
c.PrintSBML(newsbmlfile)
In [37]:
newmodelfile=c.ConvertSBML("foo.xml")
print newmodelfile
In [38]:
T,V,S=c.Solve(newmodelfile)
In [39]:
mpl.rcParams["figure.figsize"]=15, 3;
c.PlotAll(T,V,S)
Out[39]:
Generate a Cellerator Mathematica Notebook from a Model
The inverse translation is implemented in the Cellerator function TextArrow; from within Mathematica, to generate the arrow forms for a python model file use "TextArrow/@model"
In [40]:
nb = c.ToMathematica("Gold1.model")
print nb
The PrintMathematican function serves no operational function, it just gives a pretty-print look into the contents of the file.
In [41]:
c.PrintMathematica(nb)