nemo

An implementation of a description language for computational models of ion channels.

  1. nemo
  2. Usage
  3. Documentation
    1. Options
    2. Model description language
      1. Expressions
      2. State transition equations
      3. Ionic current definitions
      4. Hodgkin-Huxley ionic conductance extension
  4. Examples
  5. About this egg
    1. Author
    2. Version history
    3. License

Usage

nemo [options...] [input files ...]

Documentation

NEMO is a program that reads an ion channel description and generates corresponding model simulation code in GNU Octave, NEST C++ code, or the NMODL language used by the NEURON simulator.

Options

-i FORMAT
specify input format (nemo, xml, sxml, s-exp)
-p
generate individual files for each current component in the input file
--xml[=FILE]
write XML output to file (default: <model-name>.xml)
--sxml[=FILE]
write SXML output to file (default: <model-name>.sxml)
--nest
write NEST output to files <model-name>.cpp and <model-name>.h
--nmodl[=FILE]
write NMODL output to file (default: <model-name>.mod)
--nmodl-method=METHOD
specify NMODL integration method (cnexp, derivimplicit, cvode)
--nmodl-kinetic=[STATES]
use NMODL kinetic equations for the given reactions
--nmodl-depend=VARS
specify DEPEND variables for NMODL interpolation tables
--octave[=FILE]
write Octave output to file (default: <model-name>.m)
--matlab[=FILE]
write Matlab output to file (default: <model-name>.m)
--vclamp-octave[=FILE]
write Octave voltage clamp script to file (default: <model-name>_vclamp.m)
--vclamp-hoc[=FILE]
write HOC voltage clamp script to file (default: <model-name>.ses)
--debug
print additional debugging information
-t
use interpolation tables in generated code
-h, --help
print help

Model description language

The following constructs comprise the model description language:

MODEL ::= INPUT {ID} | {ID} [AS {LOCAL-ID}] [FROM {NAMESPACE}] ...
Declares one or several imported quantities. If the optional AS parameter is given, then the quantity is imported as {LOCAL-ID}. If the optional FROM parameter is given, then the quantity is imported from namespace {NAMESPACE}.
| OUTPUT {ID}
Declares that an existing quantity be exported.
| CONST {ID} = {EXPR}
Declares a constant quantity (its value will be computed at declaration time).
| FUN {ID} ( {ARG-ID} ... ) {EXPR}
Declares a function (a parameterized expression with no free variables).
| {ID} = {EXPR}
Declares an assigned quantity (an expression that can refer to other quantities in the system).
| REACTION {ID} {TRANSITIONS} {INITIAL-EXPR} {OPEN-ID}
Declares a reaction quantity. See below for the syntax of state transition equations. {INITIAL-EXPR} is an expression that computes the initial value. {OPEN-ID} is the name of the open state. It must be one of the states defined by the transition equations.
| COMPONENT ( TYPE {ID} ) ( NAME {ID} ) {ELEMENTS} )
Declares a system component (a quantity that can contain other quantities).

Expressions

Expressions in the model description language are defined as:

EXPR ::= {NUM}
A numeric constant.
| {ID}
A variable name.
| {ID} ( {EXPR} ... )
A function invocation.
| {EXPR} {OP} {EXPR}
Arithmetic operator invocation. The following operators are supported: + - / * > < <= >= ^
| LET ( {BINDINGS} ) {EXPR}
Local variables declaration. Each element in {BINDINGS} is of the form: ( {ID} {EXPR} )
| IF {CONDITION} THEN {EXPR} ELSE {EXPR}
Conditional expression. The expression after IF must be a comparison expression.

State transition equations

State transition equations in the model description language are defined as:

TRANSITION ::= -> {SRC-ID} {DEST-ID} {EXPR}
Declares that a transition occurs from state {SRC-ID} to state {DEST-ID} at rate computed by {EXPR}.
| <-> {SRC-ID} {DEST-ID} {EXPR-1} {EXPR-2}
Declares that a transition occurs from state {SRC-ID} to state {DEST-ID} and vice versa, at rates computed by {EXPR-1} and {EXPR-2}.

Ionic current definitions

Currently, the NMODL code generator recognizes and generates code for ion channel components that are defined as follows:

COMPONENT (TYPE ionic-current) (NAME {NAME}) ( COMPONENT ( TYPE gate ) ...
One or more gate definitions. Each component of type gate must export the reactions that characterize the gate dynamics.
COMPONENT ( TYPE pore ) ...
Conductance law definition. This component must export a constant maximal conductance, or an assigned quantity whose equation represents the conductance law used.
[ COMPONENT ( TYPE permeating-ion ) ... ]
[ COMPONENT ( TYPE accumulating-substance ) ... ]

Hodgkin-Huxley ionic conductance extension

The Hodgkin-Huxley ionic conductance extension is a shortcut that declares a reaction corresponding to the Hodgkin-Huxley formulation of ion channel dynamics.

HH-IONIC-GATE
( {ION-NAME} : Ion name: exported variables will be of the form {ion}_{id}.
M-POWER {INTEGER}
Power of state variable M.
H-POWER {INTEGER}
Power of state variable H. If zero, the initial value and equations for this variable can be omitted.
INITIAL-M {EXPR}
Expression that computes initial value for state variable M.
INITIAL-H {EXPR}
Expression that computes initial value for state variable H.
M-ALPHA {EXPR}
Closed state to open state rate expression for state variable M.
M-BETA {EXPR}
Open state to closed state rate expression for state variable M.
H-ALPHA {EXPR}
Closed state to open state rate expression for state variable H.
H-BETA {EXPR}
Open state to closed state rate expression for state variable H.
M-INF {EXPR}
Steady state expression for variable M.
M-TAU {EXPR}
Time constant expression for variable M.
H-INF {EXPR}
Steady state expression for variable H.
H-TAU {EXPR}
Time constant expression for variable H.

Examples

;; Cerebellar Purkinje Cell: resurgent Na current and high frequency
;; firing (Khaliq et al 2003).
nemo-model 
 Khaliq03
  input v 
  cai from ion-pools
  ica from ion-currents
  const ena = 60
  const ek = -88
  const ca0 = 1e-4
  component (type ionic-current) (name CaBK)
  ;: BK-type Purkinje calcium-activated potassium current
      component (type gate)
		 ;; constants
		 const ztau = 1.0
		 ;; rate functions
		 CaBK_v = (v + 5)
		 minf = (let ((vh -28.9)
			      (k  6.2))
		              (1.0 / (1.0 + exp (neg ((CaBK_v - vh) / k)))))
		 mtau = (let
		          ((y0   0.000505)
			   (vh1  -33.3)
			   (k1   -10.0)
			   (vh2  86.4)
			   (k2   10.1))
		          ((1e3) * (y0 + 1 / (exp ((CaBK_v + vh1) / k1) + 
		     	      	         exp ((CaBK_v + vh2) / k2)))))
		 hinf = (let 
                                 ((y0  0.085)
			   (vh  -32.0)
			   (k   5.8))
		          (y0 + (1 - y0) / (1 + exp ((CaBK_v - vh) / k))))
		 htau = (let
                                 ((y0   0.0019)
			   (vh1  -54.2)
			   (k1   -12.9)
			   (vh2   48.5)
			   (k2    5.2))
		          ((1e3) * (y0 + 1 / (exp ((CaBK_v + vh1) / k1) + exp ((CaBK_v + vh2) / k2)))))
		 zinf = (let ((k 0.001))
		          (1 / (1 + (k / cai))))
		 z_alpha = (zinf / ztau)
		 z_beta  = ((1 - zinf) / ztau)
		 reaction
		  z
                          transitions (<-> O C z_alpha z_beta)
                          conserve  (1 = (O + C))
                          initial   (let ((k 0.001)) (1 / (1 + k / ca0)))
                          open O
                          power 2
		 
		 output z
		 
		 hh-ionic-gate 
		  CaBK  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m  (minf)
		   initial-h  (hinf)
		   m-power    3
		   h-power    1
		   m-inf      (minf)
		   m-tau      (mtau)
		   h-inf      (hinf)
		   h-tau      (htau)
      
      component (type pore)
		 const  gbar_CaBK  = 0.007
		 output gbar_CaBK 
      
      component (type permeating-ion) (name k)
		 const e_CaBK = ek
		 output e_CaBK
      
      ;; end BK current
  component (type ionic-current) (name CaP)
      ;; HH P-type Calcium current
      
      component (type gate)
		 ;; rate functions
		 inf =  (let ((cv  -19)  (ck  5.5))
		          (1.0 / (1.0 + exp (neg ((v - cv) / ck)))))
		 tau = ((1e3) *
		        (if (v > -50) 
		         then (0.000191 + (0.00376 * exp (neg (((v + 41.9) / 27.8) ^ 2))))
		         else (0.00026367 + (0.1278 * exp (0.10327 * v)))))
		 hh-ionic-gate 
		  CaP  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m  (inf)
		   m-power    1
		   h-power    0
		   m-inf      inf
		   m-tau      tau
      component (type permeability)
		 fun ghk (v ci co)
		   (let ((F  9.6485e4)
		   	 (R  8.3145)
  			         (T  (22 + 273.19))  
                                (Z  2)
			 (E  ((1e-3) * v)))
                            (let ((k0 ((Z * (F * E)) / (R * T))))
		               (let ((k1 (exp (neg (k0))))
		             (k2 (((Z ^ 2) * (E * (F ^ 2))) / (R * T))))
                               (1e-6) * (if (abs (1 - k1) < 1e-6) 
                                         then (Z * F * (ci - (co * k1)) * (1 - k0))
                                         else (k2 * (ci - (co * k1)) / (1 - k1))))))
		 
		 const pcabar  = 0.00005
		 const cao     = 2.4
		 pca           = (pcabar * ghk (v cai cao))
		 output pca
      
      component (type permeating-ion) (name ca)
      
      
      ;; end CaP current
  component (type ionic-current) (name K1)
  ;; HH TEA-sensitive Purkinje potassium current
      component (type gate)
		 ;; constants
		 ;; rate functions
		 K1_v = (v + 11) ;; account for junction potential
		 minf = (let ((mivh -24)
			      (mik  15.4))
		              (1 / (1 + exp (neg (K1_v - mivh) / mik))))
		 mtau = (let ((mty0   0.00012851)
		              (mtvh1  100.7)
			      (mtk1   12.9)
			      (mtvh2  -56.0)
			      (mtk2   -23.1))
		             (1e3 * (if (K1_v < -35) 
			  	then (3.0 * (3.4225e-5 + 0.00498 * exp (neg (K1_v) / -28.29)))
				else (mty0 + 1.0 / (exp ((K1_v + mtvh1) / mtk1) + exp ((K1_v + mtvh2) / mtk2)))
				)))
		 hinf = (let ((hiy0  0.31)
			      (hiA   0.78)
			      (hivh  -5.802)
			      (hik   11.2))
		           (hiy0 + hiA / (1 + exp ((K1_v - hivh) / hik))))
		 htau =  (1e3 * (if ( K1_v > 0 ) 
				   then (0.0012 + 0.0023 * exp (-0.141 * K1_v))
				   else (1.2202e-05 + 0.012 * exp (neg (((K1_v - (-56.3)) / 49.6) ^ 2)))))
		 hh-ionic-gate 
		  K1  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m  (minf)
		   initial-h  (hinf)
		   m-power    3
		   h-power    1
		   m-inf      (minf)
		   m-tau      (mtau)
		   h-inf      (hinf)
		   h-tau      (htau)
      
      component (type pore)
		 const  gbar  = 0.004
		 output gbar
      
      component (type permeating-ion) (name k)
		 const e = ek
		 output e
      
      ;; end K1 current
  component (type ionic-current) (name K2)
  ;; HH Low TEA-sensitive Purkinje potassium current
      component (type gate)
		 ;; constants
		 ;; rate functions
		 K2_v = (v + 11) ;; account for junction potential
		 minf = (let ((mivh -24)
			      (mik  20.4))
		            (1 / (1 + exp ((neg (K2_v - mivh)) / mik))))
		 mtau = ((1e3) * (if (K2_v < -20) 
				  then (0.000688 + 1 / (exp ((K2_v + 64.2) / 6.5) + exp ((K2_v - 141.5) / -34.8)))
				  else (0.00016 + 0.0008 * exp (-0.0267 * K2_v))))
		 
		 hh-ionic-gate 
		  K2  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m  (minf)
		   m-power    4
		   h-power    0
		   m-inf      (minf)
		   m-tau      (mtau)
      
      component (type pore)
		 const  gbar  = 0.002
		 output gbar
      
      component (type permeating-ion) (name k)
		 const e = ek
		 output e
      
      ;; end K2 current
  component (type ionic-current) (name K3)
  ;; HH slow TEA-insensitive Purkinje potassium current
      component (type gate)
		 ;; constants
		 ;; rate functions
		 K3_v = (v + 11) ;; account for junction potential
		 minf = (let ((mivh -16.5)
			      (mik  18.4))
		            (1 / (1 + exp ((neg (K3_v - mivh)) / mik))))
		 mtau = ((1e3) * (0.000796 + 1.0 / (exp ((K3_v + 73.2) / 11.7) + exp ((K3_v - 306.7) / -74.2))))
		 
		 hh-ionic-gate 
		  K3  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m  (minf)
		   m-power    4
		   h-power    0
		   m-inf      (minf)
		   m-tau      (mtau)
      
      component (type pore)
		 const  gbar  =  0.004
		 output gbar
      
      component (type permeating-ion) (name k)
		 const e = ek
		 output e
      ;; end K3 current
  component (type ionic-current) (name Narsg) 
             component (type gate)
			
	const Con   = 0.005
	const Coff  = 0.5
	const Oon   = 0.75
	const Ooff  = 0.005
	const alfac = (pow ((Oon / Con) (1.0 / 4.0)))
	const btfac = (pow ((Ooff / Coff) (1.0 / 4.0)))
		 
	const alpha = 150
	const beta  = 3
	const gamma = 150
	const delta = 40
	const epsilon = 1.75
	const zeta = 0.03
	const x1 = 20
	const x2 = -20
	const x3 = 1e12
	const x4 = -1e12
	const x5 = 1e12
	const x6 = -25
 
	;; rate functions
		 
	f01 = (4.0 * alpha * exp (v / x1))
	f02 = (3.0 * alpha * exp (v / x1))
	f03 = (2.0 * alpha * exp (v / x1))
	f04 = (alpha * exp (v / x1))
	f0O = (gamma * exp (v / x3))
	fip = (epsilon * exp (v / x5))
	f11 = (4.0 * alpha * alfac * exp (v / x1))
	f12 = (3.0 * alpha * alfac * exp (v / x1))
	f13 = (2.0 * alpha * alfac * exp (v / x1))
	f14 = (alpha * alfac * exp (v / x1))
	f1n = (gamma * exp (v / x3))
		 
	fi1 = (Con)
	fi2 = (Con * alfac)
	fi3 = (Con * alfac * alfac)
	fi4 = (Con * alfac * alfac * alfac)
	fi5 = (Con * alfac * alfac * alfac * alfac)
	fin = (Oon)
	 
	b01 = (beta * exp (v / x2))
	b02 = (2.0 * beta * exp (v / x2))
	b03 = (3.0 * beta * exp (v / x2))
	b04 = (4.0 * beta * exp (v / x2))
	b0O = (delta * exp (v / x4))
	bip = (zeta * exp (v / x6))
		 
	b11 = (beta * btfac * exp (v / x2))
	b12 = (2.0 * beta * btfac * exp (v / x2))
	b13 = (3.0 * beta * btfac * exp (v / x2))
	b14 = (4.0 * beta * btfac * exp (v / x2))
	b1n = (delta * exp (v / x4))
		 
	bi1 = (Coff)
	bi2 = (Coff * btfac)
	bi3 = (Coff * btfac * btfac)
	bi4 = (Coff * btfac * btfac * btfac)
	bi5 = (Coff * btfac * btfac * btfac * btfac)
	bin = (Ooff)
 
	reaction
	   z
                    transitions
                     <-> C1 C2 f01 b01
                     <-> C2 C3 f02 b02
                     <-> C3 C4 f03 b03
                     <-> C4 C5 f04 b04
                     <-> C5 O  f0O b0O
                     <-> O  B  fip bip
                     <-> O  I6 fin bin
                     <-> C1 I1 fi1 bi1
                     <-> C2 I2 fi2 bi2
                     <-> C3 I3 fi3 bi3
                     <-> C4 I4 fi4 bi4
                     <-> C5 I5 fi5 bi5
                     <-> I1 I2 f11 b11
                     <-> I2 I3 f12 b12
                     <-> I3 I4 f13 b13
                     <-> I4 I5 f14 b14
                     <-> I5 I6 f1n b1n
                    conserve (1 = (I1 + I2 + I3 + I4 + I5 + I6 + C1 + C2 + C3 + C4 + C5 + O + B))
                    open O
                    power 1
	   
             output z
		
             component (type pore)
		   const  gbar  = 0.015
		   output gbar
	
             component (type permeating-ion) (name na)
		   const e = ena
		   output e
	
	;; end Narsg component
  component (type ionic-current) (name Ih)
      
      component (type gate)
		 
		 ;; rate functions
		 
		 inf = (1.0 / (1.0 + exp ((v + 90.1) / 9.9)))
		 
		 tau = ((1e3) * (0.19 + 0.72 * exp (neg (((v - (-81.5)) / 11.9) ^ 2))))
		 hh-ionic-gate 
		  Ih  ;; ion name: exported variables will be of the form {ion}_{id}
		   initial-m (inf)
		   m-power   1
		   h-power   0
		   m-inf     (inf)
		   m-tau     (tau)
      component (type pore)
		 const  gbar  = 0.0001
		 output gbar
      
      component (type permeating-ion) (name non-specific)
		const e = -30
		output e
      
      ;; end Ih current
  component (type ionic-current) (name Leak)
      
      component (type pore)
		 const  gbar  = 5e-5
		 output gbar
      
      component (type permeating-ion) (name non-specific)
		 const e = -60
		 output e
      
      ;; end leak current
  component (type decaying-pool) (name ca)
             const  F = 96485.0
             const  ca_depth   = 0.1
             const  ca_beta    = 1.0
             d (ca) =  ((neg (ica) / (2 * ca0 * F * ca_depth)) -
			  ((if (ca < ca0) then ca0 else ca) * ca_beta))
      	      	initial ca0
             cac = (if (ca < ca0) then ca0 else ca)
             output cac
  component (type membrane-capacitance)
          const C_m  = (1e-3)
          output C_m
  component (type voltage-clamp) (name K1)
      
          const vchold   = -71
          const vcbase   = -69
          const vcinc    = 10
          const vcsteps  = 8
          const vchdur   = 30
          const vcbdur   = 100
          output vchold vcbase vcinc vcsteps vchdur vcbdur

About this egg

Author

Ivan Raikov

Version history

9.0
transitioning to ersatz templates for code generation
7.0-8.x
support for the NEST simulator and CVODE solver, discrete events, synaptic components
6.11
bug fix in surface XML generation
6.9
added -p and --surface-xml option
6.4-6.8
bug fixes and enhancements to NMODL code generator
6.3
bug fixes in XML parsing
6.2
supported for deployment as a self-contained package
6.0-6.1
introduced indentation-based syntax
5.0-5.1
Added some flexibility in generating HH rate equations
4.4
Voltage clamp script generation
4.3
Renamed permeating-substance components to permeating-ion
4.2
Using installation-chicken-home to install example files
4.1
Documentation converted to wiki format
4.0
Introducing the gate-complex element
3.4
Documentation update
3.1-3.3
Fixes to the examples
3.0
Internal restructuring and new examples
2.5
Bug fixes in option handling and NMODL backend
2.4
Converted to using getopt-long
2.3
Added eggdoc as a dependency
2.2
Added stx-engine.scm to file manifest
2.1
Ported to Chicken 4
2.0
Introduced functors
1.15
Added nmodl-depend option
1.14
Added support for exponential Euler integration
1.13
Change in the integration method used for the AKP example
1.12
Added support for binary conductances and conservation equations
1.11
Bug fixes in the current equations part of NMODL code generator
1.10
AKP06 example is now installed in CHICKEN-HOME/nemo/examples
1.9
Documentation and example updates
1.8
Bug fixes related to kinetic equation processing
1.6
Added infix expression parser (nemo format)
1.0
Initial release

License

Copyright 2008-2014 Ivan Raikov

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

A full copy of the GPL license can be found at
<http://www.gnu.org/licenses/>.