History of pubtator3_relations
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 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/pubtator3_relations/__init__.py b/entries/pubtator3_relations/__init__.py
index e223613..2f3464b 100644
--- a/entries/pubtator3_relations/__init__.py
+++ b/entries/pubtator3_relations/__init__.py
@@ -39,7 +39,7 @@ tags = ['Biological', 'Informational', 'Unweighted', 'Multigraph', 'Metadata']
url = ['https://www.ncbi.nlm.nih.gov/research/pubtator3/', 'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3/']
citation = [('C.-H. Wei, A. Allot, P.-T. Lai, R. Leaman, S. Tian, L. Luo, Q. Jin, Z. Wang, Q. Chen, Z. Lu, "PubTator 3.0: an AI-powered literature resource for unlocking biomedical knowledge." Nucleic Acids Research 52, W540-W546 (2024)',
'https://doi.org/10.1093/nar/gkae235')]
-icon_hash = None
+date_added = '2026-10-31'
upstream_license = ('Public domain (United States Government Work)',
'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3/README.txt')
# The file is replaced in place every month (no versioned releases): the
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) 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/pubtator3_relations/__init__.py b/entries/pubtator3_relations/__init__.py
index 4ce608f..e223613 100644
--- a/entries/pubtator3_relations/__init__.py
+++ b/entries/pubtator3_relations/__init__.py
@@ -31,10 +31,10 @@ PubTator3 updates its files monthly, replacing them in place; the data are those
The network has the following properties:
-- `concept`: the concept, with its type and identifier, as given by PubTator3 (e.g. `Chemical|MESH:D003911`, `Gene|7157`).
-- `kind`: the type of the concept: `Gene`, `Chemical`, `Disease`, `Species`, `DNAMutation`, `ProteinMutation`, `SNP`, ...
-- Edge `type`: the type of the relation.
-- Edge `pmid`: the PubMed identifier of the article."""
+- (Node) `concept`: the concept, with its type and identifier, as given by PubTator3 (e.g. `Chemical|MESH:D003911`, `Gene|7157`).
+- (Node) `kind`: the type of the concept: `Gene`, `Chemical`, `Disease`, `Species`, `DNAMutation`, `ProteinMutation`, `SNP`, ...
+- (Edge) `type`: the type of the relation.
+- (Edge) `pmid`: the PubMed identifier of the article."""
tags = ['Biological', 'Informational', 'Unweighted', 'Multigraph', 'Metadata']
url = ['https://www.ncbi.nlm.nih.gov/research/pubtator3/', 'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3/']
citation = [('C.-H. Wei, A. Allot, P.-T. Lai, R. Leaman, S. Tian, L. Luo, Q. Jin, Z. Wang, Q. Chen, Z. Lu, "PubTator 3.0: an AI-powered literature resource for unlocking biomedical knowledge." Nucleic Acids Research 52, W540-W546 (2024)',
[entries] New entry: pubtator3_relations 6671857
diff --git a/entries/pubtator3_relations/__init__.py b/entries/pubtator3_relations/__init__.py
new file mode 100644
index 0000000..4ce608f
--- /dev/null
+++ b/entries/pubtator3_relations/__init__.py
@@ -0,0 +1,111 @@
+#! /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/>.
+
+import pyarrow
+import pyarrow.csv
+import pyarrow.compute as pc
+
+from .. import *
+
+title = "PubTator3 biomedical relations mined from PubMed"
+description = r"""A directed network of biomedical concepts (genes, chemicals, diseases, genetic variants, species) and their relations, mined from the scientific literature by PubTator3 of the NCBI, which annotates all PubMed abstracts (about 36 million) and the full texts of the PMC Open Access Subset with deep-learning text mining tools: AIONER for the recognition of the entities, GNorm2, TaggerOne and NLM-Chem for their normalization to database identifiers, tmVar3 for the variants, and BioREx for the relations between them. Each edge is a relation found in an article, from the first to the second concept of the relation, with the type of relation and the PubMed identifier of the article; two concepts are joined by one edge per article (and type) in which their relation was found, so that the network is a multigraph.
+
+The types of relation are `associate`, `cause`, `compare`, `cotreat`, `drug_interact`, `inhibit`, `interact`, `negative_correlate`, `positive_correlate`, `prevent`, `stimulate` and `treat`. The concepts are identified by the databases used by PubTator3: NCBI Gene identifiers for genes, MeSH identifiers for chemicals and diseases, dbSNP identifiers or tmVar normalized names for variants, NCBI Taxonomy identifiers for species. The names of the concepts are not included (they are in the much larger annotation files of PubTator3).
+
+PubTator3 updates its files monthly, replacing them in place; the data are those of the version of the download date (the release of October 6, 2026, at the time of writing).
+
+The network has the following properties:
+
+- `concept`: the concept, with its type and identifier, as given by PubTator3 (e.g. `Chemical|MESH:D003911`, `Gene|7157`).
+- `kind`: the type of the concept: `Gene`, `Chemical`, `Disease`, `Species`, `DNAMutation`, `ProteinMutation`, `SNP`, ...
+- Edge `type`: the type of the relation.
+- Edge `pmid`: the PubMed identifier of the article."""
+tags = ['Biological', 'Informational', 'Unweighted', 'Multigraph', 'Metadata']
+url = ['https://www.ncbi.nlm.nih.gov/research/pubtator3/', 'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3/']
+citation = [('C.-H. Wei, A. Allot, P.-T. Lai, R. Leaman, S. Tian, L. Luo, Q. Jin, Z. Wang, Q. Chen, Z. Lu, "PubTator 3.0: an AI-powered literature resource for unlocking biomedical knowledge." Nucleic Acids Research 52, W540-W546 (2024)',
+ 'https://doi.org/10.1093/nar/gkae235')]
+icon_hash = None
+upstream_license = ('Public domain (United States Government Work)',
+ 'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3/README.txt')
+# The file is replaced in place every month (no versioned releases): the
+# cached copy is the one used
+upstream_prefix = 'https://ftp.ncbi.nlm.nih.gov/pub/lu/PubTator3'
+files = [("relation2pubtator3.gz", None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+# For checks only: if set, only (about) this many rows are read
+_check_rows = None
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ name = __name__.split(".")[-1]
+ concepts = {}
+ types = {}
+ src, tgt, etype, pmid = [], [], [], []
+ n = 0
+ with open_upstream_file(name, files[0][0], "rb") as f:
+ reader = pyarrow.csv.open_csv(
+ f,
+ read_options=pyarrow.csv.ReadOptions(
+ column_names=["pmid", "type", "a", "b"], block_size=1 << 26),
+ parse_options=pyarrow.csv.ParseOptions(delimiter="\t",
+ quote_char=False),
+ convert_options=pyarrow.csv.ConvertOptions(
+ column_types={"pmid": pyarrow.int64(), "type": pyarrow.string(),
+ "a": pyarrow.string(), "b": pyarrow.string()}))
+ for batch in reader:
+ if _check_rows is not None and n >= _check_rows:
+ break
+ n += batch.num_rows
+ for c, out in (("a", src), ("b", tgt)):
+ col = batch.column(c)
+ u = pc.unique(col)
+ ids = numpy.array([concepts.setdefault(x, len(concepts))
+ for x in u.to_pylist()], dtype="int64")
+ out.append(ids[pc.index_in(col, value_set=u).to_numpy()])
+ col = batch.column("type")
+ u = pc.unique(col)
+ ids = numpy.array([types.setdefault(x, len(types))
+ for x in u.to_pylist()], dtype="int8")
+ etype.append(ids[pc.index_in(col, value_set=u).to_numpy()])
+ pmid.append(batch.column("pmid").to_numpy())
+ g = Graph(directed=True)
+ g.add_vertex(len(concepts))
+ src = numpy.concatenate(src)
+ tgt = numpy.concatenate(tgt)
+ g.add_edge_list(numpy.column_stack([src, tgt]))
+ del src, tgt
+ keys = list(concepts.keys())
+ del concepts
+ g.vp.concept = g.new_vp("string", vals=keys)
+ g.vp.kind = g.new_vp("string", vals=[k.partition("|")[0] for k in keys])
+ del keys
+ labels = list(types.keys())
+ codes = g.new_ep("int8_t", vals=numpy.concatenate(etype))
+ del etype
+ p = g.new_ep("string")
+ map_property_values(codes, p, lambda i: labels[i])
+ g.ep.type = p
+ del codes
+ g.ep.pmid = g.new_ep("int64_t", vals=numpy.concatenate(pmid))
+ yield None, g