Skip to content

Commit

Permalink
Initial version gate parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Apr 19, 2024
1 parent d1034b0 commit 6358caf
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 3 deletions.
30 changes: 30 additions & 0 deletions NeuroML2/AWCon_kir.channel.nml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,35 @@
<notes>An ion channel from cell AWCon from Nicoletti et al. 2019</notes>
<ionChannelHH id="AWCon_kir" 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="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
<Constant name="p2tmkir" dimension="none" value="-17.8258"/>
<Constant name="p3tmkir" dimension="none" value="20.3154"/>
<Constant name="p4tmkir" dimension="none" value="-43.4414"/>
<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))"/>
</Dynamics>
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<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"/>
<Constant name="p2tmkir" dimension="none" value="-17.8258"/>
<Constant name="p3tmkir" dimension="none" value="20.3154"/>
<Constant name="p4tmkir" dimension="none" value="-43.4414"/>
<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"/>
</Dynamics>
</ComponentType>
</neuroml>
58 changes: 55 additions & 3 deletions NeuroML2/GenerateNeuroML.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from pyneuroml import pynml
from pyneuroml.xppaut import parse_script

from neuroml import GateHHRates


xpps = {"RMD": parse_script("../RMD.ode"), "AWCon": parse_script("../AWC.ode")}

Expand All @@ -13,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):
def create_channel_file(chan_id_in_cell, cell_id, xpp, gates={}, parameters={}):
chan_id = "%s_%s" % (cell_id, chan_id_in_cell)
chan_doc = NeuroMLDocument(
id=chan_id,
Expand All @@ -29,8 +31,42 @@ def create_channel_file(chan_id_in_cell, cell_id, xpp):
notes="%s channel from Nicoletti et al. 2019" % chan_id,
)

for g in gates:

ss = component_factory("HHVariable", type="%s_%s_inf"%(chan_id_in_cell,g))
tc = component_factory("HHTime", type="%s_%s_tau"%(chan_id_in_cell,g))

gc = component_factory("GateHHTauInf", id=g, instances=gates[g][0], steady_state=ss, time_course=tc, validate=True)
channel.add(gc)

ssct = component_factory("ComponentType", name=ss.type, extends="baseVoltageDepVariable")
tcct = component_factory("ComponentType", name=tc.type, extends="baseVoltageDepTime")
chan_doc.add(ssct)
chan_doc.add(tcct)

for p in parameters:
const = component_factory(
"Constant", name=p, dimension="none", value=str(xpp["parameters"][p])
)
ssct.add(const)
tcct.add(const)


d = component_factory("Dynamics")
ssct.add(d)
dv = component_factory("DerivedVariable", name="x", exposure="x", dimension="none", value=xpp["derived_variables"][gates[g][1]])
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(dv)




chan_doc.add(channel)
chan_doc.validate(recursive=True)
#chan_doc.validate(recursive=True)

pynml.write_neuroml2_file(nml2_doc=chan_doc, nml2_file_name=chan_fn, validate=True)

Expand Down Expand Up @@ -134,7 +170,23 @@ def create_cells():
erev="%smV" % xpps[cell_id]["parameters"]["ek"],
ion="k",
ion_channel="%s_kir" % cell_id,
ion_chan_def_file=create_channel_file("kir", cell_id, xpps[cell_id]),
ion_chan_def_file=create_channel_file(
"kir",
cell_id,
xpps[cell_id],
gates={'m':[1,'minf_kir','tm_kir']},
parameters=[
"va_kir",
"ka_kir",
"p1tmkir",
"p2tmkir",
"p3tmkir",
"p4tmkir",
"p5tmkir",
"p6tmkir",
],

),
)

cell.set_specific_capacitance("%s uF_per_cm2" % c)
Expand Down
30 changes: 30 additions & 0 deletions NeuroML2/RMD_kir.channel.nml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,35 @@
<notes>An ion channel from cell RMD from Nicoletti et al. 2019</notes>
<ionChannelHH id="RMD_kir" 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="va_kir" dimension="none" value="-52.0"/>
<Constant name="ka_kir" dimension="none" value="13.0"/>
<Constant name="p1tmkir" dimension="none" value="17.0752"/>
<Constant name="p2tmkir" dimension="none" value="-17.8258"/>
<Constant name="p3tmkir" dimension="none" value="20.3154"/>
<Constant name="p4tmkir" dimension="none" value="-43.4414"/>
<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))"/>
</Dynamics>
</ComponentType>
<ComponentType name="kir_m_tau" extends="baseVoltageDepTime">
<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"/>
<Constant name="p2tmkir" dimension="none" value="-17.8258"/>
<Constant name="p3tmkir" dimension="none" value="20.3154"/>
<Constant name="p4tmkir" dimension="none" value="-43.4414"/>
<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"/>
</Dynamics>
</ComponentType>
</neuroml>

0 comments on commit 6358caf

Please sign in to comment.