pyobo 0.12.9__py3-none-any.whl → 0.12.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyobo/ner/scispacy_utils.py +15 -21
- pyobo/struct/struct.py +40 -0
- pyobo/version.py +1 -1
- {pyobo-0.12.9.dist-info → pyobo-0.12.10.dist-info}/METADATA +1 -1
- {pyobo-0.12.9.dist-info → pyobo-0.12.10.dist-info}/RECORD +8 -8
- {pyobo-0.12.9.dist-info → pyobo-0.12.10.dist-info}/WHEEL +0 -0
- {pyobo-0.12.9.dist-info → pyobo-0.12.10.dist-info}/entry_points.txt +0 -0
- {pyobo-0.12.9.dist-info → pyobo-0.12.10.dist-info}/licenses/LICENSE +0 -0
pyobo/ner/scispacy_utils.py
CHANGED
|
@@ -9,7 +9,7 @@ entity linking (also called named entity normalization (NEN) or grounding) in
|
|
|
9
9
|
Constructing a Lexical Index
|
|
10
10
|
============================
|
|
11
11
|
|
|
12
|
-
An *ad hoc*
|
|
12
|
+
An *ad hoc* ScispaCy lexical index can be constructed on-the-fly by passing a
|
|
13
13
|
Bioregistry prefix to :func:`pyobo.get_scispacy_knowledgebase`. In the following
|
|
14
14
|
example, the prefix ``to`` is used to construct a lexical index for the `Plant Trait
|
|
15
15
|
Ontology <https://bioregistry.io/to>`_.
|
|
@@ -74,7 +74,7 @@ process in the correctly versioned folder in the PyOBO cache.
|
|
|
74
74
|
import pyobo
|
|
75
75
|
from scispacy.linking import EntityLinker
|
|
76
76
|
|
|
77
|
-
linker = pyobo.get_scispacy_entity_linker("hgnc", filter_for_definitions=False)
|
|
77
|
+
linker: EntityLinker = pyobo.get_scispacy_entity_linker("hgnc", filter_for_definitions=False)
|
|
78
78
|
|
|
79
79
|
Full Workflow
|
|
80
80
|
=============
|
|
@@ -128,7 +128,7 @@ highly scored groundings, the best of which, `hgnc:391
|
|
|
128
128
|
|
|
129
129
|
.. note::
|
|
130
130
|
|
|
131
|
-
The groundings and scores are stored by
|
|
131
|
+
The groundings and scores are stored by ScispaCy in the hidden attribute
|
|
132
132
|
``span._.kb_ents``.
|
|
133
133
|
"""
|
|
134
134
|
|
|
@@ -162,12 +162,10 @@ def get_scispacy_entity_linker(
|
|
|
162
162
|
candidate_generator_kwargs: dict[str, Any] | None = None,
|
|
163
163
|
**entity_linker_kwargs: Any,
|
|
164
164
|
) -> EntityLinker:
|
|
165
|
-
"""Get
|
|
166
|
-
|
|
167
|
-
:param prefix :
|
|
168
|
-
The ontology's prefix, such as ``go` for Gene Ontology, ``doid`` for the Disease
|
|
169
|
-
Ontology, or more.
|
|
165
|
+
"""Get an entity linker for usage with :mod:`scispacy`.
|
|
170
166
|
|
|
167
|
+
:param prefix: The ontology's prefix, such as ``go` for Gene Ontology, ``doid`` for
|
|
168
|
+
the Disease Ontology, or more.
|
|
171
169
|
:param ontology_kwargs: keyword arguments to pass to :func:`pyobo.get_ontology`,
|
|
172
170
|
such as ``version``.
|
|
173
171
|
:param candidate_generator_kwargs: keyword arguments to pass to
|
|
@@ -199,14 +197,12 @@ def get_scispacy_entity_linker(
|
|
|
199
197
|
|
|
200
198
|
|
|
201
199
|
def get_scispacy_knowledgebase(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> KnowledgeBase:
|
|
202
|
-
"""Get a
|
|
200
|
+
"""Get a lexical index for usage with :mod:`scispacy`.
|
|
203
201
|
|
|
204
|
-
:param prefix
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
:param kwargs :
|
|
209
|
-
keyword arguments to pass to :func:`pyobo.get_ontology`, such as ``version``.
|
|
202
|
+
:param prefix: The ontology's prefix, such as ``go` for Gene Ontology, ``doid`` for
|
|
203
|
+
the Disease Ontology, or more.
|
|
204
|
+
:param kwargs: keyword arguments to pass to :func:`pyobo.get_ontology`, such as
|
|
205
|
+
``version``.
|
|
210
206
|
|
|
211
207
|
:returns: An object that represents a lexical index over name, synonym, and
|
|
212
208
|
definition strings from the ontology.
|
|
@@ -219,12 +215,10 @@ def get_scispacy_knowledgebase(prefix: str, **kwargs: Unpack[GetOntologyKwargs])
|
|
|
219
215
|
def get_scispacy_entities(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> Iterable[Entity]:
|
|
220
216
|
"""Iterate over entities in a given ontology via :mod:`pyobo`.
|
|
221
217
|
|
|
222
|
-
:param prefix
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
:param kwargs :
|
|
227
|
-
keyword arguments to pass to :func:`pyobo.get_ontology`, such as ``version``.
|
|
218
|
+
:param prefix: The ontology's prefix, such as ``go` for Gene Ontology, ``doid`` for
|
|
219
|
+
the Disease Ontology, or more.
|
|
220
|
+
:param kwargs: keyword arguments to pass to :func:`pyobo.get_ontology`, such as
|
|
221
|
+
``version``.
|
|
228
222
|
|
|
229
223
|
:yields: Entity objects for all terms in the ontology
|
|
230
224
|
"""
|
pyobo/struct/struct.py
CHANGED
|
@@ -1903,6 +1903,46 @@ class Obo:
|
|
|
1903
1903
|
"""Get a mapping from identifiers to a list of sorted synonym strings."""
|
|
1904
1904
|
return multidict(self.iterate_synonym_rows(use_tqdm=use_tqdm))
|
|
1905
1905
|
|
|
1906
|
+
def get_grounder(self) -> ssslm.Grounder:
|
|
1907
|
+
"""Get a grounder from this ontology.
|
|
1908
|
+
|
|
1909
|
+
:returns: An object that can be used for named entity recognition and named
|
|
1910
|
+
entity normalization
|
|
1911
|
+
|
|
1912
|
+
Here's example usage for a built-in ontology:
|
|
1913
|
+
|
|
1914
|
+
.. code-block:: python
|
|
1915
|
+
|
|
1916
|
+
import pyobo
|
|
1917
|
+
import ssslm
|
|
1918
|
+
|
|
1919
|
+
ontology = pyobo.get_ontology("taxrank")
|
|
1920
|
+
grounder: ssslm.Grounder = ontology.get_grounder()
|
|
1921
|
+
matches: list[ssslm.Match] = grounder.ground("species")
|
|
1922
|
+
|
|
1923
|
+
Here's example usage for a custom ontology:
|
|
1924
|
+
|
|
1925
|
+
.. code-block:: python
|
|
1926
|
+
|
|
1927
|
+
import pyobo
|
|
1928
|
+
import ssslm
|
|
1929
|
+
from urllib.request import urlretrieve
|
|
1930
|
+
|
|
1931
|
+
url = "http://purl.obolibrary.org/obo/taxrank.obo"
|
|
1932
|
+
path = "taxrank.obo"
|
|
1933
|
+
urlretrieve(url, path)
|
|
1934
|
+
|
|
1935
|
+
ontology = pyobo.from_obo_path(path, prefix="taxrank")
|
|
1936
|
+
grounder: ssslm.Grounder = ontology.get_grounder()
|
|
1937
|
+
matches: list[ssslm.Match] = grounder.get_matches("species")
|
|
1938
|
+
|
|
1939
|
+
.. warning::
|
|
1940
|
+
|
|
1941
|
+
It's required to tell PyOBO the prefix for a custom ontology when using
|
|
1942
|
+
:func:`pyobo.from_obo_path`, and it must be registered in the Bioregistry
|
|
1943
|
+
"""
|
|
1944
|
+
return ssslm.make_grounder(self.get_literal_mappings())
|
|
1945
|
+
|
|
1906
1946
|
def get_literal_mappings(self) -> Iterable[ssslm.LiteralMapping]:
|
|
1907
1947
|
"""Get literal mappings in a standard data model."""
|
|
1908
1948
|
stanzas: Iterable[Stanza] = itt.chain(self, self.typedefs or [])
|
pyobo/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobo
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.10
|
|
4
4
|
Summary: A python package for handling and generating OBO
|
|
5
5
|
Keywords: snekpack,cookiecutter,ontologies,biomedical ontologies,life sciences,natural sciences,bioinformatics,cheminformatics,Open Biomedical Ontologies,OBO
|
|
6
6
|
Author: Charles Tapley Hoyt
|
|
@@ -36,7 +36,7 @@ pyobo/mocks.py,sha256=j545K9P_DPsDBuYHDrhyTLjmlPoNlRdEtcRlLhXlbXI,2440
|
|
|
36
36
|
pyobo/ner/__init__.py,sha256=7Os84d8_gZktUxyUW9Tn2dW33rYFWSO8cviJJef-ZeE,373
|
|
37
37
|
pyobo/ner/api.py,sha256=s0MJgz6sj13qiB1TEyO_aC8103fgnYBwZroRgygpZNw,2167
|
|
38
38
|
pyobo/ner/normalizer.py,sha256=pdvwFG9elriK83FKqjQfT2s-ZuC-QZZuMPudjfay21w,954
|
|
39
|
-
pyobo/ner/scispacy_utils.py,sha256=
|
|
39
|
+
pyobo/ner/scispacy_utils.py,sha256=4NRGJ1JJB-OmlVthHhyms1iPMwJYrkVMQP1jgZfJ18U,8170
|
|
40
40
|
pyobo/plugins.py,sha256=wEr-NpyZ7Z6uEr0uGDNOeXLOGZokGbFmo3e-z2PNKJM,1232
|
|
41
41
|
pyobo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
42
|
pyobo/resource_utils.py,sha256=bloSKbHfMLz0hB8AkhMkfLOGqw6FyO8CEU6LNg0PVMk,4406
|
|
@@ -190,7 +190,7 @@ pyobo/struct/obograph/export.py,sha256=yk3MHulDM_SMohfwiFdeB62-XGJ2ZNgRUZGjGjiyo
|
|
|
190
190
|
pyobo/struct/obograph/reader.py,sha256=264yVeD8a3jGx9EaGUZVxFbSQ_pwQ_6ckVw9S8wiJfM,8525
|
|
191
191
|
pyobo/struct/obograph/utils.py,sha256=je0kSkC24MU9pWRHq1_K-J5jWhjWESY6NI3TpZqvZ_Q,1516
|
|
192
192
|
pyobo/struct/reference.py,sha256=qgwTa-0VIoDklQ7LjlYH-mf2WG0_uO7KlHt0PSBail4,11744
|
|
193
|
-
pyobo/struct/struct.py,sha256=
|
|
193
|
+
pyobo/struct/struct.py,sha256=0is3zpmLQoH8XNVKPDAOqYlQ7IIL7Xr7onx6auLjYJA,95115
|
|
194
194
|
pyobo/struct/struct_utils.py,sha256=_D689bNlGg1_r-4vQQ-imVEOxzq95XBqBFxqFMV077U,40346
|
|
195
195
|
pyobo/struct/typedef.py,sha256=iLm8-DVY0v_dK_RwoNKCeOF7nI6XlaieS2CaCHePSlI,13088
|
|
196
196
|
pyobo/struct/utils.py,sha256=zkpOE42JQIfkN0rc5qNENK03VIKmkf_57tHojMJK71Y,906
|
|
@@ -202,9 +202,9 @@ pyobo/utils/iter.py,sha256=rYRbbaFJHxMaE0yU-rQZoCagYIrtev09uY0mxFkf5zY,1524
|
|
|
202
202
|
pyobo/utils/misc.py,sha256=499pencyDqW9_xm0H0Cq0FhOw0MoNoq-9IVQTKh-eaE,7992
|
|
203
203
|
pyobo/utils/ndex_utils.py,sha256=EokCWS00Wrk_4y8ldeQuUyaaC6yNzBg3DagUl-J2czY,2326
|
|
204
204
|
pyobo/utils/path.py,sha256=Ep8lTRWgFU9_XF5vqJV5B3G4PcUBglIitMkaUNxjzvo,4091
|
|
205
|
-
pyobo/version.py,sha256=
|
|
206
|
-
pyobo-0.12.
|
|
207
|
-
pyobo-0.12.
|
|
208
|
-
pyobo-0.12.
|
|
209
|
-
pyobo-0.12.
|
|
210
|
-
pyobo-0.12.
|
|
205
|
+
pyobo/version.py,sha256=r3VLmEhyOat5T5vXiDW6v0isg_jC5J9BzcsOTJg1OxY,927
|
|
206
|
+
pyobo-0.12.10.dist-info/licenses/LICENSE,sha256=QcgJZKGxlW5BwBNnCBL8VZLVtRvXs81Ch9lJRQSIpJg,1076
|
|
207
|
+
pyobo-0.12.10.dist-info/WHEEL,sha256=Pi5uDq5Fdo_Rr-HD5h9BiPn9Et29Y9Sh8NhcJNnFU1c,79
|
|
208
|
+
pyobo-0.12.10.dist-info/entry_points.txt,sha256=ANgzvuwF_9_1ipCoxJtbBM6A4i2Mkt39gMPzQO6hvGs,42
|
|
209
|
+
pyobo-0.12.10.dist-info/METADATA,sha256=PdeYdweM7uV4yHveuaDqAyD_sS7Xh3PIT9kUwZ8Kycw,22096
|
|
210
|
+
pyobo-0.12.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|