borismarin / pynmodl Goto Github PK
View Code? Open in Web Editor NEWPython infrastructure for parsing and generating code from NMODL
License: MIT License
Python infrastructure for parsing and generating code from NMODL
License: MIT License
Currently, the LEMS backend will generate correct NeuroML for a limited number of mod
files, via building new ComponentType
s for each ionic mechanism found. Ideally, HH-like currents (kinetics, rate variables...) should be mapped to builtin NeuroML types, instead of creating new ones. That will involve clever symbolic manipulation (trying to cast dynamics/current laws into preexisting forms), but should be feasible for simple mechanisms.
modlunit
bundles a custom version of gnu units. units
doesn't seem to have been ported to python, so either try to wrap it (cffi, ctypes, cython, swig) or write a poor man's parser and use their custom unit lib.
The unparser can only handle a limited number of metamodel types (when updating the parser to cope with all ICG files, the grammar grew fast and I did not implement unparsing for the new nodes). This is a good starting point for understanding how this package works.
Use the auto-keyword parser option from textx instead of hoop-jumping our way.
textx uses a single global namespace to resolve references. nmodl
scoping rules need to be implemented via processors to get semantically correct resolutions.
Function calls in mod
get transpiled to LEMS DerivedVariable
s. The name of these variables contains the function's name and its arguments: '{}_{}'.format(fun.name, '_'.join(args))
- where args
is a list of strings already compiled to Lems. Obviously, that breaks whenever a function is called with expressions other than literals as arguments (eg. fun(1+1)
).
In order to ensure that generated LEMS fully captures the original nmodl description, it would be important to simulate cells with both mechanisms and compare the results. A natural (although convoluted) path would be re-generating nmodl for the transpiled LEMS (using org.neuroml.export), adding both mechanisms to a cell in NEURON (with zero max conductance), and run current clamp experiments. Code in https://github.com/borismarin/single-comp-channel-tester could easily be adapted for that.
Add 'validation' model processors to backends, so that we can fail soon if unsupported constructs (which can be parsed but not transpiled to the target at hand) are found instead of producing incomplete/invalid output; eg VERBATIM
for Lems.
Hello,
I am looking at existing tools for parsing NMODL and would like to know how much NMODL specification / grammar this tool cover.
If you have done tests (e.g. from ModelDB mod files collection), could you comment overall coverage?
Thank you!
Function calls in mod get transpiled to LEMS
DerivedVariables. The name of these variables contain the function's name and the arguments:
'{}{}'.format(fun.name, ''.join(args))- where
argsis a list of strings already compiled to Lems. Obviously, that breaks whenever a function is called with expressions other than literals as arguments (eg.
fun(1+1)`).
I've been trying to batch run the various channels we have at ICG.
Total number of broken channels : 683 (K-channels)
Total number of UNPARSE TextXSyntaxError : 216
Percent of the failed : 31.625183016105417
TextXSyntaxError: Expected 'TITLE' or 'UNITS' or 'NEURON' or 'PARAMETER' or 'ASSIGNED' or 'STATE' or 'INITIAL' or 'BREAKPOINT' or 'DERIVATIVE' or 'FUNCTION' or 'PROCEDURE' or 'UNITSON' or 'UNITSOFF' or EOF at position (1, 189) => 'p, ntau } *INDEPENDEN'
Fails at unp(dedent(cleaned_mod_txt))
following channel definitions from https://github.com/icgenealogy/icg-channels-K
'123815_Kaxon.mod', '125152_ka.mod', '114359_km.mod', '180789_kpkj.mod', '144553_kvz_nature.mod', '64229_kdr_v2.mod', '146026_kfast.mod', '135902_kdrpr.mod', '83344_km.mod', '39949_kir2.mod', '182797_IMminret.mod', '140828_kv.mod', '102288_IMmintau.mod', '182134_kaolmkop.mod', '144526_Kv.mod', '145672_Kv4_csi.mod', '20212_kv.mod', '141273_km.mod', '140462_IKt3.mod', '138321_km.mod', '123927_KM.mod', '3793_kd.mod', '144089_kd.mod', '135898_kv.mod', '147514_kv.mod', '180789_kpkjslow.mod', '54903_kv.mod', '135839_km.mod', '28316_IA.mod', '108459_km.mod', '98005_kv4_ch.mod', '136095_A.mod', '136095_kdr2.mod', '37819_km.mod', '123927_kdr.mod', '35358_kdr.mod', '136095_kmbg.mod', '182134_kdrolmkop.mod', '135787_km.mod', '182134_kdrbwb.mod', '64229_kmRT03.mod', '139421_kaolmkop.mod', '122329_kv4_gp.mod', '87473_ka.mod', '123927_ka.mod', '123927_kslow.mod', '20212_Mykca.mod', '122329_kv2_gp.mod', '149737_kslow.mod', '151126_IA.mod', '87473_fn.mod', '64229_kaRT03_v2.mod', '20212_km.mod', '135903_kdrbwb.mod', '151282_kdrbwb.mod', '155057_kdr.mod', '150538_kv.mod', '22203_kslow.mod', '123815_km.mod', '22203_kfast.mod', '7400_kdr.mod', '114394_Km.mod', '141273_kv.mod', '155735_kpkjslow_cn.mod', '64229_k2RT03.mod', '146030_Kdr_ChannelML.mod', '155735_kpkj.mod', '3342_kd_v2.mod', '143604_km.mod', '155057_iks.mod', '185332_kslow.mod', '124043_km.mod', '52034_kdr.mod', '144490_km_v2.mod', '26997_kdr.mod', '135902_kaolmkop.mod', '139421_kdrpr.mod', '64229_kdrRT03.mod', '48332_kpkj.mod', '64229_kdr.mod', '54903_km.mod', '8210_kd3h5.mod', '105385_kv4_gp.mod', '151126_Kdend.mod', '135903_kaolmkop.mod', '37819_kv.mod', '143604_kv.mod', '28316_Kdend.mod', '122329_kcnq_gp.mod', '83523_kfast.mod', '83344_kv.mod', '2488_km.mod', '124063_Bip_Ka.mod', '53451_km.mod', '87585_ichanWT2005.mod', '151126_Kaxon.mod', '181967_IA.mod', '116862_kmbg.mod', '64229_kmRT03_v2.mod', '139421_kapyrkop.mod', '140828_inwardrect.mod', '22203_km.mod', '116096_km.mod', '147514_km.mod', '123815_Kdend.mod', '28316_IAprox.mod', '185858_kdrbwb.mod', '52034_kdrp.mod', '105385_kv3_gp.mod', '116096_kv.mod', '105385_kv2_gp.mod', '141272_hh2F.mod', '113732_km.mod', '135902_kdrpyrkop.mod', '122329_kv3_gp.mod', '22203_kv.mod', '82849_iks.mod', '83523_kv.mod', '181967_Kdend.mod', '117207_kv.mod', '136715_kv.mod', '37819_kdr.mod', '182134_kdrpr.mod', '64229_kaRT03.mod', '123815_IA.mod', '155735_kpkj_cn.mod', '28316_Ksoma.mod', '123815_Ksoma.mod', '116862_kdr2.mod', '155735_kpkj2_cn.mod', '64195_kv.mod', '64229_kdrp_v2.mod', '144089_km.mod', '115356_kdr.mod', '116053_km.mod', '135902_kapyrkop.mod', '115356_ka.mod', '138321_kv.mod', '116053_kv.mod', '146026_kslow.mod', '141272_hh58CW.mod', '181967_Kaxon.mod', '153196_km.mod', '151126_Ksoma.mod', '3342_kd.mod', '113732_kdr.mod', '181967_km.mod', '64195_km.mod', '125152_kdr.mod', '181967_Ksoma.mod', '64229_kdrp.mod', '108458_Kv.mod', '124063_Bip_Kv.mod', '98005_kv2_ch.mod', '123897_kv.mod', '145672_Kv4_csiosi.mod', '141272_hh2CW.mod', '139421_kdrbwb.mod', '144490_km.mod', '144385_kv.mod', '114359_kv.mod', '37819_kleak.mod', '64229_k2RT03_v2.mod', '115356_km.mod', '136803_km.mod', '110560_potassium.mod', '180789_kpkj2.mod', '144089_kdrD.mod', '135902_kdrolmkop.mod', '150538_km.mod', '139421_kdrpyrkop.mod', '102288_IMminret.mod', '125152_kslow.mod', '135903_kdrolmkop.mod', '114394_kv.mod', '37819_kmbg.mod', '182797_IMmintau.mod', '125152_KM.mod', '117459_kleak.mod', '64229_kdrRT03_v2.mod', '37819_kl.mod', '185332_kfast.mod', '97756_KChannel.mod', '33975_kdr.mod', '168858_kvz_nature.mod', '153196_kv.mod', '143442_kv.mod', '135902_kdrbwb.mod', '53451_kv.mod', '185858_km.mod', '151825_kslow.mod', '135903_kdrpr.mod', '154732_km.mod', '39949_ksi.mod', '182134_kapyrkop.mod', '139421_kdrolmkop.mod', '87585_ichanR859C1.mod', '123897_km.mod', '105385_kcnq_gp.mod', '116862_kleak.mod', '28316_Kaxon.mod', '135903_kapyrkop.mod', '136026_kd.mod', '125857_kdr.mod', '7399_kdr.mod', '140828_km.mod', '146030_KA_ChannelML.mod', '144482_kv.mod', '144385_km.mod', '108459_kv.mod', '82849_kdr.mod', '135787_kv.mod', '124043_kdf.mod', '135903_kdrpyrkop.mod', '22203_kvfast.mod', '182134_kdrpyrkop.mod'
Fails at unp(dedent(cleaned_mod_txt))
following channel definitions from https://github.com/icgenealogy/icg-channels-K
Total number of broken channels : 683 (K-channels)
Total number of UNPARSE TextXSemanticError : 2
Percent of the failed : 0.29282576866764276
TextXSemanticError: Unknown object "float" of class "Variable"
'155157_AType_potassium.mod', '105385_kleak_gp.mod'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.