logo Netzschleuder network catalog, repository, and centrifuge

History of ancient_metabolism

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/ancient_metabolism/__init__.py b/entries/ancient_metabolism/__init__.py
index 8a95b14..59d58e8 100644
--- a/entries/ancient_metabolism/__init__.py
+++ b/entries/ancient_metabolism/__init__.py
@@ -46,7 +46,7 @@ The networks have the following properties:
 tags = ['Biological', 'Metabolic', 'Unweighted', 'Metadata']
 url = 'https://doi.org/10.1016/j.cell.2017.02.001'
 citation = [('J. E. Goldford, H. Hartman, T. F. Smith, D. Segrè, "Remnants of an Ancient Metabolism without Phosphate." Cell 168(6), 1126-1134.e9 (2017)', 'https://doi.org/10.1016/j.cell.2017.02.001')]
-icon_hash = '592de57367ec90f1500d4e41'
+date_added = '2026-10-25'
 upstream_license = ("Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)",
                     "https://creativecommons.org/licenses/by-nc-nd/4.0/")
 # Supplementary tables S1 and S2 of the article, from the Internet Archive
[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/ancient_metabolism/__init__.py b/entries/ancient_metabolism/__init__.py
index c7c09b3..8a95b14 100644
--- a/entries/ancient_metabolism/__init__.py
+++ b/entries/ancient_metabolism/__init__.py
@@ -32,8 +32,15 @@ The reactions of KEGG were filtered to keep only those whose compounds all have
 
 The networks have the following properties:
 
-- Nodes: `is_reaction`, whether the node is a reaction (otherwise it is a metabolite); `kegg_id`, the KEGG identifier (e.g. R00004 for reactions and C00001 for compounds); `name`, the name of the reaction or compound (empty for some reactions); `formula`, for reactions, the reaction equation with KEGG compound identifiers (reactions involving oxygen are written with "=>", the others with "<=>"), and for metabolites, the chemical formula; `smiles`, the SMILES string of metabolites; `delta_g`, the standard molar free energy of reactions in kJ/mol (at pH 7 and ionic strength 0.1 M; NaN if unavailable); `anaerobic`, whether the node belongs to the anaerobic network; `core`, whether the node belongs to the phosphate-free core network.
-- Edges: `stoichiometry`, the stoichiometric coefficient of the metabolite in the reaction, negative for metabolites on the left-hand side of the reaction equation (substrates in the direction written) and positive for those on the right-hand side (products).[^icon]
+- (Node) `is_reaction`: whether the node is a reaction (otherwise it is a metabolite).
+- (Node) `kegg_id`: the KEGG identifier (e.g. R00004 for reactions and C00001 for compounds).
+- (Node) `name`: the name of the reaction or compound (empty for some reactions).
+- (Node) `formula`: for reactions, the reaction equation with KEGG compound identifiers (reactions involving oxygen are written with "=>", the others with "<=>"), and for metabolites, the chemical formula.
+- (Node) `smiles`: the SMILES string of metabolites.
+- (Node) `delta_g`: the standard molar free energy of reactions in kJ/mol (at pH 7 and ionic strength 0.1 M; NaN if unavailable).
+- (Node) `anaerobic`: whether the node belongs to the anaerobic network.
+- (Node) `core`: whether the node belongs to the phosphate-free core network.
+- (Edge) `stoichiometry`: the stoichiometric coefficient of the metabolite in the reaction, negative for metabolites on the left-hand side of the reaction equation (substrates in the direction written) and positive for those on the right-hand side (products).[^icon].
 
 [^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
 tags = ['Biological', 'Metabolic', 'Unweighted', 'Metadata']
[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/ancient_metabolism/__init__.py b/entries/ancient_metabolism/__init__.py
index f18e63c..c7c09b3 100644
--- a/entries/ancient_metabolism/__init__.py
+++ b/entries/ancient_metabolism/__init__.py
@@ -66,7 +66,6 @@ def read_sheet(name, fname, sheet):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     rxns = mets = None
     for fnames, alt, fmt in files:
[entries] New entry: ancient_metabolism by Tiago de Paula Peixoto d6c1aab
diff --git a/entries/ancient_metabolism/__init__.py b/entries/ancient_metabolism/__init__.py
new file mode 100644
index 0000000..f18e63c
--- /dev/null
+++ b/entries/ancient_metabolism/__init__.py
@@ -0,0 +1,141 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# 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
+# 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 Affero General Public License for more
+# details.
+#
+# 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 *
+import re
+import math
+import openpyxl
+
+title = "Biosphere-level and ancient phosphate-free metabolism (2017)"
+description = """Bipartite networks of metabolic reactions and metabolites from the KEGG database, assembled by J. E. Goldford, H. Hartman, T. F. Smith and D. Segrè as a model of the metabolism of the whole biosphere, and used to find a core metabolic network that could have functioned without phosphate in an early, prebiotic environment. Nodes represent reactions and metabolites, and an undirected edge connects a reaction to each metabolite that it consumes or produces, with the stoichiometric coefficient as edge property.
+
+The reactions of KEGG were filtered to keep only those whose compounds all have a known structure (SMILES string) and no polymer subunits of undefined size, and which are elementally balanced (for every element except hydrogen; generic "R" groups are allowed if balanced). There are three networks:
+
+- `kegg`: the elementally balanced KEGG network (the "full KEGG network" of the paper), with 6,880 reactions and the 5,944 metabolites listed in the source data (146 of which take part in none of the reactions, and are isolated nodes).
+- `anaerobic`: the anaerobic (oxygen-independent) network, obtained by removing all reactions that involve molecular oxygen, and keeping only the largest connected component of the remaining bipartite graph, with 5,651 reactions and 5,252 metabolites.
+- `core`: the phosphate-free core network, with 315 reactions and 260 metabolites, obtained by "network expansion" from a seed set of eight simple compounds thought to be available in prebiotic environments (lacking phosphate), i.e. by iteratively adding all reactions of the KEGG network whose substrates are available (reactions considered reversible, except the ones that would produce oxygen), together with their products, until no new reactions can be added.
+
+The networks have the following properties:
+
+- Nodes: `is_reaction`, whether the node is a reaction (otherwise it is a metabolite); `kegg_id`, the KEGG identifier (e.g. R00004 for reactions and C00001 for compounds); `name`, the name of the reaction or compound (empty for some reactions); `formula`, for reactions, the reaction equation with KEGG compound identifiers (reactions involving oxygen are written with "=>", the others with "<=>"), and for metabolites, the chemical formula; `smiles`, the SMILES string of metabolites; `delta_g`, the standard molar free energy of reactions in kJ/mol (at pH 7 and ionic strength 0.1 M; NaN if unavailable); `anaerobic`, whether the node belongs to the anaerobic network; `core`, whether the node belongs to the phosphate-free core network.
+- Edges: `stoichiometry`, the stoichiometric coefficient of the metabolite in the reaction, negative for metabolites on the left-hand side of the reaction equation (substrates in the direction written) and positive for those on the right-hand side (products).[^icon]
+
+[^icon]: Description obtained in part from the [ICON](https://icon.colorado.edu) project."""
+tags = ['Biological', 'Metabolic', 'Unweighted', 'Metadata']
+url = 'https://doi.org/10.1016/j.cell.2017.02.001'
+citation = [('J. E. Goldford, H. Hartman, T. F. Smith, D. Segrè, "Remnants of an Ancient Metabolism without Phosphate." Cell 168(6), 1126-1134.e9 (2017)', 'https://doi.org/10.1016/j.cell.2017.02.001')]
+icon_hash = '592de57367ec90f1500d4e41'
+upstream_license = ("Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)",
+                    "https://creativecommons.org/licenses/by-nc-nd/4.0/")
+# Supplementary tables S1 and S2 of the article, from the Internet Archive
+# (the publisher's site refuses automated downloads)
+archived_urls = {
+    "mmc1.xlsx": "https://web.archive.org/web/20221023042933id_/https://www.cell.com/cms/10.1016/j.cell.2017.02.001/attachment/0d294680-8b37-4323-b60f-a0a51a9bdd53/mmc1.xlsx",
+    "mmc2.xlsx": "https://web.archive.org/web/20221023042939id_/https://www.cell.com/cms/10.1016/j.cell.2017.02.001/attachment/f5a6143a-661d-4444-b377-bce915c6f579/mmc2.xlsx",
+}
+upstream_prefix = None
+files = [(("mmc1.xlsx", "mmc2.xlsx"), "kegg", None),
+         (("mmc1.xlsx", "mmc2.xlsx"), "anaerobic", None),
+         (("mmc1.xlsx", "mmc2.xlsx"), "core", None)]
+
+def fetch_upstream(force=False):
+    return fetch_archived_files(__name__.split(".")[-1], archived_urls,
+                                force=force, tries=6)
+
+def read_sheet(name, fname, sheet):
+    with open_upstream_file(name, fname, "rb", seekable=True) as f:
+        wb = openpyxl.load_workbook(f, read_only=True, data_only=True)
+        return [r for r in wb[sheet].iter_rows(values_only=True)]
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    rxns = mets = None
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        if rxns is None:
+            rows = read_sheet(name, fnames[0], "Table S1A")
+            assert rows[1][0] == "ID" and rows[1][5].startswith("INCLUDED IN ANAEROBIC")
+            rxns = [r for r in rows[2:] if r[0] is not None]
+            # Sheet with the metabolites (Table S1B)
+            rows = read_sheet(name, fnames[0], "Table S2A")
+            assert rows[1][0] == "ID" and rows[1][3] == "SMILES STRING"
+            mets = [r for r in rows[2:] if r[0] is not None]
+            rows = read_sheet(name, fnames[1], "Table S2A")
+            core = set(r[0] for r in rows[2:] if r[0] is not None)
+            rows = read_sheet(name, fnames[1], "Table S2B")
+            core |= set(r[0] for r in rows[2:] if r[0] is not None)
+
+        if alt == "kegg":
+            sel = lambda r: True
+        elif alt == "anaerobic":
+            sel = lambda r: bool(r[5]) if r[0][0] == "R" else bool(r[4])
+        else:
+            sel = lambda r: r[0] in core
+
+        g = Graph(directed=False)
+        g.vp.is_reaction = g.new_vp("bool")
+        g.vp.kegg_id = g.new_vp("string")
+        g.vp.name = g.new_vp("string")
+        g.vp.formula = g.new_vp("string")
+        g.vp.smiles = g.new_vp("string")
+        g.vp.delta_g = g.new_vp("double")
+        g.vp.anaerobic = g.new_vp("bool")
+        g.vp.core = g.new_vp("bool")
+        g.ep.stoichiometry = g.new_ep("int")
+
+        vs = {}
+        for r in mets:
+            if not sel(r):
+                continue
+            v = vs[r[0]] = g.add_vertex()
+            g.vp.kegg_id[v] = r[0]
+            g.vp.name[v] = r[1] or ""
+            g.vp.formula[v] = r[2] or ""
+            g.vp.smiles[v] = (r[3] or "").strip()
+            g.vp.delta_g[v] = math.nan
+            g.vp.anaerobic[v] = bool(r[4])
+            g.vp.core[v] = r[0] in core
+
+        edges = []
+        for r in rxns:
+            if not sel(r):
+                continue
+            v = g.add_vertex()
+            g.vp.is_reaction[v] = True
+            g.vp.kegg_id[v] = r[0]
+            g.vp.name[v] = (r[1] or "").strip()
+            g.vp.formula[v] = " ".join(r[2].split())
+            try:
+                g.vp.delta_g[v] = float(r[6])
+            except (TypeError, ValueError):
+                g.vp.delta_g[v] = math.nan
+            g.vp.anaerobic[v] = bool(r[5])
+            g.vp.core[v] = r[0] in core
+            lhs, rhs = re.split(r"<=>|=>", r[2])
+            for side, sign in ((lhs, -1), (rhs, 1)):
+                for t in side.split(" + "):
+                    m = re.fullmatch(r"(?:(\d+) )?([CG]\d{5})", t.strip())
+                    s = int(m[1]) if m[1] is not None else 1
+                    edges.append((vs[m[2]], v, sign * s))
+        g.add_edge_list(edges, eprops=[g.ep.stoichiometry])
+        yield alt, g