Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use latest master for ow-0.9.5 release #83

Merged
merged 29 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
07871e6
Merge pull request #74 from openworm/master
pgleeson May 2, 2024
1b076b7
Merge branch 'experimental' of github.com:openworm/c302 into experime…
pgleeson May 20, 2024
cbc0f30
Installation guide
KaanS139 Jun 24, 2024
cacdd58
Update README.md
KaanS139 Jun 24, 2024
ea8607a
Regenerated nml files with latest libraries
pgleeson Jun 24, 2024
63dcc4f
Windows additions
KaanS139 Jun 25, 2024
ba0218a
Delete Untitled.ipynb
KaanS139 Jun 25, 2024
4f3587a
Merge pull request #78 from KaanS139/development
pgleeson Jun 25, 2024
4e12f47
Readme tweaks
pgleeson Jun 25, 2024
a058860
Merge pull request #77 from openworm/development
pgleeson Jun 25, 2024
d6788cf
Merge branch 'master' into experimental
pgleeson Jun 25, 2024
7312885
Initial test of removing owmeta...
pgleeson Jun 26, 2024
917f3cc
Include install in test...
pgleeson Jun 26, 2024
8684c05
Don't test owmeta on py3.11
pgleeson Jun 26, 2024
c062d3c
Fix utils script for no owmeta
pgleeson Aug 28, 2024
3e31bbf
Minor tweaks
pgleeson Aug 28, 2024
f44c1ab
Updated select figs on linux
pgleeson Aug 28, 2024
6dd6ab8
Merge branch 'experimental' of github.com:openworm/c302 into experime…
pgleeson Aug 28, 2024
bd28eaf
Caching owmeta info on cells
pgleeson Aug 29, 2024
d56dcf1
Merge branch 'experimental' of github.com:openworm/c302 into experime…
pgleeson Aug 29, 2024
3a233d5
Tweak cached owmeta info
pgleeson Aug 29, 2024
60e3244
Using cached info if owmeta not found
pgleeson Aug 29, 2024
b44bea8
Fix finding owmeta cached data
pgleeson Aug 29, 2024
aaeed7e
Merge pull request #79 from openworm/experimental
pgleeson Aug 29, 2024
81b229a
Merge pull request #80 from openworm/development
pgleeson Aug 29, 2024
ca0166c
Add action for push to pypi on new release
pgleeson Aug 29, 2024
bb8d0fb
Merge pull request #81 from openworm/development
pgleeson Aug 29, 2024
44feb88
To v0.8.1; apply black formatting to python
pgleeson Aug 29, 2024
9555bc9
Merge pull request #82 from openworm/development
pgleeson Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .github/workflows/non_omv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, macos-12, macos-latest ]
python-version: [ 3.8, 3.9, "3.10" ]
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
exclude:
- runs-on: macos-latest
python-version: "3.8"
Expand Down Expand Up @@ -43,7 +43,9 @@ jobs:
pip list

- name: Test OpenWormReader with owmeta
if: ${{ matrix.python-version != '3.11' }}
run: |
pip install owmeta>=0.12.3
owm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json'
python -m c302.OpenWormReader

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ arm64
/examples/test/images/c302_C1_Pharyngeal.net.nml
/examples/test/images/c302_C1_Social.net.nml
/examples/test/images/c302_C1_Syns.net.nml
*ken.sh
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ c302 is a framework for generating network models in NeuroML 2 based on *C. eleg

![c302 structure](https://raw.githubusercontent.com/openworm/CElegansNeuroML/master/CElegans/pythonScripts/c302/images/c302.png)

It uses information on the synaptic connectivity of the network (from [here](https://github.com/openworm/c302/blob/master/c302/data/CElegansNeuronTables.xls)) and uses [libNeuroML](https://github.com/NeuralEnsemble/libNeuroML) to generate a network in valid NeuroML, which can be run in [jNeuroML](https://github.com/NeuroML/jNeuroML) or [pyNeuroML](https://github.com/NeuroML/pyNeuroML).
It uses information on the synaptic connectivity of the network (from [here](https://github.com/openworm/c302/blob/master/c302/data)) and uses [libNeuroML](https://github.com/NeuralEnsemble/libNeuroML) to generate a network in valid NeuroML, which can be run in [jNeuroML](https://github.com/NeuroML/jNeuroML) or [pyNeuroML](https://github.com/NeuroML/pyNeuroML).

**The c302 paper has recently been published!**
**The c302 paper is out!**

*c302: a multiscale framework for modelling the nervous system of Caenorhabditis elegans* Padraig Gleeson, David Lung, Radu Grosu, Ramin Hasani, Stephen D. Larson, [Phil. Trans. R. Soc. B 2018 373 20170379](http://rstb.royalsocietypublishing.org/content/373/1758/20170379); DOI: 10.1098/rstb.2017.0379.


### To install & test

The full set of dependencies for c302 can be installed with the following (see also the [Travis-CI script](https://github.com/openworm/c302/blob/master/.travis.yml)):
The full set of dependencies for c302 can be installed with the following (see also the [ci.yml](https://github.com/openworm/c302/blob/master/.github/workflows/ci.yml) and [non_omv.yml](https://github.com/openworm/c302/blob/master/.github/workflows/non_omv.yml) workflow files):

git clone https://github.com/openworm/c302.git
cd c302
pip install .
owm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json'
```console
git clone https://github.com/openworm/c302.git
cd c302
pip install .

# The following can only be run on Mac and Linux. Note: c302 can be run without ownmeta fully installed
owm bundle remote --user add ow 'https://raw.githubusercontent.com/openworm/owmeta-bundles/master/index.json'
```

This will install c302 as well as [pyNeuroML](https://github.com/NeuroML/pyNeuroML) and [owmeta](https://github.com/openworm/owmeta).

To run the test.sh script, the Neuron simulator is also required, and should be installed as described [here](https://www.neuron.yale.edu/neuron/download).
For Windows users a virtual environment must be generated with Python 3.10 as any newer versions do not currently support owmeta.

To run the test.sh script, the Neuron simulator is also required, and should be installed as described [here](https://www.neuron.yale.edu/neuron/download) (On Mac and Linux it can be installed with `pip install neuron`).

For Linux users, additional dependencies (OpenJDK 19 and Graphviz) are required to run the Usage Examples:
For Linux users, additional dependencies (OpenJDK 19 and Graphviz) are required to run the usage examples:

sudo apt-get install openjdk-19-jdk graphviz

Expand Down Expand Up @@ -81,7 +87,7 @@ Screenshots of a simulation with pyNeuroML of c302_B_Pharyngeal are shown below

#### 1b) Run standard examples with Neuron

The models can also be run using the Neuron simulator. This should be installed as outlined [here](https://www.neuron.yale.edu/neuron/download).
The models can also be run using the Neuron simulator. This should be installed as outlined [here](https://www.neuron.yale.edu/neuron/download). Note: running c302 with Neuron is not currently supported on Windows.

cd examples
pynml LEMS_c302_A_IClamp.xml -neuron # Generate the Neuron files (Python/hoc/mod)
Expand Down
101 changes: 78 additions & 23 deletions c302/CompareMain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
__author__ = 'Ari'
__author__ = "Ari"

from operator import itemgetter
import xlrd
import os

def comparitor(fName1, fName2):

def comparitor(fName1, fName2):
path1 = fName1
path2 = fName2
dir = os.path.dirname(__file__)
Expand All @@ -28,17 +28,54 @@ def comparitor(fName1, fName2):
# Print results. Give number of pairs that are matched, remained from unmatched files, and associated pairs.
print("Number of matching pairs: " + str(len(matches[indexName2[0]])))
for p in range(len(matches[indexName2[0]])):
print(str(matches[indexName2[0]][p])+" -> "+str(matches[indexName2[1]][p])+" ("+str(matches[indexName2[2]][p])+", "+str(matches[indexName2[3]][p])+")")
print("\nNumber of pairs unmatched in " + fName1 + " is: " + str(len(col1[indexName2[0]])))
print(
str(matches[indexName2[0]][p])
+ " -> "
+ str(matches[indexName2[1]][p])
+ " ("
+ str(matches[indexName2[2]][p])
+ ", "
+ str(matches[indexName2[3]][p])
+ ")"
)
print(
"\nNumber of pairs unmatched in "
+ fName1
+ " is: "
+ str(len(col1[indexName2[0]]))
)
for p in range(len(col1[indexName2[0]])):
print(str(col1[indexName2[0]][p])+" -> "+str(col1[indexName2[1]][p])+" ("+str(col1[indexName2[2]][p])+", "+str(col1[indexName2[3]][p])+")")
print("\nNumber of pairs unmatched in " + fName2 + " is: " + str(len(col2[indexName1[0]])))
print(
str(col1[indexName2[0]][p])
+ " -> "
+ str(col1[indexName2[1]][p])
+ " ("
+ str(col1[indexName2[2]][p])
+ ", "
+ str(col1[indexName2[3]][p])
+ ")"
)
print(
"\nNumber of pairs unmatched in "
+ fName2
+ " is: "
+ str(len(col2[indexName1[0]]))
)
for p in range(len(col2[indexName1[0]])):
print(str(col2[indexName1[0]][p])+" -> "+str(col2[indexName1[1]][p])+" ("+str(col2[indexName1[2]][p])+", "+str(col2[indexName1[3]][p])+")")
print(
str(col2[indexName1[0]][p])
+ " -> "
+ str(col2[indexName1[1]][p])
+ " ("
+ str(col2[indexName1[2]][p])
+ ", "
+ str(col2[indexName1[3]][p])
+ ")"
)


# Get columns from .txt files
def getColumns(fileIn, delim = "\t", header = True):
def getColumns(fileIn, delim="\t", header=True):
cols = {}
indexName = {}
for lineNum, line in enumerate(fileIn):
Expand All @@ -63,6 +100,7 @@ def getColumns(fileIn, delim = "\t", header = True):
i += 1
return cols, indexName


# Get columns from .xls files
def getColumnsXls(fileIn):
cols = {}
Expand Down Expand Up @@ -92,16 +130,19 @@ def getColumnsXls(fileIn):
cols[indexName[curr_cell]] += [cell_value]
return cols, indexName


# Sort dictionaries by first two column (From/To Neurons), first by one, then the other.
def sortTwoColumns(cols):
cols = sorted(cols, key = itemgetter(0,1))
cols = sorted(cols, key=itemgetter(0, 1))


# Formatting involved removing any filler zeros from the middle of strings.
def formatNames(cols, indexName):
for i in range(2):
for char in cols[indexName[i]]:
if char[-1] != '0':
char = "".join(char.split("0",1))
if char[-1] != "0":
char = "".join(char.split("0", 1))


# Compare two lists, create new list of matching pairs, remove pairs from respective original lists.
def matchLists(cols1, cols2, indexName1, indexName2):
Expand Down Expand Up @@ -134,7 +175,9 @@ def matchLists(cols1, cols2, indexName1, indexName2):
if x2 == pair:
index2 = p2
# If matches array does not contain current pair from long array, add it
if not zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(([pair[0]],[pair[1]])):
if not zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(
([pair[0]], [pair[1]])
):
# print(matches[indexNames1[0]], matches[indexNames1[1]])
for i in range(len(indexNames1)):
if col1[indexNames1[i]][index1] == col2[indexNames2[i]][index2]:
Expand All @@ -144,17 +187,23 @@ def matchLists(cols1, cols2, indexName1, indexName2):
del col2[indexNames2[i]][index2]
del col1[indexNames1[i]][index1]
else:
matches[indexNames1[i]] += [[col1[indexNames1[i]][index1], col2[indexNames2[i]][index2]]]
matches[indexNames1[i]] += [
[col1[indexNames1[i]][index1], col2[indexNames2[i]][index2]]
]
del col2[indexNames2[i]][index2]
del col1[indexNames1[i]][index1]
# If pair is already in array, add value from last two columns to array
else:
for p3, x3 in enumerate(zip(matches[indexNames1[0]], matches[indexNames1[1]])):
for p3, x3 in enumerate(
zip(matches[indexNames1[0]], matches[indexNames1[1]])
):
if x3 == ([pair[0]], [pair[1]]):
index3 = p3
for i in range(len(indexNames1)):
if i > 1:
matches[indexNames1[i]][index3] += [col1[indexNames1[i]][index1]]
matches[indexNames1[i]][index3] += [
col1[indexNames1[i]][index1]
]
del col1[indexNames1[i]][index1]
del col2[indexNames2[i]][index2]

Expand All @@ -164,8 +213,12 @@ def matchLists(cols1, cols2, indexName1, indexName2):
if x1 == pair:
index1 = p1
# If matches array does contain current pair from long array, add its conn. type and number
if zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(([pair[0]],[pair[1]])):
for p3, x3 in enumerate(zip(matches[indexNames1[0]], matches[indexNames1[1]])):
if zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(
([pair[0]], [pair[1]])
):
for p3, x3 in enumerate(
zip(matches[indexNames1[0]], matches[indexNames1[1]])
):
if x3 == ([pair[0]], [pair[1]]):
index3 = p3
for i in range(len(indexNames1)):
Expand All @@ -183,7 +236,9 @@ def matchLists(cols1, cols2, indexName1, indexName2):
for p4, x4 in enumerate(zip(matches[indexNames1[0]], matches[indexNames1[1]])):
if x4 == ([pair[1]], [pair[0]]):
index4 = p4
if zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(([pair[1]], [pair[0]])):
if zip(matches[indexNames1[0]], matches[indexNames1[1]]).__contains__(
([pair[1]], [pair[0]])
):
# print(zip(matches[indexNames1[0]], matches[indexNames1[1]]))
# print(([pair[1]], [pair[0]]))
for i in range(len(indexNames1)):
Expand All @@ -193,26 +248,26 @@ def matchLists(cols1, cols2, indexName1, indexName2):
matches[indexNames1[i]][index4] += [col1[indexNames1[i]][index1]]
del col1[indexNames1[i]][index1]


return matches, col1, col2


# Option of additional formatting to shorten lists. Not used. Not complete.
# 'EJ' maps to 'GapJunction'.
# 'R', 'Rp', 'S', 'Sp' map to 'Send'.
# 'NMJ' does not map.
def typeMapping(cols1, cols2, indexName1, indexName2):
list1 = ['GapJunction','Send']
list2 = ['EJ','NMJ','R','Rp','S','Sp']
list1 = ["GapJunction", "Send"]
list2 = ["EJ", "NMJ", "R", "Rp", "S", "Sp"]
type1 = cols1[indexName1[2]]
type2 = cols2[indexName2[2]]


if __name__ == '__main__':
if __name__ == "__main__":
fName1 = "CElegansNeuronTables.xls"
fName2 = "NeuronConnectFormatted.xlsx"

# file1 = "C:\\Users\\Ari\\Documents\\Projects\\OpenWorm\\book1.txt"
# file2 = "C:\\Users\\Ari\\Documents\\Projects\\OpenWorm\\book2.txt"
# xfile1 = "C:\\Users\\Ari\\Documents\\Projects\\OpenWorm\\CElegansNeuroML\\CElegansNeuronTables.xls"
# xfile2 = "C:\\Users\\Ari\\Documents\\Projects\\OpenWorm\\CElegansNeuroML\\NeuronConnectFormatted.xlsx"
comparitor(fName1,fName2)
comparitor(fName1, fName2)
Loading
Loading