From efa4ec0d81f16b5413c5014042ef2008cbf2cbeb Mon Sep 17 00:00:00 2001 From: Matthias Wolf Date: Fri, 7 Jun 2024 06:29:50 -0400 Subject: [PATCH] Add NMODL Language (#6776) * Add NMODL Language This is the NEURON extension to MODL, a model description language used within the neuroscientific community. See also: https://www.neuron.yale.edu/neuron/static/py_doc/modelspec/programmatic/mechanisms/nmodl2.html * Add some heuristics * Try to add some tests --- lib/linguist/heuristics.yml | 2 ++ lib/linguist/languages.yml | 8 +++++ samples/NMODL/fornetcon.mod | 40 ++++++++++++++++++++++++ samples/NMODL/k3st.mod | 62 +++++++++++++++++++++++++++++++++++++ test/test_heuristics.rb | 1 + 5 files changed, 113 insertions(+) create mode 100644 samples/NMODL/fornetcon.mod create mode 100644 samples/NMODL/k3st.mod diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index 9a7a53fb7f..8a6fcea078 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -469,6 +469,8 @@ disambiguations: rules: - language: XML pattern: ' 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) +} diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index 177ed995c8..884a039d9b 100755 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -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"),