logo Netzschleuder network catalog, repository, and centrifuge

History of celegans_2019

The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.

[entries] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto beff7c9
The dates are those of the commits that first added the entries' files
(2020-08-11 for the entries of the initial commit); renamed entries keep
the date of their first name.

Changed: none
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 92bded9..78780d0 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -38,7 +38,7 @@ The networks have the following properties:
 tags = ['Biological', 'Connectome', 'Weighted']
 url = 'https://wormwiring.org/pages/adjacency.html'
 citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://doi.org/10.1038/s41586-019-1352-7')]
-icon_hash = '5d1cfbf5f7b45cae742fd520'
+date_added = '2020-08-11'
 upstream_license = None
 upstream_prefix = 'https://wormwiring.org/si'
 files = [('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_chemical', None),
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto bc3dbbd
The lists of properties at the end of the descriptions marked edge
properties with "Edge" but left node properties unmarked, or grouped
them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property
was often unclear. Every item now starts with (Node), (Edge) or (Graph),
followed by the property names, a colon and the explanation, one item
per property or group of properties; qualifications (kinds of nodes,
networks) follow the names in parentheses. Properties that were only
named got a short explanation, and a few items that named the wrong
kind of property were corrected.
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index a79758b..92bded9 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -31,8 +31,10 @@ There are twelve networks, named `<sex>_<type>[_<version>]`, for each sex (`herm
 
 The networks have the following properties:
 
-- Nodes: `name`, the name of the cell; `node_type`, the cell category (e.g. sensory neurons, interneurons, motor neurons, pharynx, bodywall muscles, other end organs, sex-specific cells); `node_subtype`, a sub-category for some cells (e.g. head, sublateral or body motor neurons; empty otherwise). `node_type` and `node_subtype` are not available in `male_chemical_synapse` and `male_gap_junction_synapse`.
-- Edges: `connectivity` or `synapses`, as described above."""
+- (Node) `name`: the name of the cell.
+- (Node) `node_type`: the cell category (e.g. sensory neurons, interneurons, motor neurons, pharynx, bodywall muscles, other end organs, sex-specific cells).
+- (Node) `node_subtype`: a sub-category for some cells (e.g. head, sublateral or body motor neurons; empty otherwise). `node_type` and `node_subtype` are not available in `male_chemical_synapse` and `male_gap_junction_synapse`.
+- (Edge) `connectivity` or `synapses`: as described above."""
 tags = ['Biological', 'Connectome', 'Weighted']
 url = 'https://wormwiring.org/pages/adjacency.html'
 citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://doi.org/10.1038/s41586-019-1352-7')]
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 2c69f19
Unneeded "global files" statements, unused imports and variables,
f-strings without placeholders, duplicate keys in foodweb_little_rock
(keeping the order and the values used), and the second definition of
get_lines() in twitter_higgs. Nothing changes in the networks or
descriptions.

Changed: none
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 66dfeaa..a79758b 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -60,7 +60,6 @@ def fetch_upstream(force=False):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fname, alt, fmt in files:
         if alts is not None and alt not in alts:
[pipeline] Fix KONECT entity files, seekable upstream files and archive formats by Tiago de Paula Peixoto 2f6e19f
- konect.py: each ent.<net>.<entity>.<attr> file becomes a vertex
  property on the side of the entity it describes (per-vertex or per-edge
  files), instead of all of them being written from vertex 0 into `meta`
  (which put e.g. the item names of bibsonomy and reuters on the wrong
  nodes); only leading "%" lines are comments.
- open_upstream_file(..., seekable=True) returns a seekable file (via a
  temporary file) for readers that need one (openpyxl, scipy.io.loadmat,
  zipfile), replacing the per-entry BytesIO copies.
- .xz files can be read again; .xz, .rar and .7z downloads are stored as
  they are, and "x.tar.xz:", "x.rar:" and "x.7z:" member access works
  (with py7zr or the 7z command); caches in the previous layouts are still
  read.
- parsers.py: vprops_from_txt matches rows by name for graphs keyed by
  name; the Wikimedia dump readers (stub histories, SQL tables) are shared
  helpers; new read_doc (tables of Word documents via LibreOffice) and
  read_epanet (EPANET water network files) readers.
- The entries' workarounds are removed (all parse identically).
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index acd5b10..66dfeaa 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -21,25 +21,23 @@ from openpyxl import load_workbook
 import pandas
 
 title = "Complete C. elegans neurons (2019)"
-description = """Networks among neurons of both the adult male and adult hermaphrodite worms C. elegans, constructed from electron microscopy series, to include directed edges (chemical) and undirected (gap junction), and spanning including nodes for muscle and non-muscle end organs.[^icon]
+description = """Whole-animal connectomes of both sexes of the nematode *Caenorhabditis elegans*, the adult hermaphrodite and the adult male, reconstructed by S. J. Cook and collaborators from serial-section electron microscopy (EM) series, including both new reconstructions and a re-analysis of the original EM material of J. G. White and others. Nodes are cells: neurons, as well as the muscles and other end organs that they innervate. Edges are either chemical synapses (directed, from the pre-synaptic to the post-synaptic cell) or gap junctions (electrical synapses, undirected). To cover the entire nervous system, the connectomes were assembled from several animals, and connections were added by extrapolation in regions where no EM data were available.
 
-For chemical connections, directed edges go from pre-synaptic cell to post-synaptic cell. 
+There are twelve networks, named `<sex>_<type>[_<version>]`, for each sex (`hermaphrodite`, `male`) and connection type (`chemical`, `gap_junction`):
 
-The 'connectivity' edge property corresponds to the total number of EM serial sections of connectivity, taking into account both the number of synapses and the sizes of synapses.
+- no suffix: the connectome adjacency matrices, where the edge property `connectivity` is the total number of EM serial sections in which the connection is observed, which accounts for both the number and the size of the synapses.
+- `_corrected`: corrected versions of the connectome matrices, released by the authors in July 2020.
+- `_synapse`: the synapse adjacency matrices, where the edge property `synapses` is the number of synapses scored between each pair of cells. These do not take into account the size of the synapses, include only connections scored on electron micrographs, and do not include connections inserted by extrapolation; hence some cells that are connected in the other networks are not connected here.
 
-To provide complete coverage of the entire nervous system, the data are assembled from multiple animals and include connections added by extrapolation in gaps where no data were available. 
+The networks have the following properties:
 
-For 'synapse' data the edge property 'synapses' contain the number of synapses scored between each pair of cells. These networks differ from the others in not taking into account the sizes of synapses and in showing only connections scored on electron micrographs.  It does not include any connections inserted by extrapolation.  Thus there are cells showing no connection here that are connected in the the other matrices.  Also note, there are more edges in these networks than the total number of synapses scored (synapse lists, Supplementary Information 3).  This is because polyads are listed here more than once (once for each postsynaptic cell).
-
-The '_corrected' networks correspond to corrected versions of the network made available in July 2020.
-
-[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project.
-"""
+- Nodes: `name`, the name of the cell; `node_type`, the cell category (e.g. sensory neurons, interneurons, motor neurons, pharynx, bodywall muscles, other end organs, sex-specific cells); `node_subtype`, a sub-category for some cells (e.g. head, sublateral or body motor neurons; empty otherwise). `node_type` and `node_subtype` are not available in `male_chemical_synapse` and `male_gap_junction_synapse`.
+- Edges: `connectivity` or `synapses`, as described above."""
 tags = ['Biological', 'Connectome', 'Weighted']
 url = 'https://wormwiring.org/pages/adjacency.html'
 citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://doi.org/10.1038/s41586-019-1352-7')]
 icon_hash = '5d1cfbf5f7b45cae742fd520'
-ustream_license = None
+upstream_license = None
 upstream_prefix = 'https://wormwiring.org/si'
 files = [('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_chemical', None),
          ('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_gap_junction', None),
@@ -67,7 +65,7 @@ def parse(alts=None):
     for fname, alt, fmt in files:
         if alts is not None and alt not in alts:
             continue
-        with open_upstream_file(name, fname, "rb") as f:
+        with open_upstream_file(name, fname, "rb", seekable=True) as f:
             wb = load_workbook(f, read_only=True)
             if alt in ["male_chemical", "male_chemical_corrected"]:
                 g = parse_connectome(wb["male chemical"])
@@ -158,9 +156,10 @@ def parse_connectome(ws, moff=2):
                 int(m[i, j])
             except ValueError:
                 continue
+            # rows are pre-synaptic and columns post-synaptic cells
             v = vs[m[i,moff]]
             u = vs[m[moff,j]]
-            e = g.add_edge(u, v)
+            e = g.add_edge(v, u)
             g.ep.connectivity[e] = m[i,j]
 
     return g
Update copyright information by Tiago de Paula Peixoto 73a4f0d
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index cd65df3..acd5b10 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Affero General Public License as published by the Free
Update copyright information by Tiago de Paula Peixoto 3d288ea
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 91b8554..cd65df3 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Affero General Public License as published by the Free
@@ -163,4 +163,4 @@ def parse_connectome(ws, moff=2):
             e = g.add_edge(u, v)
             g.ep.connectivity[e] = m[i,j]
 
-    return g
\ No newline at end of file
+    return g
Update copyright information by Tiago de Paula Peixoto 8d005ae
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 46ec130..91b8554 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Affero General Public License as published by the Free
Update copyright info by Tiago de Paula Peixoto db2efcc
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 4957685..46ec130 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
 #
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU Affero General Public License as published by the Free
Update citations to use DOIs by Tiago de Paula Peixoto e878874
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 676506d..4957685 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -37,7 +37,7 @@ The '_corrected' networks correspond to corrected versions of the network made a
 """
 tags = ['Biological', 'Connectome', 'Weighted']
 url = 'https://wormwiring.org/pages/adjacency.html'
-citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://www.nature.com/articles/s41586-019-1352-7')]
+citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://doi.org/10.1038/s41586-019-1352-7')]
 icon_hash = '5d1cfbf5f7b45cae742fd520'
 ustream_license = None
 upstream_prefix = 'https://wormwiring.org/si'
celegans_2019: fix SSL problem by Tiago de Paula Peixoto a57e365
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index 4c88422..676506d 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -56,7 +56,7 @@ files = [('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_chemical', No
 
 def fetch_upstream(force=False):
     return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
-                                force)
+                                force, bad_ssl=True)
 
 @cache_network()
 @coerce_props()
Change license from GPLv3 to AGPLv3 by Tiago de Paula Peixoto d754be5
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index d935dce..4c88422 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -3,18 +3,18 @@
 #
 # Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
 #
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+# details.
 #
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Affero General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from .. import *
 from openpyxl import load_workbook
Add explicit attribution to descriptions obtained from ICON by Tiago de Paula Peixoto 1645314
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index e6f3349..d935dce 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -21,7 +21,7 @@ from openpyxl import load_workbook
 import pandas
 
 title = "Complete C. elegans neurons (2019)"
-description = """Networks among neurons of both the adult male and adult hermaphrodite worms C. elegans, constructed from electron microscopy series, to include directed edges (chemical) and undirected (gap junction), and spanning including nodes for muscle and non-muscle end organs.
+description = """Networks among neurons of both the adult male and adult hermaphrodite worms C. elegans, constructed from electron microscopy series, to include directed edges (chemical) and undirected (gap junction), and spanning including nodes for muscle and non-muscle end organs.[^icon]
 
 For chemical connections, directed edges go from pre-synaptic cell to post-synaptic cell. 
 
@@ -32,6 +32,8 @@ To provide complete coverage of the entire nervous system, the data are assemble
 For 'synapse' data the edge property 'synapses' contain the number of synapses scored between each pair of cells. These networks differ from the others in not taking into account the sizes of synapses and in showing only connections scored on electron micrographs.  It does not include any connections inserted by extrapolation.  Thus there are cells showing no connection here that are connected in the the other matrices.  Also note, there are more edges in these networks than the total number of synapses scored (synapse lists, Supplementary Information 3).  This is because polyads are listed here more than once (once for each postsynaptic cell).
 
 The '_corrected' networks correspond to corrected versions of the network made available in July 2020.
+
+[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project.
 """
 tags = ['Biological', 'Connectome', 'Weighted']
 url = 'https://wormwiring.org/pages/adjacency.html'
celegans_2019: include new 'corrected' networks by Tiago de Paula Peixoto 545d287
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
index c47864f..e6f3349 100644
--- a/entries/celegans_2019/__init__.py
+++ b/entries/celegans_2019/__init__.py
@@ -30,9 +30,11 @@ The 'connectivity' edge property corresponds to the total number of EM serial se
 To provide complete coverage of the entire nervous system, the data are assembled from multiple animals and include connections added by extrapolation in gaps where no data were available. 
 
 For 'synapse' data the edge property 'synapses' contain the number of synapses scored between each pair of cells. These networks differ from the others in not taking into account the sizes of synapses and in showing only connections scored on electron micrographs.  It does not include any connections inserted by extrapolation.  Thus there are cells showing no connection here that are connected in the the other matrices.  Also note, there are more edges in these networks than the total number of synapses scored (synapse lists, Supplementary Information 3).  This is because polyads are listed here more than once (once for each postsynaptic cell).
+
+The '_corrected' networks correspond to corrected versions of the network made available in July 2020.
 """
 tags = ['Biological', 'Connectome', 'Weighted']
-url = 'http://wormwiring.org/series/'
+url = 'https://wormwiring.org/pages/adjacency.html'
 citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://www.nature.com/articles/s41586-019-1352-7')]
 icon_hash = '5d1cfbf5f7b45cae742fd520'
 ustream_license = None
@@ -44,7 +46,11 @@ files = [('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_chemical', No
          ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'male_chemical_synapse', None),
          ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'male_gap_junction_synapse', None),
          ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'hermaphrodite_chemical_synapse', None),
-         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'hermaphrodite_gap_junction_synapse', None)]
+         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'hermaphrodite_gap_junction_synapse', None),
+         ('SI%205%20Connectome%20adjacency%20matrices,%20corrected%20July%202020.xlsx', 'male_chemical_corrected', None),
+         ('SI%205%20Connectome%20adjacency%20matrices,%20corrected%20July%202020.xlsx', 'male_gap_junction_corrected', None),
+         ('SI%205%20Connectome%20adjacency%20matrices,%20corrected%20July%202020.xlsx', 'hermaphrodite_chemical_corrected', None),
+         ('SI%205%20Connectome%20adjacency%20matrices,%20corrected%20July%202020.xlsx', 'hermaphrodite_gap_junction_corrected', None)]
 
 def fetch_upstream(force=False):
     return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
@@ -61,17 +67,20 @@ def parse(alts=None):
             continue
         with open_upstream_file(name, fname, "rb") as f:
             wb = load_workbook(f, read_only=True)
-            if alt == "male_chemical":
+            if alt in ["male_chemical", "male_chemical_corrected"]:
                 g = parse_connectome(wb["male chemical"])
-            elif alt == "hermaphrodite_chemical":
+            elif alt in ["hermaphrodite_chemical", "hermaphrodite_chemical_corrected"]:
                 g = parse_connectome(wb["hermaphrodite chemical"])
-            elif alt == "male_gap_junction":
+            elif alt in ["male_gap_junction", "male_gap_junction_corrected"]:
                 g = parse_connectome(wb["male gap jn asymmetric"])
                 g.set_directed(False)
             elif alt == "hermaphrodite_gap_junction":
                 g = parse_connectome(wb["herm gap jn asymmetric"])
                 g.set_directed(False)
-            elif alt == "male_chemical_synapse":
+            elif alt == "hermaphrodite_gap_junction_corrected":
+                g = parse_connectome(wb["hermaphrodite gap jn asymmetric"])
+                g.set_directed(False)
+            elif alt in ["male_chemical_synapse"]:
                 g = parse_connectome(wb["male chem synapse adjacency"], moff=0)
                 del g.vp["node_type"]
                 del g.vp["node_subtype"]
Initial commit by Tiago de Paula Peixoto cc85872
diff --git a/entries/celegans_2019/__init__.py b/entries/celegans_2019/__init__.py
new file mode 100644
index 0000000..c47864f
--- /dev/null
+++ b/entries/celegans_2019/__init__.py
@@ -0,0 +1,155 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+from openpyxl import load_workbook
+import pandas
+
+title = "Complete C. elegans neurons (2019)"
+description = """Networks among neurons of both the adult male and adult hermaphrodite worms C. elegans, constructed from electron microscopy series, to include directed edges (chemical) and undirected (gap junction), and spanning including nodes for muscle and non-muscle end organs.
+
+For chemical connections, directed edges go from pre-synaptic cell to post-synaptic cell. 
+
+The 'connectivity' edge property corresponds to the total number of EM serial sections of connectivity, taking into account both the number of synapses and the sizes of synapses.
+
+To provide complete coverage of the entire nervous system, the data are assembled from multiple animals and include connections added by extrapolation in gaps where no data were available. 
+
+For 'synapse' data the edge property 'synapses' contain the number of synapses scored between each pair of cells. These networks differ from the others in not taking into account the sizes of synapses and in showing only connections scored on electron micrographs.  It does not include any connections inserted by extrapolation.  Thus there are cells showing no connection here that are connected in the the other matrices.  Also note, there are more edges in these networks than the total number of synapses scored (synapse lists, Supplementary Information 3).  This is because polyads are listed here more than once (once for each postsynaptic cell).
+"""
+tags = ['Biological', 'Connectome', 'Weighted']
+url = 'http://wormwiring.org/series/'
+citation = [('Cook et al., "Whole-animal connectomes of both Caenorhabditis elegans sexes." Nature 571, 63-71 (2019)', 'https://www.nature.com/articles/s41586-019-1352-7')]
+icon_hash = '5d1cfbf5f7b45cae742fd520'
+ustream_license = None
+upstream_prefix = 'https://wormwiring.org/si'
+files = [('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_chemical', None),
+         ('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'male_gap_junction', None),
+         ('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'hermaphrodite_chemical', None),
+         ('SI%205%20Connectome%20adjacency%20matrices.xlsx', 'hermaphrodite_gap_junction', None),
+         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'male_chemical_synapse', None),
+         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'male_gap_junction_synapse', None),
+         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'hermaphrodite_chemical_synapse', None),
+         ('SI%202%20Synapse%20adjacency%20matrices.xlsx', 'hermaphrodite_gap_junction_synapse', None)]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fname, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        with open_upstream_file(name, fname, "rb") as f:
+            wb = load_workbook(f, read_only=True)
+            if alt == "male_chemical":
+                g = parse_connectome(wb["male chemical"])
+            elif alt == "hermaphrodite_chemical":
+                g = parse_connectome(wb["hermaphrodite chemical"])
+            elif alt == "male_gap_junction":
+                g = parse_connectome(wb["male gap jn asymmetric"])
+                g.set_directed(False)
+            elif alt == "hermaphrodite_gap_junction":
+                g = parse_connectome(wb["herm gap jn asymmetric"])
+                g.set_directed(False)
+            elif alt == "male_chemical_synapse":
+                g = parse_connectome(wb["male chem synapse adjacency"], moff=0)
+                del g.vp["node_type"]
+                del g.vp["node_subtype"]
+            elif alt == "hermaphrodite_chemical_synapse":
+                g = parse_connectome(wb["herm chem synapse adjacency"])
+            elif alt == "male_gap_junction_synapse":
+                g = parse_connectome(wb["male gap jn synapse adjacency"], moff=0)
+                g.set_directed(False)
+                del g.vp["node_type"]
+                del g.vp["node_subtype"]
+            elif alt == "hermaphrodite_gap_junction_synapse":
+                g = parse_connectome(wb["herm gap jn synapse adjacency"])
+                g.set_directed(False)
+            if "synapse" in alt:
+                g.ep.synapses = g.ep.connectivity
+                del g.ep["connectivity"]
+        yield alt, g
+
+def parse_connectome(ws, moff=2):
+    g = Graph()
+
+    g.vp.node_type = g.new_vp("string")
+    g.vp.node_subtype = g.new_vp("string")
+    g.vp.name = g.new_vp("string")
+    g.ep.connectivity = g.new_ep("int")
+
+    m = pandas.DataFrame(ws.values).values
+
+    if moff == 2:
+        curr_type = None
+        for i, t in enumerate(m[0,:]):
+            if t is not None:
+                curr_type = t
+            else:
+                m[0,i] = curr_type
+
+        curr_type = None
+        for i, t in enumerate(m[1,:]):
+            if t is not None:
+                curr_type = t
+            else:
+                m[1,i] = curr_type
+
+    vs = {}
+    for i, v in enumerate(m[moff,:]):
+        if v is None:
+            continue
+        vs[v] = g.add_vertex()
+        g.vp.name[vs[v]] = v
+        v = vs[v]
+
+        if moff == 2:
+            try:
+                int(m[0, i])
+            except (ValueError, TypeError):
+                if m[0, i] != None:
+                    g.vp.node_type[v] = m[0, i]
+            try:
+                int(m[1, i])
+            except (ValueError, TypeError):
+                if m[1, i] != None:
+                    g.vp.node_subtype[v] = m[1, i]
+
+    for i in range(m[:,moff+1].shape[0]):
+        if i < moff + 1:
+            continue
+        for j in range(m[moff+1,:].shape[0]):
+            if j < moff + 1:
+                continue
+            if m[i, j] is None:
+                continue
+            try:
+                int(m[i, j])
+            except ValueError:
+                continue
+            v = vs[m[i,moff]]
+            u = vs[m[moff,j]]
+            e = g.add_edge(u, v)
+            g.ep.connectivity[e] = m[i,j]
+
+    return g
\ No newline at end of file