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