pyobo 0.10.12__py3-none-any.whl → 0.11.0__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.
Files changed (151) hide show
  1. pyobo/__init__.py +0 -2
  2. pyobo/__main__.py +0 -2
  3. pyobo/api/__init__.py +0 -2
  4. pyobo/api/alts.py +6 -7
  5. pyobo/api/hierarchy.py +14 -15
  6. pyobo/api/metadata.py +3 -4
  7. pyobo/api/names.py +31 -32
  8. pyobo/api/properties.py +6 -7
  9. pyobo/api/relations.py +12 -11
  10. pyobo/api/species.py +5 -6
  11. pyobo/api/typedefs.py +1 -3
  12. pyobo/api/utils.py +61 -5
  13. pyobo/api/xrefs.py +4 -5
  14. pyobo/aws.py +3 -5
  15. pyobo/cli/__init__.py +0 -2
  16. pyobo/cli/aws.py +0 -2
  17. pyobo/cli/cli.py +0 -4
  18. pyobo/cli/database.py +1 -3
  19. pyobo/cli/lookup.py +0 -2
  20. pyobo/cli/utils.py +0 -2
  21. pyobo/constants.py +0 -33
  22. pyobo/getters.py +19 -26
  23. pyobo/gilda_utils.py +9 -10
  24. pyobo/identifier_utils.py +10 -10
  25. pyobo/mocks.py +5 -6
  26. pyobo/normalizer.py +24 -24
  27. pyobo/obographs.py +3 -3
  28. pyobo/plugins.py +3 -4
  29. pyobo/py.typed +0 -0
  30. pyobo/reader.py +19 -21
  31. pyobo/registries/__init__.py +0 -2
  32. pyobo/registries/metaregistry.py +6 -8
  33. pyobo/resource_utils.py +1 -3
  34. pyobo/resources/__init__.py +0 -2
  35. pyobo/resources/ncbitaxon.py +2 -3
  36. pyobo/resources/ro.py +2 -4
  37. pyobo/sources/README.md +15 -0
  38. pyobo/sources/__init__.py +0 -2
  39. pyobo/sources/agrovoc.py +3 -3
  40. pyobo/sources/antibodyregistry.py +2 -3
  41. pyobo/sources/biogrid.py +4 -4
  42. pyobo/sources/ccle.py +3 -4
  43. pyobo/sources/cgnc.py +1 -3
  44. pyobo/sources/chebi.py +2 -4
  45. pyobo/sources/chembl.py +1 -3
  46. pyobo/sources/civic_gene.py +2 -3
  47. pyobo/sources/complexportal.py +3 -5
  48. pyobo/sources/conso.py +2 -4
  49. pyobo/sources/cpt.py +1 -3
  50. pyobo/sources/credit.py +1 -1
  51. pyobo/sources/cvx.py +1 -3
  52. pyobo/sources/depmap.py +3 -4
  53. pyobo/sources/dictybase_gene.py +1 -3
  54. pyobo/sources/drugbank.py +6 -7
  55. pyobo/sources/drugbank_salt.py +3 -4
  56. pyobo/sources/drugcentral.py +5 -7
  57. pyobo/sources/expasy.py +11 -12
  58. pyobo/sources/famplex.py +3 -5
  59. pyobo/sources/flybase.py +2 -4
  60. pyobo/sources/geonames.py +1 -1
  61. pyobo/sources/gmt_utils.py +5 -6
  62. pyobo/sources/go.py +4 -6
  63. pyobo/sources/gwascentral_phenotype.py +1 -3
  64. pyobo/sources/gwascentral_study.py +2 -3
  65. pyobo/sources/hgnc.py +6 -7
  66. pyobo/sources/hgncgenefamily.py +2 -4
  67. pyobo/sources/icd10.py +3 -4
  68. pyobo/sources/icd11.py +3 -4
  69. pyobo/sources/icd_utils.py +6 -7
  70. pyobo/sources/interpro.py +3 -5
  71. pyobo/sources/itis.py +1 -3
  72. pyobo/sources/kegg/__init__.py +0 -2
  73. pyobo/sources/kegg/api.py +3 -4
  74. pyobo/sources/kegg/genes.py +3 -4
  75. pyobo/sources/kegg/genome.py +1 -3
  76. pyobo/sources/kegg/pathway.py +5 -6
  77. pyobo/sources/mesh.py +19 -21
  78. pyobo/sources/mgi.py +1 -3
  79. pyobo/sources/mirbase.py +4 -6
  80. pyobo/sources/mirbase_constants.py +0 -2
  81. pyobo/sources/mirbase_family.py +1 -3
  82. pyobo/sources/mirbase_mature.py +1 -3
  83. pyobo/sources/msigdb.py +4 -5
  84. pyobo/sources/ncbigene.py +3 -5
  85. pyobo/sources/npass.py +1 -3
  86. pyobo/sources/omim_ps.py +1 -3
  87. pyobo/sources/pathbank.py +3 -5
  88. pyobo/sources/pfam.py +1 -3
  89. pyobo/sources/pfam_clan.py +1 -3
  90. pyobo/sources/pid.py +3 -5
  91. pyobo/sources/pombase.py +1 -3
  92. pyobo/sources/pubchem.py +2 -3
  93. pyobo/sources/reactome.py +2 -4
  94. pyobo/sources/rgd.py +2 -3
  95. pyobo/sources/rhea.py +7 -8
  96. pyobo/sources/ror.py +3 -2
  97. pyobo/sources/selventa/__init__.py +0 -2
  98. pyobo/sources/selventa/schem.py +1 -3
  99. pyobo/sources/selventa/scomp.py +1 -3
  100. pyobo/sources/selventa/sdis.py +1 -3
  101. pyobo/sources/selventa/sfam.py +1 -3
  102. pyobo/sources/sgd.py +1 -3
  103. pyobo/sources/slm.py +1 -3
  104. pyobo/sources/umls/__init__.py +0 -2
  105. pyobo/sources/umls/__main__.py +0 -2
  106. pyobo/sources/umls/get_synonym_types.py +1 -1
  107. pyobo/sources/umls/umls.py +2 -4
  108. pyobo/sources/uniprot/__init__.py +0 -2
  109. pyobo/sources/uniprot/uniprot.py +4 -4
  110. pyobo/sources/uniprot/uniprot_ptm.py +6 -5
  111. pyobo/sources/utils.py +3 -5
  112. pyobo/sources/wikipathways.py +1 -3
  113. pyobo/sources/zfin.py +2 -3
  114. pyobo/ssg/__init__.py +3 -2
  115. pyobo/struct/__init__.py +0 -2
  116. pyobo/struct/reference.py +13 -15
  117. pyobo/struct/struct.py +102 -96
  118. pyobo/struct/typedef.py +9 -10
  119. pyobo/struct/utils.py +0 -2
  120. pyobo/utils/__init__.py +0 -2
  121. pyobo/utils/cache.py +14 -6
  122. pyobo/utils/io.py +9 -10
  123. pyobo/utils/iter.py +5 -6
  124. pyobo/utils/misc.py +1 -3
  125. pyobo/utils/ndex_utils.py +6 -7
  126. pyobo/utils/path.py +4 -5
  127. pyobo/version.py +3 -5
  128. pyobo/xrefdb/__init__.py +0 -2
  129. pyobo/xrefdb/canonicalizer.py +27 -18
  130. pyobo/xrefdb/priority.py +0 -2
  131. pyobo/xrefdb/sources/__init__.py +3 -4
  132. pyobo/xrefdb/sources/biomappings.py +0 -2
  133. pyobo/xrefdb/sources/cbms2019.py +0 -2
  134. pyobo/xrefdb/sources/chembl.py +0 -2
  135. pyobo/xrefdb/sources/compath.py +1 -3
  136. pyobo/xrefdb/sources/famplex.py +3 -5
  137. pyobo/xrefdb/sources/gilda.py +0 -2
  138. pyobo/xrefdb/sources/intact.py +5 -5
  139. pyobo/xrefdb/sources/ncit.py +1 -3
  140. pyobo/xrefdb/sources/pubchem.py +2 -5
  141. pyobo/xrefdb/sources/wikidata.py +2 -4
  142. pyobo/xrefdb/xrefs_pipeline.py +15 -16
  143. {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/LICENSE +1 -1
  144. pyobo-0.11.0.dist-info/METADATA +723 -0
  145. pyobo-0.11.0.dist-info/RECORD +171 -0
  146. {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/WHEEL +1 -1
  147. pyobo-0.11.0.dist-info/entry_points.txt +2 -0
  148. pyobo-0.10.12.dist-info/METADATA +0 -499
  149. pyobo-0.10.12.dist-info/RECORD +0 -169
  150. pyobo-0.10.12.dist-info/entry_points.txt +0 -15
  151. {pyobo-0.10.12.dist-info → pyobo-0.11.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,723 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyobo
3
+ Version: 0.11.0
4
+ Summary: A python package for handling and generating OBO
5
+ Author-email: Charles Tapley Hoyt <cthoyt@gmail.com>
6
+ Maintainer-email: Charles Tapley Hoyt <cthoyt@gmail.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2024 Charles Tapley Hoyt
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: Bug Tracker, https://github.com/biopragmatics/pyobo/issues
30
+ Project-URL: Homepage, https://github.com/biopragmatics/pyobo
31
+ Project-URL: Repository, https://github.com/biopragmatics/pyobo.git
32
+ Project-URL: Documentation, https://pyobo.readthedocs.io
33
+ Keywords: snekpack,cookiecutter,ontologies,biomedical ontologies,life sciences,natural sciences,bioinformatics,cheminformatics,Open Biomedical Ontologies,OBO
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: OS Independent
39
+ Classifier: Framework :: Pytest
40
+ Classifier: Framework :: tox
41
+ Classifier: Framework :: Sphinx
42
+ Classifier: Programming Language :: Python
43
+ Classifier: Programming Language :: Python :: 3.9
44
+ Classifier: Programming Language :: Python :: 3.10
45
+ Classifier: Programming Language :: Python :: 3.11
46
+ Classifier: Programming Language :: Python :: 3.12
47
+ Classifier: Programming Language :: Python :: 3 :: Only
48
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
49
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
50
+ Requires-Python: >=3.9
51
+ Description-Content-Type: text/markdown
52
+ License-File: LICENSE
53
+ Requires-Dist: obonet >=0.3.0
54
+ Requires-Dist: click
55
+ Requires-Dist: tqdm
56
+ Requires-Dist: pyyaml
57
+ Requires-Dist: pandas
58
+ Requires-Dist: requests
59
+ Requires-Dist: protmapper
60
+ Requires-Dist: more-itertools
61
+ Requires-Dist: more-click >=0.0.2
62
+ Requires-Dist: humanize
63
+ Requires-Dist: tabulate
64
+ Requires-Dist: cachier
65
+ Requires-Dist: pystow >=0.2.7
66
+ Requires-Dist: bioversions >=0.5.514
67
+ Requires-Dist: bioregistry >=0.10.20
68
+ Requires-Dist: bioontologies >=0.4.0
69
+ Requires-Dist: zenodo-client >=0.0.5
70
+ Requires-Dist: class-resolver
71
+ Requires-Dist: psycopg2-binary
72
+ Requires-Dist: pydantic >=2.0
73
+ Requires-Dist: drugbank-downloader
74
+ Requires-Dist: chembl-downloader
75
+ Requires-Dist: umls-downloader >=0.1.3
76
+ Requires-Dist: typing-extensions
77
+ Requires-Dist: rdflib
78
+ Provides-Extra: docs
79
+ Requires-Dist: sphinx >=8 ; extra == 'docs'
80
+ Requires-Dist: sphinx-rtd-theme >=3.0 ; extra == 'docs'
81
+ Requires-Dist: sphinx-click ; extra == 'docs'
82
+ Requires-Dist: sphinx-automodapi ; extra == 'docs'
83
+ Provides-Extra: tests
84
+ Requires-Dist: pytest ; extra == 'tests'
85
+ Requires-Dist: coverage ; extra == 'tests'
86
+
87
+ <!--
88
+ <p align="center">
89
+ <img src="https://github.com/biopragmatics/pyobo/raw/main/docs/source/logo.png" height="150">
90
+ </p>
91
+ -->
92
+
93
+ <h1 align="center">
94
+ PyOBO
95
+ </h1>
96
+
97
+ <p align="center">
98
+ <a href="https://github.com/biopragmatics/pyobo/actions/workflows/tests.yml">
99
+ <img alt="Tests" src="https://github.com/biopragmatics/pyobo/actions/workflows/tests.yml/badge.svg" /></a>
100
+ <a href="https://pypi.org/project/pyobo">
101
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/pyobo" /></a>
102
+ <a href="https://pypi.org/project/pyobo">
103
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/pyobo" /></a>
104
+ <a href="https://github.com/biopragmatics/pyobo/blob/main/LICENSE">
105
+ <img alt="PyPI - License" src="https://img.shields.io/pypi/l/pyobo" /></a>
106
+ <a href='https://pyobo.readthedocs.io/en/latest/?badge=latest'>
107
+ <img src='https://readthedocs.org/projects/pyobo/badge/?version=latest' alt='Documentation Status' /></a>
108
+ <a href="https://codecov.io/gh/biopragmatics/pyobo/branch/main">
109
+ <img src="https://codecov.io/gh/biopragmatics/pyobo/branch/main/graph/badge.svg" alt="Codecov status" /></a>
110
+ <a href="https://github.com/cthoyt/cookiecutter-python-package">
111
+ <img alt="Cookiecutter template from @cthoyt" src="https://img.shields.io/badge/Cookiecutter-snekpack-blue" /></a>
112
+ <a href='https://github.com/psf/black'>
113
+ <img src='https://img.shields.io/badge/code%20style-black-000000.svg' alt='Code style: black' /></a>
114
+ <a href="https://github.com/biopragmatics/pyobo/blob/main/.github/CODE_OF_CONDUCT.md">
115
+ <img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Contributor Covenant"/></a>
116
+ </p>
117
+
118
+ Tools for biological identifiers, names, synonyms, xrefs, hierarchies, relations, and properties through the
119
+ perspective of OBO.
120
+
121
+ ## Example Usage
122
+
123
+ Note! PyOBO is no-nonsense. This means that there's no repetitive
124
+ prefixes in identifiers. It also means all identifiers are strings,
125
+ no exceptions.
126
+
127
+ Note! The first time you run these, they have to download and cache
128
+ all resources. We're not in the business of redistributing data,
129
+ so all scripts should be completely reproducible. There's some
130
+ AWS tools for hosting/downloading pre-compiled versions in
131
+ `pyobo.aws` if you don't have time for that.
132
+
133
+ Note! PyOBO can perform grounding in a limited number of cases, but
134
+ it is *not* a general solution for named entity recognition (NER) or grounding.
135
+ It's suggested to check `Gilda <https://github.com/indralab/gilda>`_
136
+ for a no-nonsense solution.
137
+
138
+ ### Mapping Identifiers and CURIEs
139
+
140
+ Get mapping of ChEBI identifiers to names:
141
+
142
+ ```python
143
+ import pyobo
144
+
145
+ chebi_id_to_name = pyobo.get_id_name_mapping('chebi')
146
+
147
+ name = chebi_id_to_name['132964']
148
+ assert name == 'fluazifop-P-butyl'
149
+ ```
150
+
151
+ Or, you don't have time for two lines:
152
+
153
+ ```python
154
+ import pyobo
155
+
156
+ name = pyobo.get_name('chebi', '132964')
157
+ assert name == 'fluazifop-P-butyl'
158
+ ```
159
+
160
+ Get reverse mapping of ChEBI names to identifiers:
161
+
162
+ ```python
163
+ import pyobo
164
+
165
+ chebi_name_to_id = pyobo.get_name_id_mapping('chebi')
166
+
167
+ identifier = chebi_name_to_id['fluazifop-P-butyl']
168
+ assert identifier == '132964'
169
+ ```
170
+
171
+ Maybe you live in CURIE world and just want to normalize something like
172
+ `CHEBI:132964`:
173
+
174
+ ```python
175
+ import pyobo
176
+
177
+ name = pyobo.get_name_by_curie('CHEBI:132964')
178
+ assert name == 'fluazifop-P-butyl'
179
+ ```
180
+
181
+ Sometimes you accidentally got an old CURIE. It can be mapped to the more recent
182
+ one using alternative identifiers listed in the underlying OBO with:
183
+
184
+ ```python
185
+ import pyobo
186
+
187
+ # Look up DNA-binding transcription factor activity (go:0003700)
188
+ # based on an old id
189
+ primary_curie = pyobo.get_primary_curie('go:0001071')
190
+ assert primary_curie == 'go:0003700'
191
+
192
+ # If it's already the primary, it just gets returned
193
+ assert 'go:0003700' == pyobo.get_priority_curie('go:0003700')
194
+ ```
195
+
196
+ ### Mapping Species
197
+
198
+ Some resources have species information for their term. Get a mapping of WikiPathway identifiers
199
+ to species (as NCBI taxonomy identifiers):
200
+
201
+ ```python
202
+ import pyobo
203
+
204
+ wikipathways_id_to_species = pyobo.get_id_species_mapping('wikipathways')
205
+
206
+ # Apoptosis (Homo sapiens)
207
+ taxonomy_id = wikipathways_id_to_species['WP254']
208
+ assert taxonomy_id == '9606'
209
+ ```
210
+
211
+ Or, you don't have time for two lines:
212
+
213
+ ```python
214
+ import pyobo
215
+
216
+ # Apoptosis (Homo sapiens)
217
+ taxonomy_id = pyobo.get_species('wikipathways', 'WP254')
218
+ assert taxonomy_id == '9606'
219
+ ```
220
+
221
+ ### Grounding
222
+
223
+ Maybe you've got names/synonyms you want to try and map back to ChEBI synonyms.
224
+ Given the brand name `Fusilade II` of `CHEBI:132964`, it should be able to look
225
+ it up and its preferred label.
226
+
227
+ ```python
228
+ import pyobo
229
+
230
+ prefix, identifier, name = pyobo.ground('chebi', 'Fusilade II')
231
+ assert prefix == 'chebi'
232
+ assert identifier == '132964'
233
+ assert name == 'fluazifop-P-butyl'
234
+
235
+ # When failure happens...
236
+ prefix, identifier, name = pyobo.ground('chebi', 'Definitely not a real name')
237
+ assert prefix is None
238
+ assert identifier is None
239
+ assert name is None
240
+ ```
241
+
242
+ If you're not really sure which namespace a name might belong to, you
243
+ can try a few in a row (prioritize by ones that cover the appropriate
244
+ entity type to avoid false positives in case of conflicts):
245
+
246
+ ```python
247
+ import pyobo
248
+
249
+ # looking for phenotypes/pathways
250
+ prefix, identifier, name = pyobo.ground(['efo', 'go'], 'ERAD')
251
+ assert prefix == 'go'
252
+ assert identifier == '0030433'
253
+ assert name == 'ubiquitin-dependent ERAD pathway'
254
+ ```
255
+
256
+ ### Cross-referencing
257
+
258
+ Get xrefs from ChEBI to PubChem:
259
+
260
+ ```python
261
+ import pyobo
262
+
263
+ chebi_id_to_pubchem_compound_id = pyobo.get_filtered_xrefs('chebi', 'pubchem.compound')
264
+
265
+ pubchem_compound_id = chebi_id_to_pubchem_compound_id['132964']
266
+ assert pubchem_compound_id == '3033674'
267
+ ```
268
+
269
+ If you don't have time for two lines:
270
+
271
+ ```python
272
+ import pyobo
273
+
274
+ pubchem_compound_id = pyobo.get_xref('chebi', '132964', 'pubchem.compound')
275
+ assert pubchem_compound_id == '3033674'
276
+ ```
277
+
278
+ Get xrefs from Entrez to HGNC, but they're only available through HGNC,
279
+ so you need to flip them:
280
+
281
+ ```python
282
+ import pyobo
283
+
284
+ hgnc_id_to_ncbigene_id = pyobo.get_filtered_xrefs('hgnc', 'ncbigene')
285
+ ncbigene_id_to_hgnc_id = {
286
+ ncbigene_id: hgnc_id
287
+ for hgnc_id, ncbigene_id in hgnc_id_to_ncbigene_id.items()
288
+ }
289
+ mapt_hgnc = ncbigene_id_to_hgnc_id['4137']
290
+ assert mapt_hgnc == '6893'
291
+ ```
292
+
293
+ Since this is a common pattern, there's a keyword argument `flip`
294
+ that does this for you:
295
+
296
+ ```python
297
+ import pyobo
298
+
299
+ ncbigene_id_to_hgnc_id = pyobo.get_filtered_xrefs('hgnc', 'ncbigene', flip=True)
300
+ mapt_hgnc_id = ncbigene_id_to_hgnc_id['4137']
301
+ assert mapt_hgnc_id == '6893'
302
+ ```
303
+
304
+ If you don't have time for two lines (I admit this one is a bit confusing) and
305
+ need to flip it:
306
+
307
+ ```python
308
+ import pyobo
309
+
310
+ hgnc_id = pyobo.get_xref('hgnc', '4137', 'ncbigene', flip=True)
311
+ assert hgnc_id == '6893'
312
+ ```
313
+
314
+ Remap a CURIE based on pre-defined priority list and [Inspector Javert's Xref
315
+ Database](https://cthoyt.com/2020/04/19/inspector-javerts-xref-database.html):
316
+
317
+ ```python
318
+
319
+ import pyobo
320
+
321
+ # Map to the best source possible
322
+ mapt_ncbigene = pyobo.get_priority_curie('hgnc:6893')
323
+ assert mapt_ncbigene == 'ncbigene:4137'
324
+
325
+ # Sometimes you know you're the best. Own it.
326
+ assert 'ncbigene:4137' == pyobo.get_priority_curie('ncbigene:4137')
327
+ ```
328
+
329
+ Find all CURIEs mapped to a given one using Inspector Javert's Xref Database:
330
+
331
+ ```python
332
+ import pyobo
333
+
334
+ # Get a set of all CURIEs mapped to MAPT
335
+ mapt_curies = pyobo.get_equivalent('hgnc:6893')
336
+ assert 'ncbigene:4137' in mapt_curies
337
+ assert 'ensembl:ENSG00000186868' in mapt_curies
338
+ ```
339
+
340
+ If you don't want to wait to build the database locally for the `pyobo.get_priority_curie` and
341
+ `pyobo.get_equivalent`, you can use the following code to download a release from
342
+ [Zenodo](https://zenodo.org/record/3757266):
343
+
344
+ ```python
345
+ import pyobo.resource_utils
346
+
347
+ pyobo.resource_utils.ensure_inspector_javert()
348
+ ```
349
+
350
+ ### Properties
351
+
352
+ Get properties, like SMILES. The semantics of these are defined on an OBO-OBO basis.
353
+
354
+ ```python
355
+ import pyobo
356
+
357
+ # I don't make the rules. I wouldn't have chosen this as the key for this property. It could be any string
358
+ chebi_smiles_property = 'http://purl.obolibrary.org/obo/chebi/smiles'
359
+ chebi_id_to_smiles = pyobo.get_filtered_properties_mapping('chebi', chebi_smiles_property)
360
+
361
+ smiles = chebi_id_to_smiles['132964']
362
+ assert smiles == 'C1(=CC=C(N=C1)OC2=CC=C(C=C2)O[C@@H](C(OCCCC)=O)C)C(F)(F)F'
363
+ ```
364
+
365
+ If you don't have time for two lines:
366
+
367
+ ```python
368
+ import pyobo
369
+
370
+ smiles = pyobo.get_property('chebi', '132964', 'http://purl.obolibrary.org/obo/chebi/smiles')
371
+ assert smiles == 'C1(=CC=C(N=C1)OC2=CC=C(C=C2)O[C@@H](C(OCCCC)=O)C)C(F)(F)F'
372
+ ```
373
+
374
+ ### Hierarchy
375
+
376
+ Check if an entity is in the hierarchy:
377
+
378
+ ```python
379
+ import networkx as nx
380
+ import pyobo
381
+
382
+ # check that go:0008219 ! cell death is an ancestor of go:0006915 ! apoptotic process
383
+ assert 'go:0008219' in pyobo.get_ancestors('go', '0006915')
384
+
385
+ # check that go:0070246 ! natural killer cell apoptotic process is a
386
+ # descendant of go:0006915 ! apoptotic process
387
+ apopototic_process_descendants = pyobo.get_descendants('go', '0006915')
388
+ assert 'go:0070246' in apopototic_process_descendants
389
+ ```
390
+
391
+ Get the sub-hierarchy below a given node:
392
+
393
+ ```python
394
+ import pyobo
395
+
396
+ # get the descendant graph of go:0006915 ! apoptotic process
397
+ apopototic_process_subhierarchy = pyobo.get_subhierarchy('go', '0006915')
398
+
399
+ # check that go:0070246 ! natural killer cell apoptotic process is a
400
+ # descendant of go:0006915 ! apoptotic process through the subhierarchy
401
+ assert 'go:0070246' in apopototic_process_subhierarchy
402
+ ```
403
+
404
+ Get a hierarchy with properties preloaded in the node data dictionaries:
405
+
406
+ ```python
407
+ import pyobo
408
+
409
+ prop = 'http://purl.obolibrary.org/obo/chebi/smiles'
410
+ chebi_hierarchy = pyobo.get_hierarchy('chebi', properties=[prop])
411
+
412
+ assert 'chebi:132964' in chebi_hierarchy
413
+ assert prop in chebi_hierarchy.nodes['chebi:132964']
414
+ assert chebi_hierarchy.nodes['chebi:132964'][prop] == 'C1(=CC=C(N=C1)OC2=CC=C(C=C2)O[C@@H](C(OCCCC)=O)C)C(F)(F)F'
415
+ ```
416
+
417
+ ### Relations
418
+
419
+ Get all orthologies (`ro:HOM0000017`) between HGNC and MGI (note: this is one way)
420
+
421
+ ```python
422
+ >>> import pyobo
423
+ >>> human_mapt_hgnc_id = '6893'
424
+ >>> mouse_mapt_mgi_id = '97180'
425
+ >>> hgnc_mgi_orthology_mapping = pyobo.get_relation_mapping('hgnc', 'ro:HOM0000017', 'mgi')
426
+ >>> assert mouse_mapt_mgi_id == hgnc_mgi_orthology_mapping[human_mapt_hgnc_id]
427
+ ```
428
+
429
+ If you want to do it in one line, use:
430
+
431
+ ```python
432
+
433
+ >>> import pyobo
434
+ >>> human_mapt_hgnc_id = '6893'
435
+ >>> mouse_mapt_mgi_id = '97180'
436
+ >>> assert mouse_mapt_mgi_id == pyobo.get_relation('hgnc', 'ro:HOM0000017', 'mgi', human_mapt_hgnc_id)
437
+ ```
438
+
439
+ ### Writings Tests that Use PyOBO
440
+
441
+ If you're writing your own code that relies on PyOBO, and unit
442
+ testing it (as you should) in a continuous integration setting,
443
+ you've probably realized that loading all of the resources on each
444
+ build is not so fast. In those scenarios, you can use some of the
445
+ pre-build patches like in the following:
446
+
447
+ ```python
448
+ import unittest
449
+ import pyobo
450
+ from pyobo.mocks import get_mock_id_name_mapping
451
+
452
+ mock_id_name_mapping = get_mock_id_name_mapping({
453
+ 'chebi': {
454
+ '132964': 'fluazifop-P-butyl',
455
+ },
456
+ })
457
+
458
+ class MyTestCase(unittest.TestCase):
459
+ def my_test(self):
460
+ with mock_id_name_mapping:
461
+ # use functions directly, or use your functions that wrap them
462
+ pyobo.get_name('chebi', '1234')
463
+ ```
464
+
465
+
466
+ ## Curation of the Bioregistry
467
+
468
+ In order to normalize references and identify resources, PyOBO uses the
469
+ [Bioregistry](https://github.com/bioregistry/bioregistry). It used to be a part of PyOBO, but has since
470
+ been externalized for more general reuse.
471
+
472
+ At [src/pyobo/registries/metaregistry.json](https://github.com/pyobo/pyobo/blob/master/src/pyobo/registries/metaregistry.json)
473
+ is the curated "metaregistry". This is a source of information that contains
474
+ all sorts of fixes for missing/wrong information in MIRIAM, OLS, and OBO Foundry; entries that don't appear in
475
+ any of them; additional synonym information for each namespace/prefix; rules for normalizing xrefs and CURIEs, etc.
476
+
477
+ Other entries in the metaregistry:
478
+
479
+ - The `"remappings"->"full"` entry is a dictionary from strings that might follow `xref:`
480
+ in a given OBO file that need to be completely replaced, due to incorrect formatting
481
+ - The `"remappings"->"prefix"` entry contains a dictionary of prefixes for xrefs that need
482
+ to be remapped. Several rules, for example, remove superfluous spaces that occur inside
483
+ CURIEs or and others address instances of the GOGO issue.
484
+ - The `"blacklists"` entry contains rules for throwing out malformed xrefs based on
485
+ full string, just prefix, or just suffix.
486
+
487
+ ## Troubleshooting
488
+
489
+ The OBO Foundry seems to be pretty unstable with respect to the URLs to OBO resources. If you get an error like:
490
+
491
+ ```
492
+ pyobo.getters.MissingOboBuild: OBO Foundry is missing a build for: mondo
493
+ ```
494
+
495
+ Then you should check the corresponding page on the OBO Foundry (in this case, http://www.obofoundry.org/ontology/mondo.html)
496
+ and make update to the `url` entry for that namespace in the Bioregistry.
497
+
498
+ ## 🚀 Installation
499
+
500
+ The most recent release can be installed from
501
+ [PyPI](https://pypi.org/project/pyobo/) with:
502
+
503
+ ```shell
504
+ pip install pyobo
505
+ ```
506
+
507
+ The most recent code and data can be installed directly from GitHub with:
508
+
509
+ ```shell
510
+ pip install git+https://github.com/biopragmatics/pyobo.git
511
+ ```
512
+
513
+ ## 👐 Contributing
514
+
515
+ Contributions, whether filing an issue, making a pull request, or forking, are appreciated. See
516
+ [CONTRIBUTING.md](https://github.com/biopragmatics/pyobo/blob/master/.github/CONTRIBUTING.md)
517
+ for more information on getting involved.
518
+
519
+ ## 👋 Attribution
520
+
521
+ ### ⚖️ License
522
+
523
+ The code in this package is licensed under the MIT License.
524
+
525
+ <!--
526
+ ### 📖 Citation
527
+
528
+ Citation goes here!
529
+ -->
530
+
531
+ <!--
532
+ ### 🎁 Support
533
+
534
+ This project has been supported by the following organizations (in alphabetical order):
535
+
536
+ - [Biopragmatics Lab](https://biopragmatics.github.io)
537
+
538
+ -->
539
+
540
+ <!--
541
+ ### 💰 Funding
542
+
543
+ This project has been supported by the following grants:
544
+
545
+ | Funding Body | Program | Grant Number |
546
+ |---------------|--------------------------------------------------------------|--------------|
547
+ | Funder | [Grant Name (GRANT-ACRONYM)](https://example.com/grant-link) | ABCXYZ |
548
+ -->
549
+
550
+ ### 🍪 Cookiecutter
551
+
552
+ This package was created with [@audreyfeldroy](https://github.com/audreyfeldroy)'s
553
+ [cookiecutter](https://github.com/cookiecutter/cookiecutter) package using [@cthoyt](https://github.com/cthoyt)'s
554
+ [cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack) template.
555
+
556
+ ## 🛠️ For Developers
557
+
558
+ <details>
559
+ <summary>See developer instructions</summary>
560
+
561
+ The final section of the README is for if you want to get involved by making a code contribution.
562
+
563
+ ### Development Installation
564
+
565
+ To install in development mode, use the following:
566
+
567
+ ```bash
568
+ git clone git+https://github.com/biopragmatics/pyobo.git
569
+ cd pyobo
570
+ pip install -e .
571
+ ```
572
+
573
+ ### Updating Package Boilerplate
574
+
575
+ This project uses `cruft` to keep boilerplate (i.e., configuration, contribution guidelines, documentation
576
+ configuration)
577
+ up-to-date with the upstream cookiecutter package. Update with the following:
578
+
579
+ ```shell
580
+ pip install cruft
581
+ cruft update
582
+ ```
583
+
584
+ More info on Cruft's update command is
585
+ available [here](https://github.com/cruft/cruft?tab=readme-ov-file#updating-a-project).
586
+
587
+ ### 🥼 Testing
588
+
589
+ After cloning the repository and installing `tox` with `pip install tox tox-uv`,
590
+ the unit tests in the `tests/` folder can be run reproducibly with:
591
+
592
+ ```shell
593
+ tox -e py
594
+ ```
595
+
596
+ Additionally, these tests are automatically re-run with each commit in a
597
+ [GitHub Action](https://github.com/biopragmatics/pyobo/actions?query=workflow%3ATests).
598
+
599
+ ### 📖 Building the Documentation
600
+
601
+ The documentation can be built locally using the following:
602
+
603
+ ```shell
604
+ git clone git+https://github.com/biopragmatics/pyobo.git
605
+ cd pyobo
606
+ tox -e docs
607
+ open docs/build/html/index.html
608
+ ```
609
+
610
+ The documentation automatically installs the package as well as the `docs`
611
+ extra specified in the [`pyproject.toml`](../../Desktop/pyobo/pyproject.toml). `sphinx` plugins
612
+ like `texext` can be added there. Additionally, they need to be added to the
613
+ `extensions` list in [`docs/source/conf.py`](../../Desktop/pyobo/docs/source/conf.py).
614
+
615
+ The documentation can be deployed to [ReadTheDocs](https://readthedocs.io) using
616
+ [this guide](https://docs.readthedocs.io/en/stable/intro/import-guide.html).
617
+ The [`.readthedocs.yml`](../../Desktop/pyobo/.readthedocs.yml) YAML file contains all the configuration you'll need.
618
+ You can also set up continuous integration on GitHub to check not only that
619
+ Sphinx can build the documentation in an isolated environment (i.e., with `tox -e docs-test`)
620
+ but also that [ReadTheDocs can build it too](https://docs.readthedocs.io/en/stable/pull-requests.html).
621
+
622
+ #### Configuring ReadTheDocs
623
+
624
+ 1. Log in to ReadTheDocs with your GitHub account to install the integration
625
+ at https://readthedocs.org/accounts/login/?next=/dashboard/
626
+ 2. Import your project by navigating to https://readthedocs.org/dashboard/import then clicking the plus icon next to
627
+ your repository
628
+ 3. You can rename the repository on the next screen using a more stylized name (i.e., with spaces and capital letters)
629
+ 4. Click next, and you're good to go!
630
+
631
+ ### 📦 Making a Release
632
+
633
+ #### Configuring Zenodo
634
+
635
+ [Zenodo](https://zenodo.org) is a long-term archival system that assigns a DOI to each release of your package.
636
+
637
+ 1. Log in to Zenodo via GitHub with this link: https://zenodo.org/oauth/login/github/?next=%2F. This brings you to a
638
+ page that lists all of your organizations and asks you to approve installing the Zenodo app on GitHub. Click "grant"
639
+ next to any organizations you want to enable the integration for, then click the big green "approve" button. This
640
+ step only needs to be done once.
641
+ 2. Navigate to https://zenodo.org/account/settings/github/, which lists all of your GitHub repositories (both in your
642
+ username and any organizations you enabled). Click the on/off toggle for any relevant repositories. When you make
643
+ a new repository, you'll have to come back to this
644
+
645
+ After these steps, you're ready to go! After you make "release" on GitHub (steps for this are below), you can navigate
646
+ to https://zenodo.org/account/settings/github/repository/biopragmatics/pyobo
647
+ to see the DOI for the release and link to the Zenodo record for it.
648
+
649
+ #### Registering with the Python Package Index (PyPI)
650
+
651
+ You only have to do the following steps once.
652
+
653
+ 1. Register for an account on the [Python Package Index (PyPI)](https://pypi.org/account/register)
654
+ 2. Navigate to https://pypi.org/manage/account and make sure you have verified your email address. A verification email
655
+ might not have been sent by default, so you might have to click the "options" dropdown next to your address to get to
656
+ the "re-send verification email" button
657
+ 3. 2-Factor authentication is required for PyPI since the end of 2023 (see
658
+ this [blog post from PyPI](https://blog.pypi.org/posts/2023-05-25-securing-pypi-with-2fa/)). This means
659
+ you have to first issue account recovery codes, then set up 2-factor authentication
660
+ 4. Issue an API token from https://pypi.org/manage/account/token
661
+
662
+ #### Configuring your machine's connection to PyPI
663
+
664
+ You have to do the following steps once per machine. Create a file in your home directory called
665
+ `.pypirc` and include the following:
666
+
667
+ ```ini
668
+ [distutils]
669
+ index-servers =
670
+ pypi
671
+ testpypi
672
+
673
+ [pypi]
674
+ username = __token__
675
+ password = <the API token you just got>
676
+
677
+ # This block is optional in case you want to be able to make test releases to the Test PyPI server
678
+ [testpypi]
679
+ repository = https://test.pypi.org/legacy/
680
+ username = __token__
681
+ password = <an API token from test PyPI>
682
+ ```
683
+
684
+ Note that since PyPI is requiring token-based authentication, we use `__token__` as the user, verbatim.
685
+ If you already have a `.pypirc` file with a `[distutils]` section, just make sure that there is an `index-servers`
686
+ key and that `pypi` is in its associated list. More information on configuring the `.pypirc` file can
687
+ be found [here](https://packaging.python.org/en/latest/specifications/pypirc).
688
+
689
+ #### Uploading to PyPI
690
+
691
+ After installing the package in development mode and installing
692
+ `tox` with `pip install tox tox-uv`,
693
+ run the following from the shell:
694
+
695
+ ```shell
696
+ tox -e finish
697
+ ```
698
+
699
+ This script does the following:
700
+
701
+ 1. Uses [bump-my-version](https://github.com/callowayproject/bump-my-version) to switch the version number in
702
+ the `pyproject.toml`, `CITATION.cff`, `src/pyobo/version.py`,
703
+ and [`docs/source/conf.py`](../../Desktop/pyobo/docs/source/conf.py) to not have the `-dev` suffix
704
+ 2. Packages the code in both a tar archive and a wheel using
705
+ [`uv build`](https://docs.astral.sh/uv/guides/publish/#building-your-package)
706
+ 3. Uploads to PyPI using [`twine`](https://github.com/pypa/twine).
707
+ 4. Push to GitHub. You'll need to make a release going with the commit where the version was bumped.
708
+ 5. Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can
709
+ use `tox -e bumpversion -- minor` after.
710
+
711
+ #### Releasing on GitHub
712
+
713
+ 1. Navigate
714
+ to https://github.com/biopragmatics/pyobo/releases/new
715
+ to draft a new release
716
+ 2. Click the "Choose a Tag" dropdown and select the tag corresponding to the release you just made
717
+ 3. Click the "Generate Release Notes" button to get a quick outline of recent changes. Modify the title and description
718
+ as you see fit
719
+ 4. Click the big green "Publish Release" button
720
+
721
+ This will trigger Zenodo to assign a DOI to your release as well.
722
+
723
+ </details>