Skip to content

Commit

Permalink
Improved channel parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Apr 19, 2024
1 parent 6358caf commit b6a97c0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ report.*.txt
/NeuroML2/IClamp_AWCon.net.nml
/NeuroML2/LEMS_Sim_IClamp_AWCon.xml
/NicollettiEtAl2019.pdf
/NeuroML2/LEMS_Test_RMD_kir.xml
11 changes: 8 additions & 3 deletions NeuroML2/AWCon_kir.channel.nml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="AWCon_kir">
<notes>An ion channel from cell AWCon from Nicoletti et al. 2019</notes>
<ionChannelHH id="AWCon_kir" conductance="10pS">
<ionChannelHH id="AWCon_kir" species="k" conductance="10pS">
<notes>AWCon_kir channel from Nicoletti et al. 2019</notes>
<gateHHtauInf id="m" instances="1">
<timeCourse type="kir_m_tau"/>
<steadyState type="kir_m_inf"/>
</gateHHtauInf>
</ionChannelHH>
<ComponentType name="kir_m_inf" extends="baseVoltageDepVariable">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand All @@ -17,10 +18,13 @@
<Constant name="p5tmkir" dimension="none" value="11.1691"/>
<Constant name="p6tmkir" dimension="none" value="3.8329"/>
<Dynamics>
<DerivedVariable name="x" dimension="none" exposure="x" value="1/(1+exp((v-va_kir+30)/ka_kir))"/>
<DerivedVariable name="V" dimension="none" value="(v) / VOLT_SCALE"/>
<DerivedVariable name="x" dimension="none" exposure="x" value="1/(exp((V - va_kir + 30)/ka_kir) + 1)"/>
</Dynamics>
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="TIME_SCALE" dimension="time" value="1 s"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand All @@ -30,7 +34,8 @@
<Constant name="p5tmkir" dimension="none" value="11.1691"/>
<Constant name="p6tmkir" dimension="none" value="3.8329"/>
<Dynamics>
<DerivedVariable name="t" dimension="time" exposure="t" value="p1tmkir/(exp(-(v-p2tmkir)/p3tmkir)+exp((v-p4tmkir)/p5tmkir))+p6tmkir"/>
<DerivedVariable name="V" dimension="none" value="(v) / VOLT_SCALE"/>
<DerivedVariable name="t" dimension="time" exposure="t" value="p1tmkir/(exp((-V + p2tmkir)/p3tmkir) + exp((V - p4tmkir)/p5tmkir)) + p6tmkir"/>
</Dynamics>
</ComponentType>
</neuroml>
2 changes: 1 addition & 1 deletion NeuroML2/AWCon_leak.channel.nml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="AWCon_leak">
<notes>An ion channel from cell AWCon from Nicoletti et al. 2019</notes>
<ionChannelHH id="AWCon_leak" conductance="10pS">
<ionChannelHH id="AWCon_leak" species="non_specific" conductance="10pS">
<notes>AWCon_leak channel from Nicoletti et al. 2019</notes>
</ionChannelHH>
</neuroml>
36 changes: 32 additions & 4 deletions NeuroML2/GenerateNeuroML.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
colors = {"AWCon": "0 0 0.8", "RMD": "0 0.8 0", "GenericMuscleCell": "0.8 0 0"}


def create_channel_file(chan_id_in_cell, cell_id, xpp, gates={}, parameters={}):
def create_channel_file(chan_id_in_cell, cell_id, xpp, species, gates={}, parameters={}):
chan_id = "%s_%s" % (cell_id, chan_id_in_cell)
chan_doc = NeuroMLDocument(
id=chan_id,
Expand All @@ -28,6 +28,7 @@ def create_channel_file(chan_id_in_cell, cell_id, xpp, gates={}, parameters={}):
"IonChannelHH",
id=chan_id,
conductance="10pS",
species=species,
notes="%s channel from Nicoletti et al. 2019" % chan_id,
)

Expand All @@ -44,6 +45,14 @@ def create_channel_file(chan_id_in_cell, cell_id, xpp, gates={}, parameters={}):
chan_doc.add(ssct)
chan_doc.add(tcct)

vscale = component_factory("Constant", name='VOLT_SCALE', dimension="voltage", value="1 mV")
ssct.add(vscale)
tcct.add(vscale)
tscale = component_factory("Constant", name='TIME_SCALE', dimension="time", value="1 s")
tcct.add(tscale)



for p in parameters:
const = component_factory(
"Constant", name=p, dimension="none", value=str(xpp["parameters"][p])
Expand All @@ -54,12 +63,30 @@ def create_channel_file(chan_id_in_cell, cell_id, xpp, gates={}, parameters={}):

d = component_factory("Dynamics")
ssct.add(d)
dv = component_factory("DerivedVariable", name="x", exposure="x", dimension="none", value=xpp["derived_variables"][gates[g][1]])
dvv = component_factory("DerivedVariable", name="V", dimension="none", value="(v) / VOLT_SCALE")
d.add(dvv)

expr = xpp["derived_variables"][gates[g][1]]

import sympy
from sympy.parsing.sympy_parser import parse_expr
v,V = sympy.symbols('v V')

s_expr = parse_expr(expr, evaluate=False)
s_expr = s_expr.subs(v,V)

dv = component_factory("DerivedVariable", name="x", exposure="x", dimension="none", value=s_expr)
d.add(dv)

d = component_factory("Dynamics")
tcct.add(d)
dv = component_factory("DerivedVariable", name="t", exposure="t", dimension="time", value=xpp["derived_variables"][gates[g][2]])
d.add(dvv)

expr = xpp["derived_variables"][gates[g][2]]
s_expr = parse_expr(expr, evaluate=False)
s_expr = s_expr.subs(v,V)

dv = component_factory("DerivedVariable", name="t", exposure="t", dimension="time", value=s_expr)
d.add(dv)


Expand Down Expand Up @@ -159,7 +186,7 @@ def create_cells():
erev="%smV" % xpps[cell_id]["parameters"]["eleak"],
ion="non_specific",
ion_channel="%s_leak" % cell_id,
ion_chan_def_file=create_channel_file("leak", cell_id, xpps[cell_id]),
ion_chan_def_file=create_channel_file("leak", cell_id, xpps[cell_id], species='non_specific'),
)

# IRK channel
Expand All @@ -174,6 +201,7 @@ def create_cells():
"kir",
cell_id,
xpps[cell_id],
species='k',
gates={'m':[1,'minf_kir','tm_kir']},
parameters=[
"va_kir",
Expand Down
11 changes: 8 additions & 3 deletions NeuroML2/RMD_kir.channel.nml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="RMD_kir">
<notes>An ion channel from cell RMD from Nicoletti et al. 2019</notes>
<ionChannelHH id="RMD_kir" conductance="10pS">
<ionChannelHH id="RMD_kir" species="k" conductance="10pS">
<notes>RMD_kir channel from Nicoletti et al. 2019</notes>
<gateHHtauInf id="m" instances="1">
<timeCourse type="kir_m_tau"/>
<steadyState type="kir_m_inf"/>
</gateHHtauInf>
</ionChannelHH>
<ComponentType name="kir_m_inf" extends="baseVoltageDepVariable">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand All @@ -17,10 +18,13 @@
<Constant name="p5tmkir" dimension="none" value="11.1691"/>
<Constant name="p6tmkir" dimension="none" value="3.8329"/>
<Dynamics>
<DerivedVariable name="x" dimension="none" exposure="x" value="1/(1+exp((v-va_kir+30)/ka_kir))"/>
<DerivedVariable name="V" dimension="none" value="(v) / VOLT_SCALE"/>
<DerivedVariable name="x" dimension="none" exposure="x" value="1/(exp((V - va_kir + 30)/ka_kir) + 1)"/>
</Dynamics>
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<Constant name="VOLT_SCALE" dimension="voltage" value="1 mV"/>
<Constant name="TIME_SCALE" dimension="time" value="1 s"/>
<Constant name="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
Expand All @@ -30,7 +34,8 @@
<Constant name="p5tmkir" dimension="none" value="11.1691"/>
<Constant name="p6tmkir" dimension="none" value="3.8329"/>
<Dynamics>
<DerivedVariable name="t" dimension="time" exposure="t" value="p1tmkir/(exp(-(v-p2tmkir)/p3tmkir)+exp((v-p4tmkir)/p5tmkir))+p6tmkir"/>
<DerivedVariable name="V" dimension="none" value="(v) / VOLT_SCALE"/>
<DerivedVariable name="t" dimension="time" exposure="t" value="p1tmkir/(exp((-V + p2tmkir)/p3tmkir) + exp((V - p4tmkir)/p5tmkir)) + p6tmkir"/>
</Dynamics>
</ComponentType>
</neuroml>
2 changes: 1 addition & 1 deletion NeuroML2/RMD_leak.channel.nml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd" id="RMD_leak">
<notes>An ion channel from cell RMD from Nicoletti et al. 2019</notes>
<ionChannelHH id="RMD_leak" conductance="10pS">
<ionChannelHH id="RMD_leak" species="non_specific" conductance="10pS">
<notes>RMD_leak channel from Nicoletti et al. 2019</notes>
</ionChannelHH>
</neuroml>

0 comments on commit b6a97c0

Please sign in to comment.