logo Netzschleuder network catalog, repository, and centrifuge

History of ncbi_taxonomy

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] Tag madoff_feeders, islamic_state_allegiances, ncbi_taxonomy and hydrorivers as Tree by Tiago de Paula Peixoto a26c82d
The new Tree tag marks the entries whose networks are all trees or
forests, as checked from the analyses and the cached networks
(madoff_feeders, islamic_state_allegiances) or as given by the
descriptions (ncbi_taxonomy, hydrorivers).
diff --git a/entries/ncbi_taxonomy/__init__.py b/entries/ncbi_taxonomy/__init__.py
index ea48291..a8b0135 100644
--- a/entries/ncbi_taxonomy/__init__.py
+++ b/entries/ncbi_taxonomy/__init__.py
@@ -39,7 +39,7 @@ The networks have the following properties:
 - (Node) `division`: the GenBank division of the taxon (e.g. `Bacteria`, `Invertebrates`, `Primates`, `Viruses`).
 - (Node) `genetic_code`, `mito_genetic_code`: the identifiers of the genetic code and of the mitochondrial genetic code of the taxon.
 - (Node) `is_hidden`: whether the taxon is hidden in the lineages shown in GenBank entries."""
-tags = ['Biological', 'Informational', 'Unweighted', 'Metadata']
+tags = ['Biological', 'Informational', 'Unweighted', 'Tree', 'Metadata']
 url = ['https://www.ncbi.nlm.nih.gov/taxonomy', 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive/']
 citation = [('C. L. Schoch, S. Ciufo, M. Domrachev, C. L. Hotton, S. Kannan, R. Khovanskaya, D. Leipe, R. Mcveigh, K. O\'Neill, B. Robbertse, S. Sharma, V. Soussov, J. P. Sullivan, L. Sun, S. Turner, I. Karsch-Mizrachi, "NCBI Taxonomy: a comprehensive update on curation, resources and tools." Database 2020, baaa062 (2020)',
              'https://doi.org/10.1093/database/baaa062')]
[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/ncbi_taxonomy/__init__.py b/entries/ncbi_taxonomy/__init__.py
index dfcdd9b..ea48291 100644
--- a/entries/ncbi_taxonomy/__init__.py
+++ b/entries/ncbi_taxonomy/__init__.py
@@ -43,7 +43,7 @@ tags = ['Biological', 'Informational', 'Unweighted', 'Metadata']
 url = ['https://www.ncbi.nlm.nih.gov/taxonomy', 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive/']
 citation = [('C. L. Schoch, S. Ciufo, M. Domrachev, C. L. Hotton, S. Kannan, R. Khovanskaya, D. Leipe, R. Mcveigh, K. O\'Neill, B. Robbertse, S. Sharma, V. Soussov, J. P. Sullivan, L. Sun, S. Turner, I. Karsch-Mizrachi, "NCBI Taxonomy: a comprehensive update on curation, resources and tools." Database 2020, baaa062 (2020)',
              'https://doi.org/10.1093/database/baaa062')]
-icon_hash = None
+date_added = '2026-10-31'
 upstream_license = ('Public domain (NCBI data)', 'https://www.ncbi.nlm.nih.gov/home/about/policies/')
 upstream_prefix = 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive'
 files = [((f"{z}:nodes.dmp", f"{z}:names.dmp", f"{z}:division.dmp"), alt, 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/ncbi_taxonomy/__init__.py b/entries/ncbi_taxonomy/__init__.py
index a72f698..dfcdd9b 100644
--- a/entries/ncbi_taxonomy/__init__.py
+++ b/entries/ncbi_taxonomy/__init__.py
@@ -32,13 +32,13 @@ There is one network for each year from 2014 to 2026, from the last monthly taxo
 
 The networks have the following properties:
 
-- `tax_id`: the identifier of the taxon.
-- `name`: the scientific name of the taxon.
-- `common_name`: the GenBank common name of the taxon (or another common name; empty if it has none).
-- `rank`: the rank of the taxon (e.g. `species`, `genus`, `family`, `strain`, `no rank`).
-- `division`: the GenBank division of the taxon (e.g. `Bacteria`, `Invertebrates`, `Primates`, `Viruses`).
-- `genetic_code`, `mito_genetic_code`: the identifiers of the genetic code and of the mitochondrial genetic code of the taxon.
-- `is_hidden`: whether the taxon is hidden in the lineages shown in GenBank entries."""
+- (Node) `tax_id`: the identifier of the taxon.
+- (Node) `name`: the scientific name of the taxon.
+- (Node) `common_name`: the GenBank common name of the taxon (or another common name; empty if it has none).
+- (Node) `rank`: the rank of the taxon (e.g. `species`, `genus`, `family`, `strain`, `no rank`).
+- (Node) `division`: the GenBank division of the taxon (e.g. `Bacteria`, `Invertebrates`, `Primates`, `Viruses`).
+- (Node) `genetic_code`, `mito_genetic_code`: the identifiers of the genetic code and of the mitochondrial genetic code of the taxon.
+- (Node) `is_hidden`: whether the taxon is hidden in the lineages shown in GenBank entries."""
 tags = ['Biological', 'Informational', 'Unweighted', 'Metadata']
 url = ['https://www.ncbi.nlm.nih.gov/taxonomy', 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive/']
 citation = [('C. L. Schoch, S. Ciufo, M. Domrachev, C. L. Hotton, S. Kannan, R. Khovanskaya, D. Leipe, R. Mcveigh, K. O\'Neill, B. Robbertse, S. Sharma, V. Soussov, J. P. Sullivan, L. Sun, S. Turner, I. Karsch-Mizrachi, "NCBI Taxonomy: a comprehensive update on curation, resources and tools." Database 2020, baaa062 (2020)',
[entries] New entry: ncbi_taxonomy by Tiago de Paula Peixoto 55233ba
diff --git a/entries/ncbi_taxonomy/__init__.py b/entries/ncbi_taxonomy/__init__.py
new file mode 100644
index 0000000..a72f698
--- /dev/null
+++ b/entries/ncbi_taxonomy/__init__.py
@@ -0,0 +1,104 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 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 *
+
+# The taxonomy dumps of the archive: the last one of each year (the archive
+# starts in August 2014), and the latest one
+DUMPS = {str(y): f"taxdmp_{y}-12-01.zip" for y in range(2014, 2026)}
+DUMPS["2026"] = "taxdmp_2026-10-01.zip"
+
+title = "NCBI Taxonomy (2014-2026)"
+description = r"""Networks of the NCBI Taxonomy, the taxonomic classification of all the organisms with sequences in the public sequence databases of the International Nucleotide Sequence Database Collaboration (GenBank, ENA, DDBJ), curated by the National Center for Biotechnology Information, which is the reference taxonomy of most biological databases. Besides species and higher taxa, it contains strains, isolates, environmental samples and unclassified organisms.
+
+Nodes are taxa, and a directed edge goes from each taxon to its parent taxon, so that the networks are trees, rooted at the taxon `root` (tax_id 1), whose parent is itself in the data (this self-loop is left out).
+
+There is one network for each year from 2014 to 2026, from the last monthly taxonomy dump of the year in the archive of the NCBI (which starts in August 2014): December 1 of each year from 2014 to 2025, and October 1, 2026 (the latest one).
+
+The networks have the following properties:
+
+- `tax_id`: the identifier of the taxon.
+- `name`: the scientific name of the taxon.
+- `common_name`: the GenBank common name of the taxon (or another common name; empty if it has none).
+- `rank`: the rank of the taxon (e.g. `species`, `genus`, `family`, `strain`, `no rank`).
+- `division`: the GenBank division of the taxon (e.g. `Bacteria`, `Invertebrates`, `Primates`, `Viruses`).
+- `genetic_code`, `mito_genetic_code`: the identifiers of the genetic code and of the mitochondrial genetic code of the taxon.
+- `is_hidden`: whether the taxon is hidden in the lineages shown in GenBank entries."""
+tags = ['Biological', 'Informational', 'Unweighted', 'Metadata']
+url = ['https://www.ncbi.nlm.nih.gov/taxonomy', 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive/']
+citation = [('C. L. Schoch, S. Ciufo, M. Domrachev, C. L. Hotton, S. Kannan, R. Khovanskaya, D. Leipe, R. Mcveigh, K. O\'Neill, B. Robbertse, S. Sharma, V. Soussov, J. P. Sullivan, L. Sun, S. Turner, I. Karsch-Mizrachi, "NCBI Taxonomy: a comprehensive update on curation, resources and tools." Database 2020, baaa062 (2020)',
+             'https://doi.org/10.1093/database/baaa062')]
+icon_hash = None
+upstream_license = ('Public domain (NCBI data)', 'https://www.ncbi.nlm.nih.gov/home/about/policies/')
+upstream_prefix = 'https://ftp.ncbi.nlm.nih.gov/pub/taxonomy/taxdump_archive'
+files = [((f"{z}:nodes.dmp", f"{z}:names.dmp", f"{z}:division.dmp"), alt, None)
+         for alt, z in DUMPS.items()]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+def records(f):
+    for l in f:
+        yield l.rstrip("\n").removesuffix("\t|").split("\t|\t")
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    name = __name__.split(".")[-1]
+    for (fnodes, fnames, fdiv), alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        with open_upstream_file(name, fdiv, "r") as f:
+            divisions = {int(r[0]): r[2] for r in records(f)}
+        tax, parent, rank, div, gc, mgc, hidden = [], [], [], [], [], [], []
+        with open_upstream_file(name, fnodes, "r") as f:
+            for r in records(f):
+                tax.append(int(r[0]))
+                parent.append(int(r[1]))
+                rank.append(r[2])
+                div.append(divisions.get(int(r[4]), ""))
+                gc.append(int(r[6]))
+                mgc.append(int(r[8]))
+                hidden.append(r[10] == "1")
+        idx = {t: i for i, t in enumerate(tax)}
+        sci = [""] * len(tax)
+        common = [""] * len(tax)
+        with open_upstream_file(name, fnames, "r") as f:
+            for r in records(f):
+                i = idx[int(r[0])]
+                if r[3] == "scientific name":
+                    sci[i] = r[1]
+                elif r[3] == "genbank common name" or \
+                     (r[3] == "common name" and not common[i]):
+                    common[i] = r[1]
+        edges = numpy.array([(i, idx[p]) for i, p in enumerate(parent)
+                             if idx[p] != i], dtype="int64")
+        g = Graph(directed=True)
+        g.add_vertex(len(tax))
+        g.add_edge_list(edges)
+        g.vp.tax_id = g.new_vp("int64_t", vals=tax)
+        g.vp.name = g.new_vp("string", vals=sci)
+        g.vp.common_name = g.new_vp("string", vals=common)
+        g.vp.rank = g.new_vp("string", vals=rank)
+        g.vp.division = g.new_vp("string", vals=div)
+        g.vp.genetic_code = g.new_vp("int32_t", vals=gc)
+        g.vp.mito_genetic_code = g.new_vp("int32_t", vals=mgc)
+        g.vp.is_hidden = g.new_vp("bool", vals=hidden)
+        yield alt, g