Skip to content

Commit

Permalink
Shortened reader pages
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Jul 2, 2024
1 parent a853833 commit 048c7f0
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 69 deletions.
72 changes: 46 additions & 26 deletions cect/Comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
from cect.ConnectomeReader import analyse_connections
from cect.ConnectomeReader import check_neurons

import sys

all_data = {}

quick = len(sys.argv)>1 and eval(sys.argv[1])

reader_pages = {"Varshney":"Varshney_data",
"White_A":"White_A_data",
"White_L4":"White_L4_data",
Expand All @@ -26,25 +30,26 @@
"N->N neurotrans.",
"N->M neurotrans."]


readers = {"SSData": "cect.SpreadsheetDataReader",
"UpdSSData": "cect.UpdatedSpreadsheetDataReader",
"UpdSSData2": "cect.UpdatedSpreadsheetDataReader2",
"Varshney": "cect.VarshneyDataReader",
"White_L4": "cect.White_L4",
}
readers = {"SSData": "cect.SpreadsheetDataReader",
"UpdSSData": "cect.UpdatedSpreadsheetDataReader",
"UpdSSData2": "cect.UpdatedSpreadsheetDataReader2",
"White_A": "cect.White_A",
"White_L4": "cect.White_L4",
"White_whole": "cect.White_whole",
"Varshney": "cect.VarshneyDataReader",
"Witvliet1": "cect.WitvlietDataReader1",
"Witvliet2": "cect.WitvlietDataReader2",
"WormNeuroAtlas": "cect.WormNeuroAtlasReader",
"Cook2019Herm": "cect.Cook2019HermReader",
}
if quick:
readers = {"SSData": "cect.SpreadsheetDataReader",
"UpdSSData": "cect.UpdatedSpreadsheetDataReader",
"UpdSSData2": "cect.UpdatedSpreadsheetDataReader2",
"Varshney": "cect.VarshneyDataReader",
"White_L4": "cect.White_L4",
}
else:
readers = {"SSData": "cect.SpreadsheetDataReader",
"UpdSSData": "cect.UpdatedSpreadsheetDataReader",
"UpdSSData2": "cect.UpdatedSpreadsheetDataReader2",
"White_A": "cect.White_A",
"White_L4": "cect.White_L4",
"White_whole": "cect.White_whole",
"Varshney": "cect.VarshneyDataReader",
"Witvliet1": "cect.WitvlietDataReader1",
"Witvliet2": "cect.WitvlietDataReader2",
"WormNeuroAtlas": "cect.WormNeuroAtlasReader",
"Cook2019Herm": "cect.Cook2019HermReader",
}


def shorten_neurotransmitter(nt):
Expand All @@ -53,7 +58,7 @@ def shorten_neurotransmitter(nt):


# TODO: move elsewhere and make more generic
def get_cell_link(cell_name):
def get_cell_link(cell_name, html=False):

url = None

Expand All @@ -71,7 +76,10 @@ def get_cell_link(cell_name):
url = 'https://www.wormatlas.org/neurons/Individual Neurons/%sframeset.html'%cell_name

if url is not None:
return '[%s](%s)'%(cell_name, url)
if html:
return '<a href="%s">%s</a>'%(url, cell_name)
else:
return '[%s](%s)'%(cell_name, url)
else:
return cell_name

Expand Down Expand Up @@ -119,7 +127,8 @@ def get_cell_link(cell_name):
ref = '[%s](%s.md)'%(name,reader_pages[name]) if name in reader_pages else name

if name in reader_pages:
with open('docs/%s.md'%reader_pages[name], 'w') as f:
filename = 'docs/%s.md'%reader_pages[name]
with open(filename, 'w') as f:
f.write('## %s\n'%name)

cells = {'Neurons': preferred,
Expand All @@ -128,9 +137,18 @@ def get_cell_link(cell_name):
"Other cells": not_in_preferred}

for t in cells:
f.write('\n### %s (%i)\n| '%(t,len(cells[t])))
for n in sorted(cells[t]):
f.write('%s | '%(get_cell_link(n)))
f.write('\n### %s (%i)\n'%(t,len(cells[t])))
if len(cells[t])>0:
f.write('<details><summary>Full list of %s</summary>\n'%t)
ss = sorted(cells[t])
for n in ss:
f.write('%s'%(get_cell_link(n, True)))
if n is not ss[-1]:
f.write(' | ')

f.write('\n</details>\n')

print('Written page: %s'%filename)


all_data[ref] =[len(preferred),
Expand All @@ -156,6 +174,8 @@ def get_cell_link(cell_name):

mk = df_all.to_markdown()

with open('docs/Comparison.md', 'w') as f:
filename = 'docs/Comparison.md'
with open(filename, 'w') as f:
f.write(mk)

print('Written page: %s'%filename)
13 changes: 9 additions & 4 deletions docs/Cook2019Herm_data.md

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions docs/Varshney_data.md

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions docs/White_A_data.md

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions docs/White_L4_data.md

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions docs/White_whole_data.md

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions docs/Witvliet1_data.md

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions docs/Witvliet2_data.md

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions docs/WormNeuroAtlas_data.md

Large diffs are not rendered by default.

33 changes: 22 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,39 @@ set -ex

pip install .

quick_test=false

if [[ ($# -eq 1) && ($1 == '-q') ]]; then
quick_test=true
fi

## Test readers

python -m cect.SpreadsheetDataReader
python -m cect.UpdatedSpreadsheetDataReader
python -m cect.UpdatedSpreadsheetDataReader2
#python -m cect.OpenWormReader
python -m cect.VarshneyDataReader
python -m cect.Cook2019DataReader
python -m cect.Cook2019HermReader
python -m cect.WormNeuroAtlasReader
python -m cect.W_SpreadsheetDataReader
python -m cect.WitvlietDataReader1
python -m cect.WitvlietDataReader2
python -m cect.WhiteDataReader
python -m cect.White_A
python -m cect.White_L4
python -m cect.White_whole

if [ "$quick_test" == false ]; then

python -m cect.Cook2019DataReader
python -m cect.Cook2019HermReader
python -m cect.WormNeuroAtlasReader
python -m cect.W_SpreadsheetDataReader
python -m cect.WitvlietDataReader1
python -m cect.WitvlietDataReader2
python -m cect.WhiteDataReader
python -m cect.White_A
python -m cect.White_L4
python -m cect.White_whole
fi

python cect/Comparison.py $quick_test
mkdocs build

echo
echo " Successfully completed all cect tests!"
echo " Successfully completed all cect tests (quick run: $quick_test)!"
echo


0 comments on commit 048c7f0

Please sign in to comment.