-
Notifications
You must be signed in to change notification settings - Fork 2
/
steps_skeletons_example.py
70 lines (51 loc) · 1.5 KB
/
steps_skeletons_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
NITER = 10
ENDTIME = 0.501
DT = 0.001
POINTS = int(ENDTIME/DT)
KCST = 10.0e6
ACOUNT = 100
BCOUNT = 200
CCOUNT = 0
COMPVOL = 1.0e-18
import steps.model as smodel
import steps.geom as swm
import steps.rng as srng
import steps.solver as ssolver
mdl = smodel.Model()
#################################
# SBML swap
A = smodel.Spec('A', mdl)
B = smodel.Spec('B', mdl)
C = smodel.Spec('C', mdl)
volsys = smodel.Volsys('vsys', mdl)
reac = smodel.Reac('reac', volsys, lhs=[A,B], rhs = [C], kcst = KCST)
mesh = swm.Geom()
# Create the cytosol compartment
comp = swm.Comp('comp', mesh, vol = COMPVOL)
comp.addVolsys('vsys')
############################
r = srng.create('mt19937', 256)
r.initialize(7233)
sim = ssolver.Wmdirect(mdl, mesh, r)
from pylab import *
import numpy
tpnt = numpy.arange(0.0, ENDTIME, DT)
res_m = numpy.zeros([NITER, POINTS, 3])
for i in xrange (0, NITER):
sim.reset()
sim.setCompCount('comp', 'A', ACOUNT)
sim.setCompCount('comp', 'B', BCOUNT)
sim.setCompCount('comp', 'C', CCOUNT)
for t in xrange(0,POINTS):
sim.run(tpnt[t])
res_m[i,t,0] = sim.getCompCount('comp', 'A')
res_m[i,t,1] = sim.getCompCount('comp', 'B')
res_m[i,t,2] = sim.getCompCount('comp', 'C')
mean_res = numpy.mean(res_m, 0)
plot(tpnt, mean_res[:,0], label = 'A')
plot(tpnt, mean_res[:,1], label = 'B')
plot(tpnt, mean_res[:,2], label = 'C')
xlabel('Time (sec)')
title('%d iterations' %NITER)
legend()
show()