Skip to content

Separated MechanismType file and code#176

Merged
nrnhines merged 1 commit into
neuronsimulator:nmodltextfrom
ramcdougal:nmodltext
Mar 31, 2019
Merged

Separated MechanismType file and code#176
nrnhines merged 1 commit into
neuronsimulator:nmodltextfrom
ramcdougal:nmodltext

Conversation

@ramcdougal

@ramcdougal ramcdougal commented Mar 31, 2019

Copy link
Copy Markdown
Member

Example:

from neuron import h
s = h.Section(name='s')
mt = h.MechanismType(0)
mt.select('hh')
print(mt.file()) # prints: hh.mod
print('\n'.join(mt.code().split('\n')[:4]))

"""
prints:

TITLE hh.mod squid sodium, potassium, and leak channels

COMMENT
This is the original Hodgkin-Huxley treatment for the set of sodium,
"""

>>> from neuron import h
>>> s = h.Section(name='s')
>>> mt = h.MechanismType(0)
>>> dir(mt)
['__bool__', '__call__', '__class__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', 'action', 'baseattr', 'code', 'count', 'file', 'has_net_event', 'hname', 'hocobjptr', 'internal_type', 'is_artificial', 'is_netcon_target', 'make', 'menu', 'pp_begin', 'pp_next', 'remove', 'same', 'select', 'selected']
>>> mt.select('hh')
0.0
>>> mt.file()
'hh.mod'
>>> print('\n'.join(mt.code().split('\n')[:4]))
TITLE hh.mod   squid sodium, potassium, and leak channels

COMMENT
 This is the original Hodgkin-Huxley treatment for the set of sodium,
@nrnhines nrnhines merged commit b895c5f into neuronsimulator:nmodltext Mar 31, 2019
nrnhines added a commit that referenced this pull request Apr 1, 2019
* Text of nmodl file available if a mechanism.

* MechanismType.code() returns the text of the mod file of the selected mechanism.
If there is no mod file for the implementation, returns "".
Note the first line of the code is the name of the modfile.

* Separated MechanismType file and code (#176)

>>> from neuron import h
>>> s = h.Section(name='s')
>>> mt = h.MechanismType(0)
>>> dir(mt)
['__bool__', '__call__', '__class__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', 'action', 'baseattr', 'code', 'count', 'file', 'has_net_event', 'hname', 'hocobjptr', 'internal_type', 'is_artificial', 'is_netcon_target', 'make', 'menu', 'pp_begin', 'pp_next', 'remove', 'same', 'select', 'selected']
>>> mt.select('hh')
0.0
>>> mt.file()
'hh.mod'
>>> print('\n'.join(mt.code().split('\n')[:4]))
TITLE hh.mod   squid sodium, potassium, and leak channels

COMMENT
 This is the original Hodgkin-Huxley treatment for the set of sodium,

* NMODL_TEXT nmodl_filename is the full path from realpath.

* NMODL_TEXT for INCLUDE "fname" comments the INCLUDE line with :::, adds
a ::: commented full path line if realpath available,
inserts the text of the INCLUDE file,
and closes the text with a ::: commented "end INCLUDE fname" line.
olupton pushed a commit that referenced this pull request Dec 7, 2022
* Allow json printer to embed NMODL in the JSON ast

Change-Id: Id3a38a67a104c85b1771638e31d6071e310483c7

* explicit about params in python test

Change-Id: I410cd04f8a0c264638c158333858b95bc949259a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants