Skip to content

Commit

Permalink
Merge pull request #69 from openworm/experimental
Browse files Browse the repository at this point in the history
Improved Varshney & Witvliet
  • Loading branch information
pgleeson authored Feb 19, 2024
2 parents 5ee13fb + d294d2e commit 80648f4
Show file tree
Hide file tree
Showing 20 changed files with 4,593 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
engine: [ jNeuroML, jNeuroML_NEURON, jNeuroML_validate ] #, NON_OMV_TESTS ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install OMV
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/non_omv.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Non OMV tests
name: Non-OMV-tests

on:
push:
branches: [ master, development, test*, ow* ]
branches: [ master, development, experimental, ow* ]
pull_request:
branches: [ master, development, test*, ow* ]
branches: [ master, development, experimental, ow* ]

jobs:
build:
Expand All @@ -16,9 +16,9 @@ jobs:
python-version: [ 3.7, 3.8, 3.9, "3.10" ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
16 changes: 16 additions & 0 deletions c302/NeuroMLUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

from c302 import print_

PREFERRED_NEURON_NAMES = ['ADAL', 'ADAR', 'ADEL', 'ADER', 'ADFL', 'ADFR', 'ADLL', 'ADLR', 'AFDL', 'AFDR', 'AIAL', 'AIAR', 'AIBL', 'AIBR', 'AIML', 'AIMR', 'AINL', 'AINR', 'AIYL', 'AIYR', 'AIZL', 'AIZR', 'ALA', 'ALML', 'ALMR', 'ALNL', 'ALNR', 'AQR', 'AS1', 'AS10', 'AS11', 'AS2', 'AS3', 'AS4', 'AS5', 'AS6', 'AS7', 'AS8', 'AS9', 'ASEL', 'ASER', 'ASGL', 'ASGR', 'ASHL', 'ASHR', 'ASIL', 'ASIR', 'ASJL', 'ASJR', 'ASKL', 'ASKR', 'AUAL', 'AUAR', 'AVAL', 'AVAR', 'AVBL', 'AVBR', 'AVDL', 'AVDR', 'AVEL', 'AVER', 'AVFL', 'AVFR', 'AVG', 'AVHL', 'AVHR', 'AVJL', 'AVJR', 'AVKL', 'AVKR', 'AVL', 'AVM', 'AWAL', 'AWAR', 'AWBL', 'AWBR', 'AWCL', 'AWCR', 'BAGL', 'BAGR', 'BDUL', 'BDUR', 'CANL', 'CANR', 'CEPDL', 'CEPDR', 'CEPVL', 'CEPVR', 'DA1', 'DA2', 'DA3', 'DA4', 'DA5', 'DA6', 'DA7', 'DA8', 'DA9', 'DB1', 'DB2', 'DB3', 'DB4', 'DB5', 'DB6', 'DB7', 'DD1', 'DD2', 'DD3', 'DD4', 'DD5', 'DD6', 'DVA', 'DVB', 'DVC', 'FLPL', 'FLPR', 'HSNL', 'HSNR', 'I1L', 'I1R', 'I2L', 'I2R', 'I3', 'I4', 'I5', 'I6', 'IL1DL', 'IL1DR', 'IL1L', 'IL1R', 'IL1VL', 'IL1VR', 'IL2DL', 'IL2DR', 'IL2L', 'IL2R', 'IL2VL', 'IL2VR', 'LUAL', 'LUAR', 'M1', 'M2L', 'M2R', 'M3L', 'M3R', 'M4', 'M5', 'MCL', 'MCR', 'MI', 'NSML', 'NSMR', 'OLLL', 'OLLR', 'OLQDL', 'OLQDR', 'OLQVL', 'OLQVR', 'PDA', 'PDB', 'PDEL', 'PDER', 'PHAL', 'PHAR', 'PHBL', 'PHBR', 'PHCL', 'PHCR', 'PLML', 'PLMR', 'PLNL', 'PLNR', 'PQR', 'PVCL', 'PVCR', 'PVDL', 'PVDR', 'PVM', 'PVNL', 'PVNR', 'PVPL', 'PVPR', 'PVQL', 'PVQR', 'PVR', 'PVT', 'PVWL', 'PVWR', 'RIAL', 'RIAR', 'RIBL', 'RIBR', 'RICL', 'RICR', 'RID', 'RIFL', 'RIFR', 'RIGL', 'RIGR', 'RIH', 'RIML', 'RIMR', 'RIPL', 'RIPR', 'RIR', 'RIS', 'RIVL', 'RIVR', 'RMDDL', 'RMDDR', 'RMDL', 'RMDR', 'RMDVL', 'RMDVR', 'RMED', 'RMEL', 'RMER', 'RMEV', 'RMFL', 'RMFR', 'RMGL', 'RMGR', 'RMHL', 'RMHR', 'SAADL', 'SAADR', 'SAAVL', 'SAAVR', 'SABD', 'SABVL', 'SABVR', 'SDQL', 'SDQR', 'SIADL', 'SIADR', 'SIAVL', 'SIAVR', 'SIBDL', 'SIBDR', 'SIBVL', 'SIBVR', 'SMBDL', 'SMBDR', 'SMBVL', 'SMBVR', 'SMDDL', 'SMDDR', 'SMDVL', 'SMDVR', 'URADL', 'URADR', 'URAVL', 'URAVR', 'URBL', 'URBR', 'URXL', 'URXR', 'URYDL', 'URYDR', 'URYVL', 'URYVR', 'VA1', 'VA10', 'VA11', 'VA12', 'VA2', 'VA3', 'VA4', 'VA5', 'VA6', 'VA7', 'VA8', 'VA9', 'VB1', 'VB10', 'VB11', 'VB2', 'VB3', 'VB4', 'VB5', 'VB6', 'VB7', 'VB8', 'VB9', 'VC1', 'VC2', 'VC3', 'VC4', 'VC5', 'VC6', 'VD1', 'VD10', 'VD11', 'VD12', 'VD13', 'VD2', 'VD3', 'VD4', 'VD5', 'VD6', 'VD7', 'VD8', 'VD9']
PREFERRED_MUSCLE_NAMES = ['MANAL', 'MDL01', 'MDL02', 'MDL03', 'MDL04', 'MDL05', 'MDL06', 'MDL07', 'MDL08', 'MDL09', 'MDL10', 'MDL11', 'MDL12', 'MDL13', 'MDL14', 'MDL15', 'MDL16', 'MDL17', 'MDL18', 'MDL19', 'MDL20', 'MDL21', 'MDL22', 'MDL23', 'MDL24', 'MDR01', 'MDR02', 'MDR03', 'MDR04', 'MDR05', 'MDR06', 'MDR07', 'MDR08', 'MDR09', 'MDR10', 'MDR11', 'MDR12', 'MDR13', 'MDR14', 'MDR15', 'MDR16', 'MDR17', 'MDR18', 'MDR19', 'MDR20', 'MDR21', 'MDR22', 'MDR23', 'MDR24', 'MVL01', 'MVL02', 'MVL03', 'MVL04', 'MVL05', 'MVL06', 'MVL07', 'MVL08', 'MVL09', 'MVL10', 'MVL11', 'MVL12', 'MVL13', 'MVL14', 'MVL15', 'MVL16', 'MVL17', 'MVL18', 'MVL19', 'MVL20', 'MVL21', 'MVL22', 'MVL23', 'MVR01', 'MVR02', 'MVR03', 'MVR04', 'MVR05', 'MVR06', 'MVR07', 'MVR08', 'MVR09', 'MVR10', 'MVR11', 'MVR12', 'MVR13', 'MVR14', 'MVR15', 'MVR16', 'MVR17', 'MVR18', 'MVR19', 'MVR20', 'MVR21', 'MVR22', 'MVR23', 'MVR24', 'MVULVA']


class ConnectionInfo:

def __init__(self,
Expand Down Expand Up @@ -79,7 +83,12 @@ def analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_co
print_("Found %s cells: %s\n"%(len(cells),sorted(cells)))
#assert(len(cells) == 302)
#print_("Expected number of cells correct if include_nonconnected_cells=True")
not_in_preferred = []
for c in cells:
if not c in PREFERRED_NEURON_NAMES:
not_in_preferred.append(c)

print_("Found %s non-neuron(s): %s\n"%(len(not_in_preferred),sorted(not_in_preferred)))

print_("Found %s connections..."%(len(neuron_conns)))
for c in neuron_conns[:5]: print_(" %s"%c)
Expand All @@ -102,6 +111,13 @@ def analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_co
print_(" --- Muscles ---")
print_("")

print_("Found %s muscles: %s\n"%(len(muscles),sorted(muscles)))
not_in_preferred = []
for m in muscles:
if not m in PREFERRED_MUSCLE_NAMES:
not_in_preferred.append(m)

print_("Found %s unidentified muscles: %s\n"%(len(not_in_preferred),sorted(not_in_preferred)))

print_("Found %i neurons connected to muscles: %s\n"%(len(neurons2muscles), sorted(neurons2muscles)))
print_("Found %i muscles connected to neurons: %s\n"%(len(muscles), sorted(muscles)))
Expand Down
85 changes: 85 additions & 0 deletions c302/VarshneyDataReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections
from openpyxl import load_workbook

import os
from c302 import print_

spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"
spreadsheet_name = "NeuronConnect.xlsx" # has old name...
spreadsheet_name = "NeuronConnectFormatted.xlsx"

READER_DESCRIPTION = """Data extracted from %s for neuronal connectivity"""%spreadsheet_name

NMJ_ENDPOINT = 'NMJ'

def read_data(include_nonconnected_cells=False, neuron_connect=True):

if neuron_connect:
conns = []
cells = []
filename = "%s%s"%(spreadsheet_location,spreadsheet_name)
wb = load_workbook(filename)
sheet = wb.worksheets[0]
print_("Opened the Excel file: " + filename)

for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])

if not post==NMJ_ENDPOINT:
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns


def read_muscle_data():

conns = []
neurons = []
muscles = []

filename = "%s%s"%(spreadsheet_location,spreadsheet_name)
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file: "+ filename)

for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])

if post==NMJ_ENDPOINT:
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in neurons:
neurons.append(pre)
if not post in muscles:
muscles.append(post)


return neurons, muscles, conns



def main():

cells, neuron_conns = read_data(include_nonconnected_cells=True)
neurons2muscles, muscles, muscle_conns = read_muscle_data()

analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns)

if __name__ == '__main__':

main()
224 changes: 224 additions & 0 deletions c302/W_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
from c302.NeuroMLUtilities import ConnectionInfo
from c302.NeuroMLUtilities import analyse_connections

from openpyxl import load_workbook
import os
from c302 import print_


spreadsheet_location = os.path.dirname(os.path.abspath(__file__))+"/data/"

def get_old_muscle_name(name):
if name.startswith("BWM-VL"):
return "MVL%s" %name[6:]
elif name.startswith("BWM-VR"):
return "MVR%s" %name[6:]
elif name.startswith("BWM-DL"):
return "MDL%s" %name[6:]
elif name.startswith("BWM-DR"):
return "MDR%s" %name[6:]

class WitvlietDataReader1:

def read_data(include_nonconnected_cells=False, neuron_connect=False):

if neuron_connect:
conns = []
cells = []
filename = "%switvliet_2020_7.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]
print_("Opened the Excel file: " + filename)


for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse'


conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns

else:
conns = []
cells = []
filename = "%switvliet_2020_7.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file..: " + filename)

known_nonconnected_cells = ['CANL', 'CANR', 'VC6']


for row in sheet.iter_rows(min_row=2, values_only=True):
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse'


conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

if include_nonconnected_cells:
for c in known_nonconnected_cells: cells.append(c)

return cells, conns




def read_muscle_data():

conns = []
neurons = []
muscles = []

filename = "%switvliet_2020_7.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file: "+ filename)

for row in sheet.iter_rows(min_row=2, values_only=True):
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'EJ' in syntype else 'Chemical_Synapse'
if post.startswith("BWM-"):
post = get_old_muscle_name(post)
else:
continue

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in neurons:
neurons.append(pre)
if post not in muscles:
muscles.append(post)


return neurons, muscles, conns

def main1():

cells, neuron_conns = WitvlietDataReader1.read_data(include_nonconnected_cells=True)
neurons2muscles, muscles, muscle_conns = WitvlietDataReader1.read_muscle_data()

analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns)


class WitvlietDataReader2:
def read_data(include_nonconnected_cells=False, neuron_connect=False):

if neuron_connect:
conns = []
cells = []
filename = "%switvliet_2020_8.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]
print_("Opened the Excel file: " + filename)


for row in sheet.iter_rows(min_row=2, values_only=True): # Assuming data starts from the second row
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse'

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

return cells, conns

else:
conns = []
cells = []
filename = "%switvliet_2020_8.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file..: " + filename)

known_nonconnected_cells = ['CANL', 'CANR', 'VC6']


for row in sheet.iter_rows(min_row=2, values_only=True):
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse'


conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in cells:
cells.append(pre)
if post not in cells:
cells.append(post)

if include_nonconnected_cells:
for c in known_nonconnected_cells: cells.append(c)

return cells, conns


def read_muscle_data():

conns = []
neurons = []
muscles = []

filename = "%switvliet_2020_8.xlsx"%spreadsheet_location
wb = load_workbook(filename)
sheet = wb.worksheets[0]

print_("Opened Excel file: "+ filename)

for row in sheet.iter_rows(min_row=2, values_only=True):
pre = str(row[0])
post = str(row[1])
syntype = str(row[2])
num = int(row[3])
synclass = 'Generic_GJ' if 'electrical' in syntype else 'Chemical_Synapse'
if post.startswith("BWM-"):
post = get_old_muscle_name(post)
else:
continue

conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
if pre not in neurons:
neurons.append(pre)
if post not in muscles:
muscles.append(post)


return neurons, muscles, conns

def main2():

cells, neuron_conns = WitvlietDataReader2.read_data(include_nonconnected_cells=True)
neurons2muscles, muscles, muscle_conns = WitvlietDataReader2.read_muscle_data()

analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_conns)

if __name__ == '__main__':
main1()
main2()
2 changes: 1 addition & 1 deletion c302/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.12'
__version__ = '0.8.0'
Loading

0 comments on commit 80648f4

Please sign in to comment.