-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscct.py
91 lines (48 loc) · 1.96 KB
/
scct.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
import sys
import yaml
import pystache
from subprocess import Popen, PIPE
def preprocess(conf):
conf["resistivity"] = 1.0/float(conf.get("passive", {'g':1})['g'])
return conf
def convert_channels_to_mod(lems_file):
from pyneuroml import pynml
pynml.run_jneuroml("", lems_file, "-neuron")
def command_line(cmd):
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
[out, err] = p.communicate()
print out
def compile_channel_files():
cmd = ["rm", "-rf", "x86_64"] # just to make sure: deletes existing x86_64
command_line(cmd)
cmd = ["nrnivmodl"]
command_line(cmd)
def main(nml, nrn_file):
try:
input_file = sys.argv[1]
except:
input_file = 'Saraga2003.yaml'
with open(input_file) as inpf:
conf = yaml.load(inpf)
conf = preprocess(conf)
if nml:
with open(".sccct_generated.cell.nml", "w") as outf:
outf.write(pystache.Renderer().render_path('nml.cell.mustache', conf))
with open(".sccct_generated.net.nml", "w") as outf:
outf.write(pystache.Renderer().render_path('nml.net.mustache', conf))
from neuroml.utils import validate_neuroml2
validate_neuroml2(".sccct_generated.cell.nml")
validate_neuroml2(".sccct_generated.net.nml")
lems_file = "LEMS_sccct_generated.xml"
with open(lems_file, "w") as outf:
outf.write(pystache.Renderer().render_path('lems.xml.mustache', conf))
convert_channels_to_mod(lems_file)
with open(nrn_file, "w") as outf:
outf.write(pystache.Renderer().render_path('nrn.mustache', conf))
compile_channel_files()
if __name__ == '__main__':
nml = True # set True to work with .channel.nml files instead of comparing only .mod files
nrn_file = "compare_modfiles.nrn.py"
main(nml, nrn_file)
cmd = ["nrngui", nrn_file]
command_line(cmd)