Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NMODL Language #6776

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ disambiguations:
rules:
- language: XML
pattern: '<!ENTITY '
- language: NMODL
pattern: '\b(NEURON|INITIAL|UNITS)\b'
- language: Modula-2
pattern: '^\s*(?i:MODULE|END) [\w\.]+;'
- language: [Linux Kernel Module, AMPL]
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4466,6 +4466,14 @@ NL:
tm_scope: none
ace_mode: text
language_id: 241
NMODL:
type: programming
color: "#00356B"
extensions:
- ".mod"
tm_scope: none
ace_mode: text
language_id: 136456478
NPM Config:
type: data
color: "#cb3837"
Expand Down
40 changes: 40 additions & 0 deletions samples/NMODL/fornetcon.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
: Each NetCon maintains a count of external events.
: And time of last external event
: On each internal event all connecting NetCon get the internal event count.
: And time of last external event

NEURON {
POINT_PROCESS ForNetConTest
RANGE tbegin
}

UNITS {
}

PARAMETER {
tbegin = 0 (ms)
}

INITIAL {
net_send(tbegin, 1)
}

NET_RECEIVE(w, npre, tpre (ms), npost, tpost (ms)) {
INITIAL {
npre=0 tpre=-1 npost=0 tpost=-1
}

if (flag == 0) { : external (pre) event
npre = npre + 1
tpre = t
}

if (flag == 1) { : internal (post) event
FOR_NETCONS(w, fnpre, ftpre (ms), fnpost, ftpost (ms)) {
fnpost = fnpost + 1
ftpost = t
}
net_send(3, 1) : in 3 ms another 1 event
net_event(t)
}
}
62 changes: 62 additions & 0 deletions samples/NMODL/k3st.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
: Three state kinetic scheme for HH-like potassium channel
: Steady-state v-dependent state transitions have been fit
: Needs v-dependent time constants from tables created under hoc
NEURON {
SUFFIX k3st
USEION k READ ek WRITE ik
RANGE g, gbar
RANGE tau1_rec, tau2_rec
}
UNITS { (mV) = (millivolt) }
PARAMETER {
gbar = 33 (millimho/cm2)
d1 = -38 (mV)
k1 = 0.151 (/mV)
d2 = -25 (mV)
k2 = 0.044 (/mV)
}

ASSIGNED {
v (mV)
ek (mV)
g (millimho/cm2)
ik (milliamp/cm2)
kf1 (/ms)
kb1 (/ms)
kf2 (/ms)
kb2 (/ms)
tau1_rec
tau2_rec
}

STATE { c1 c2 o }

BREAKPOINT {
SOLVE kin METHOD sparse
g = gbar*o
ik = g*(v - ek)*(1e-3)
}

INITIAL { SOLVE kin STEADYSTATE sparse }

KINETIC kin {
rates(v)
~ c1 <-> c2 (kf1, kb1)
~ c2 <-> o (kf2, kb2)
CONSERVE c1 + c2 + o = 1
}

FUNCTION_TABLE tau1(v(mV)) (ms)
FUNCTION_TABLE tau2(v(mV)) (ms)

PROCEDURE rates(v(millivolt)) {
LOCAL K1, K2
K1 = exp(k2*(d2 - v) - k1*(d1 - v))
kf1 = K1/(tau1(v)*(1+K1))
kb1 = 1/(tau1(v)*(1+K1))
K2 = exp(-k2*(d2 - v))
kf2 = K2/(tau2(v)*(1+K2))
kb2 = 1/(tau2(v)*(1+K2))
tau1_rec = tau1(v)
tau2_rec = tau2(v)
}
1 change: 1 addition & 0 deletions test/test_heuristics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ def test_ml_by_heuristics
def test_mod_by_heuristics
assert_heuristics({
"Modula-2" => all_fixtures("Modula-2", "*.mod"),
"NMODL" => all_fixtures("NMODL", "*.mod"),
"XML" => all_fixtures("XML", "*.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("Linux Kernel Module", "*.mod"),
["Linux Kernel Module", "AMPL"] => all_fixtures("AMPL", "*.mod"),
Expand Down