-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
160 lines (146 loc) · 5.14 KB
/
main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python
import os
import sys
import simulator
from mpi4py import MPI
## description of current simulation
logmsg = "First testing of running multiple simulations using mpi+neuron\n\nUsing Human 5; (real) common seed; 10% hubs; silence hubs via 50% delta cells in the islet\n\nActivate delta cell with current I, I = 1E-3 * 2^(0,1,2,3....)"#add each time 3 hubs from 12 to 3*3*16+12 hubs; silence first 10 hubs."#; not varying gGJ and gamma; 5% hubs; silence n hubs in the islet\n\nn = 1, 2, 3...."
######
## Define model and setup
######
"""
model
gjmodel
morphology
species # 0: mouse; 1: human; 2: cubic lattice
pyseed
isImitateExp # if True, simulate whole islet but only analyse imaged cells
mode # 0: WT; 1: silent hubs; 2: silent non hubs
silenceStart # I clamp hubs to silence them, compare results from Johnston et al., 2016
silenceDur
silenceAmp #-100#mV #-0.005#uA # if mode=3, this will apply to delta cells and use +0.09#uA
pHubs # percentage/fraction of hubs in islet (if <1) else number of hubs in islet (i.e. >1)
methodToPickHubs # 0: random; 1: top GJ links; 2: bottom GJ links
whichHub # indix of imaged hub/non-hub to silence
ggap # model 1,2: ~1/6.*5.1*0.385*1e-4; model 3: ~0.12 [nS]
ggaphub
pggaphubstd # fraction of ggaphub as std
pggapstd # fraction of ggap as std
gjtau
dthres # spatial cutoff distance to def GJ connection
isletsize # islet size of interest (None for whole islet)
hetVar # it is % of mean's standard deviation
tstop # usually in [ms]
dt # usually in [ms]
downSampling # down sample the output -> output_timestep = dt*downSampling
tbatch # split simulation into batches; same unit as tstop
"""
try:
pyseed = int(sys.argv[2])
except Exception:
pyseed = 4
try:
modee = int(sys.argv[3])
except Exception:
modee = 3
try:
archi = int(sys.argv[4])
except Exception:
archi = 1
try:
gjm = int(sys.argv[5])
except Exception:
gjm = 1
try:
gjhub = float(sys.argv[6])
except Exception:
gjhub = 0.02
try:
gjnonhub = float(sys.argv[7])
except Exception:
gjnonhub = 0.02
try:
mor = int(sys.argv[8])
except Exception:
mor = 0
try:
isAct = int(sys.argv[9])
except Exception:
isAct = 1
try:
stepsizer = int(sys.argv[10])
except Exception:
stepsizer = 5
try:
stepstart = int(sys.argv[11])
except Exception:
stepstart = 0
modelParam = {'model' : 5, \
'gjmodel' : gjm, \
'morphology' : archi, \
'species' : mor, \
'pyseed' : pyseed, \
'isImitateExp' : 1, \
'mode' : modee, \
'silenceStart' : 300e3, \
'silenceDur' : 300e3, \
'silenceAmp' : 0.12, \
'pHubs' : 0.1, \
'methodToPickHubs' : 3 , \
'whichHub' : 0 , \
'ggap' : gjnonhub, \
'ggaphub' : gjhub, \
'pggaphubstd' : 0.7, \
'pggapstd' : 0.7, \
'gjtau' : 400.0, \
'p_connect': 1, \
'dthres' : 17.5, \
'isletsize' : 40 , \
'hetVar' : 0.2, \
'tstop' : 900e3, \
'dt' : 0.1 , \
'downSampling' : 1000, \
'tbatch' : 5e3}
# model key word arguments
# model 1 default: {'beta':{} , 'betahub':{'hubkatp':-5.8}}
# model 2 default: {'beta':{'gkatp':(6.5,0.0) , 'useDistribution':None} , 'betahub':{'hubgkatp':10}}
# model 3 default: {'beta':{'gkatp':(6.5,0.0) , 'useDistribution':None , 'applytime':5e3} , 'betahub':{'hubgkatp':10 , 'applytime':5e3}}
#modelParam['model_kwargs'] = {'beta':{'gkatp':(6.0,7.0) , 'useDistribution':'sq'} , 'betahub':{'hubgkatp':11.0}}
modelParam['model_kwargs'] = {'beta':{'glu':(6.0,7.0) , 'useDistribution':'sq' , 'applytime':50e3} , \
'betahub':{'hubglu':11.0 , 'applytime':50e3}}
# setup output directory
#outputdir = modelSetup.outputMake()
try:
outputdir = sys.argv[1]
if not os.path.isdir(outputdir):
print("Cannot set %s as output directory"%outputdir)
outputdir = '../output/sim_temp/'
except Exception:
print("Cannot set %s as output directory"%outputdir)
outputdir = '../output/sim_temp/'
print("Output directory set as %s"%outputdir)
modelParam['parentout'] = outputdir
def main(comm,modelParam,outputdir):
# Get rank and size
size = comm.Get_size()
rank = comm.Get_rank()
modelParam['subidx'] = rank
# setup what each sub simulation does
if isAct == 1 and False:
modelParam['pHubs'] = 10*rank
modelParam['silenceStart'] = 350e3
modelParam['tstop'] = 360e3
#tempParam = stepstart + rank*stepsizer #rank+1 #(12*rank+30)/2 #
# check they are doing right thing
tempParam = 10 + rank * 6
#print("RANK %d of SIZE %d is doing the right job..."%(rank,size))
simulator.main(modelParam, tempParam=tempParam)
if __name__ == "__main__":
# log down some short note of current simulations
# e.g. what is this simulation trying to test or what is changing.
with open(os.path.join(outputdir,'logmsg.log'), 'w') as f:
f.write("# SIMULATION DESCRIPTION\n\n")
f.write(logmsg)
# main simulation
main(MPI.COMM_WORLD,modelParam,outputdir)
##