pyobo 0.12.5__py3-none-any.whl → 0.12.6__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/cli/database.py CHANGED
@@ -6,6 +6,7 @@ from collections.abc import Iterable
6
6
  from pathlib import Path
7
7
 
8
8
  import bioregistry
9
+ import bioversions
9
10
  import click
10
11
  from more_click import verbose_option
11
12
  from tqdm.contrib.logging import logging_redirect_tqdm
@@ -97,12 +98,17 @@ def _update_database_kwargs(kwargs: DatabaseKwargs) -> DatabaseKwargs:
97
98
 
98
99
 
99
100
  @database_annotate
101
+ @click.option("--eager-versions", is_flag=True)
100
102
  @click.pass_context
101
- def build(ctx: click.Context, **kwargs: Unpack[DatabaseKwargs]) -> None:
103
+ def build(ctx: click.Context, eager_versions: bool, **kwargs: Unpack[DatabaseKwargs]) -> None:
102
104
  """Build all databases."""
103
105
  # if no_strict and zenodo:
104
106
  # click.secho("Must be strict before uploading", fg="red")
105
107
  # sys.exit(1)
108
+
109
+ if eager_versions:
110
+ bioversions.get_rows(use_tqdm=True)
111
+
106
112
  with logging_redirect_tqdm():
107
113
  click.secho("Collecting metadata and building", fg="cyan", bold=True)
108
114
  # note that this is the only one that needs a force=force
@@ -287,7 +287,9 @@ def wrap_norm_prefix(f):
287
287
  raise ValueError(f"Invalid prefix: {prefix.prefix}")
288
288
  prefix = ReferenceTuple(norm_prefix, prefix.identifier)
289
289
  else:
290
- raise TypeError
290
+ raise TypeError(
291
+ f"prefix should be given as a string or reference object. Got {type(prefix)} {prefix}"
292
+ )
291
293
  return f(prefix, *args, **kwargs)
292
294
 
293
295
  return _wrapped
@@ -6,7 +6,6 @@ from collections.abc import Iterable
6
6
  from contextlib import closing
7
7
 
8
8
  import bioregistry
9
- import psycopg2
10
9
  from pydantic import ValidationError
11
10
  from tqdm.auto import tqdm
12
11
 
@@ -42,6 +41,8 @@ class DrugCentralGetter(Obo):
42
41
 
43
42
  def iter_terms() -> Iterable[Term]:
44
43
  """Iterate over DrugCentral terms."""
44
+ import psycopg2
45
+
45
46
  with closing(psycopg2.connect(**PARAMS)) as conn:
46
47
  with closing(conn.cursor()) as cur:
47
48
  cur.execute(
pyobo/sources/spdx.py CHANGED
@@ -55,11 +55,15 @@ def _get_term(record: dict[str, Any]) -> Term | None:
55
55
  except ValidationError:
56
56
  tqdm.write(f"invalid: {record['licenseId']}")
57
57
  return None
58
- term = Term(
59
- reference=reference,
60
- is_obsolete=True if record.get("isDeprecatedLicenseId") else None,
61
- # type="Instance",
62
- ).append_parent(ROOT)
58
+ term = (
59
+ Term(
60
+ reference=reference,
61
+ is_obsolete=True if record.get("isDeprecatedLicenseId") else None,
62
+ # type="Instance",
63
+ )
64
+ .append_parent(ROOT)
65
+ .append_synonym(record["licenseId"])
66
+ )
63
67
  if record.get("isOsiApproved"):
64
68
  term.annotate_boolean(IS_OSI, True)
65
69
  if record.get("isFsfLibre"):
@@ -82,4 +86,4 @@ class SPDXLicenseGetter(Obo):
82
86
 
83
87
 
84
88
  if __name__ == "__main__":
85
- SPDXLicenseGetter.cli(["--obo", "--owl", "--rewrite"])
89
+ SPDXLicenseGetter.cli()
pyobo/struct/struct.py CHANGED
@@ -8,6 +8,7 @@ import json
8
8
  import logging
9
9
  import os
10
10
  import sys
11
+ import tempfile
11
12
  import warnings
12
13
  from collections import ChainMap, defaultdict
13
14
  from collections.abc import Callable, Collection, Iterable, Iterator, Mapping, Sequence
@@ -1021,6 +1022,15 @@ class Obo:
1021
1022
  ofn = get_ofn_from_obo(self)
1022
1023
  ofn.write_funowl(path)
1023
1024
 
1025
+ def write_owl(self, path: str | Path) -> None:
1026
+ """Write OWL, by first outputting OFN then converting with ROBOT."""
1027
+ from bioontologies import robot
1028
+
1029
+ with tempfile.TemporaryDirectory() as directory:
1030
+ ofn_path = Path(directory).joinpath("tmp.ofn")
1031
+ self.write_ofn(ofn_path)
1032
+ robot.convert(ofn_path, path)
1033
+
1024
1034
  def write_rdf(self, path: str | Path) -> None:
1025
1035
  """Write as Turtle RDF."""
1026
1036
  from .functional.obo_to_functional import get_ofn_from_obo
pyobo/utils/misc.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from collections.abc import Callable
6
+ from collections.abc import Callable, Iterable
7
7
  from datetime import datetime
8
8
 
9
9
  import bioversions.utils
@@ -46,6 +46,8 @@ VERSION_PREFIXES = [
46
46
  "http://w3id.org/nfdi4ing/metadata4ing/", # like http://w3id.org/nfdi4ing/metadata4ing/1.3.1
47
47
  "http://www.semanticweb.com/OntoRxn/", # like http://www.semanticweb.com/OntoRxn/0.2.5
48
48
  "https://w3id.org/lehrplan/ontology/", # like in https://w3id.org/lehrplan/ontology/1.0.0-4
49
+ "http://www.ebi.ac.uk/swo/version/", # http://www.ebi.ac.uk/swo/version/6.0
50
+ "https://w3id.org/emi/version/",
49
51
  ]
50
52
  VERSION_PREFIX_SPLITS = [
51
53
  "http://www.ebi.ac.uk/efo/releases/v",
@@ -193,18 +195,23 @@ def _prioritize_version(
193
195
  return None
194
196
 
195
197
 
196
- def _get_version_from_artifact(prefix: str) -> str | None:
198
+ def _get_getter_urls(prefix: str) -> Iterable[tuple[OntologyFormat, str]]:
197
199
  # assume that all possible files that can be downloaded
198
200
  # are in sync and have the same version
199
- for ontology_format, func in ONTOLOGY_GETTERS:
200
- url = func(prefix)
201
+ for ontology_format, get_url_func in ONTOLOGY_GETTERS:
202
+ url = get_url_func(prefix)
201
203
  if url is None:
202
204
  continue
205
+ yield ontology_format, url
206
+
207
+
208
+ def _get_version_from_artifact(prefix: str) -> str | None:
209
+ for ontology_format, url in _get_getter_urls(prefix):
203
210
  # Try to peak into the file to get the version without fully downloading
204
- version_func = VERSION_GETTERS.get(ontology_format)
205
- if version_func is None:
211
+ get_version_func = VERSION_GETTERS.get(ontology_format)
212
+ if get_version_func is None:
206
213
  continue
207
- version = version_func(prefix, url)
214
+ version = get_version_func(prefix, url)
208
215
  if version:
209
216
  return cleanup_version(version, prefix=prefix)
210
217
  return None
pyobo/version.py CHANGED
@@ -12,7 +12,7 @@ __all__ = [
12
12
  "get_version",
13
13
  ]
14
14
 
15
- VERSION = "0.12.5"
15
+ VERSION = "0.12.6"
16
16
 
17
17
 
18
18
  def get_git_hash() -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyobo
3
- Version: 0.12.5
3
+ Version: 0.12.6
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
@@ -30,7 +30,6 @@ Requires-Dist: tqdm
30
30
  Requires-Dist: pyyaml
31
31
  Requires-Dist: pandas
32
32
  Requires-Dist: requests
33
- Requires-Dist: protmapper
34
33
  Requires-Dist: more-itertools
35
34
  Requires-Dist: more-click>=0.0.2
36
35
  Requires-Dist: humanize
@@ -43,7 +42,6 @@ Requires-Dist: bioontologies>=0.7.2
43
42
  Requires-Dist: ssslm>=0.0.13
44
43
  Requires-Dist: zenodo-client>=0.3.6
45
44
  Requires-Dist: class-resolver>=0.6.0
46
- Requires-Dist: psycopg2-binary
47
45
  Requires-Dist: pydantic>=2.0
48
46
  Requires-Dist: curies>=0.10.17
49
47
  Requires-Dist: curies-processing>=0.1.2
@@ -57,8 +55,11 @@ Requires-Dist: nih-reporter-downloader>=0.0.1
57
55
  Requires-Dist: typing-extensions
58
56
  Requires-Dist: rdflib
59
57
  Requires-Dist: obographs>=0.0.8
58
+ Requires-Dist: psycopg2-binary ; extra == 'drugcentral'
60
59
  Requires-Dist: ssslm[gilda] ; extra == 'gilda'
61
60
  Requires-Dist: ssslm[gilda-slim] ; extra == 'gilda-slim'
61
+ Requires-Dist: protmapper ; extra == 'pid'
62
+ Requires-Dist: pyobo[drugcentral,pid] ; extra == 'sources'
62
63
  Maintainer: Charles Tapley Hoyt
63
64
  Maintainer-email: Charles Tapley Hoyt <cthoyt@gmail.com>
64
65
  Requires-Python: >=3.10
@@ -67,8 +68,11 @@ Project-URL: Documentation, https://pyobo.readthedocs.io
67
68
  Project-URL: Funding, https://github.com/sponsors/cthoyt
68
69
  Project-URL: Homepage, https://github.com/biopragmatics/pyobo
69
70
  Project-URL: Repository, https://github.com/biopragmatics/pyobo.git
71
+ Provides-Extra: drugcentral
70
72
  Provides-Extra: gilda
71
73
  Provides-Extra: gilda-slim
74
+ Provides-Extra: pid
75
+ Provides-Extra: sources
72
76
  Description-Content-Type: text/markdown
73
77
 
74
78
  <!--
@@ -17,7 +17,7 @@ pyobo/api/utils.py,sha256=48232ccb8432615867f902b487dd047f55d431bc87291d5fbed791
17
17
  pyobo/api/xrefs.py,sha256=9d62cbb761b36957e780d0546ce3154a33a90ae6be23bbbedadba8c735c6aab0,5242
18
18
  pyobo/cli/__init__.py,sha256=a5388bbb38e3a62d0febdc958d0da413a9c152666e6059ea74934364b0e482f9,71
19
19
  pyobo/cli/cli.py,sha256=e5b63fed95593a81f0859b42c71f8060be726f20738d2eb9354e6fe57f43b0b0,2842
20
- pyobo/cli/database.py,sha256=e880ac2c78bd437d73c99cea5c44938129852571bca35e2ab0cc7de195851ce6,11963
20
+ pyobo/cli/database.py,sha256=82b3d51b577bf3286883996f100bb7c301e404048a86d99a6f09afc78f564487,12121
21
21
  pyobo/cli/database_utils.py,sha256=8d0eea4a0fa8664f90f910b5db536451ba9778d8342bc7d5f7a8a05da2b7adae,5540
22
22
  pyobo/cli/lookup.py,sha256=1b11bbe771979c345ff8df494562919900b95e237c7c437997595ee42de31c76,9163
23
23
  pyobo/cli/utils.py,sha256=9e6b57b311b44d61088e321efa387f6aacebd3d6d337bf8d1c589fb871b3304d,1738
@@ -25,7 +25,7 @@ pyobo/constants.py,sha256=1b9132661b9c730acc9f5d4345a4d73334c76b944676d191cd8aab
25
25
  pyobo/getters.py,sha256=5f68100998658f6b070e12fbbd52cc8d280f142d5361287ac74ee3bcc406deb8,18197
26
26
  pyobo/gilda_utils.py,sha256=b9384002b00b48dcc98be86b47d954bed41c8b9548c380aaab62fa9ad929d0aa,1990
27
27
  pyobo/identifier_utils/__init__.py,sha256=8921c06613b0a9666662939fa5734bb8aa2e4988fb652562697ec1179b93f2ca,793
28
- pyobo/identifier_utils/api.py,sha256=b65d99d4b8d223341d7d3bd4b7bc2e41ce7b52e218b0779b90bacde6a9beaa61,9247
28
+ pyobo/identifier_utils/api.py,sha256=7e293972b20e3a1b0722e1fe89afe839078a65e5f96c1323e52ea871c59a31e6,9365
29
29
  pyobo/identifier_utils/relations/__init__.py,sha256=2961f492b8530a678a9e010887b5530c3de1cc2df8f294e210a18dbb748d01db,159
30
30
  pyobo/identifier_utils/relations/api.py,sha256=c625bca0f09379ba7ef544d05aaf4b998ee9798945a90f3b98b6d763ef9d36df,5764
31
31
  pyobo/identifier_utils/relations/data.json,sha256=88b6ce5fb632faa389b512b68f1b73acdd54b552a1aaa8043430eb5e0020a0bc,113169
@@ -77,7 +77,7 @@ pyobo/sources/dictybase_gene.py,sha256=78bbde62732e26cd92c2d287ca3e34b678e9f058f
77
77
  pyobo/sources/drugbank/__init__.py,sha256=880b2dbd9419d3525c25e0089b606727ddb7501be2f1a490e2d1158440e8540a,178
78
78
  pyobo/sources/drugbank/drugbank.py,sha256=5a216ccbfe883599207ad99b518904d6f3e983974bc2305fcf7715263228d705,10914
79
79
  pyobo/sources/drugbank/drugbank_salt.py,sha256=69b565fe280b7a698cc3850b8b7fc8b5381f09aab7bb26e3aa7b13f5187b0b59,1646
80
- pyobo/sources/drugcentral.py,sha256=9fb9bbcbaf0b3c494163dde2e627a6695366ca1c74cb7293efd2419871a610a1,4047
80
+ pyobo/sources/drugcentral.py,sha256=c481bfb0f79b6d5fbf4b5bd440bcceb8ba876bf44cfb300e7d9f28aabd5aa9b7,4052
81
81
  pyobo/sources/expasy.py,sha256=25f116d229b5c25858db82add7a037e8c5b405e40dbfd76d3ff67a1f581c8755,11053
82
82
  pyobo/sources/famplex.py,sha256=a82be3e9607feaeab64471d53c8686872aa47f5b9b23a5eb3bc0daf98b5af7a4,5628
83
83
  pyobo/sources/flybase.py,sha256=8144b7f4d17fa9cef6dd1d9201b85062a3e0e943a2c0ac0f5e15d0d49c02ebc4,5666
@@ -154,7 +154,7 @@ pyobo/sources/signor/__init__.py,sha256=6de6ff151aaca2a2d5317b437916405dff5783d5
154
154
  pyobo/sources/signor/download.py,sha256=ae40c954403a95dd33e221b5e2d30e70072e4658d043d48024068b75ac5a833f,1053
155
155
  pyobo/sources/signor/signor_complexes.py,sha256=04634cfe41b48eda51fa2eab0d2305e5729e0a59563b7e336762aae0532d064d,3802
156
156
  pyobo/sources/slm.py,sha256=986242c3f131a541116d6b452e8f053763607d5844befdf79bae893db85c8f62,4246
157
- pyobo/sources/spdx.py,sha256=3a9f32952c007c1bd1dcf661b7d0cd92caf8eccdcd340b69b1a4198e4ec50ee0,2475
157
+ pyobo/sources/spdx.py,sha256=26354335498de8d73c6d3ff6fcea2a26978a9d9ceec0f99d504ca74e5fd80153,2530
158
158
  pyobo/sources/umls/__init__.py,sha256=10d80d5d02a1cdef73cb1b178e49fbdfe05daa6767b4be19cb5a91e36183b4ff,141
159
159
  pyobo/sources/umls/__main__.py,sha256=358e97a9eb60a5177f2cf9bde554d7d8bdeb241ffb877250b6d8270c9f5c1613,108
160
160
  pyobo/sources/umls/get_synonym_types.py,sha256=fd5266a8217b628fca6bef678e579dba3251445bc0f474d0f6f6c92c80bd7bb2,1724
@@ -188,7 +188,7 @@ pyobo/struct/obograph/export.py,sha256=7bf4b4bcd6c3c89e820fe542711dae70cb037ed45
188
188
  pyobo/struct/obograph/reader.py,sha256=dbae3255e0fc6b78c6c7d11a194655c456d243fa7043fe9c915c3d4bcc2225f3,8525
189
189
  pyobo/struct/obograph/utils.py,sha256=8ded244a40b6e0c53da56447ab5fcaf89e635a18d611263a348dd3a59aaf67f4,1516
190
190
  pyobo/struct/reference.py,sha256=4fc7d3b665cd18c8dfbbb2b8b49de4bc30a8e101d14ff26bf5f88e9c562bc2d3,11735
191
- pyobo/struct/struct.py,sha256=772296f541bff7b35b4c420713f8c780b059d5157f8897f1458c7371ffcb4263,92916
191
+ pyobo/struct/struct.py,sha256=e833c86ec9e302808afc3750a0d9b1cfc4237251fc10450e48bda8b181761a00,93297
192
192
  pyobo/struct/struct_utils.py,sha256=be63a06ade7ba29cf3c02410a245e715103884c5e886d4b23e49050bb8f7dd5a,39930
193
193
  pyobo/struct/typedef.py,sha256=eed11961bc01efa4f2fec3c7ae9ba8eff5dd6776d70bf0d4a9cc13b72c042e3f,13031
194
194
  pyobo/struct/utils.py,sha256=ce4a4e138d894087e4374adce6a34434ad375482a691fff9eed1e88cc24aef56,906
@@ -197,12 +197,12 @@ pyobo/utils/__init__.py,sha256=08035263cbc6abfeaff2b5a159121d9e4f96a392c0d91f568
197
197
  pyobo/utils/cache.py,sha256=c7b0e7c3cbc762ca2c9575a257d2fd65d4eee59b9e211d648b935c7696fb1f5d,3136
198
198
  pyobo/utils/io.py,sha256=413bc68cd0e46887fbf1371adb7079456fda57078a892b319a0c1229770c48da,3921
199
199
  pyobo/utils/iter.py,sha256=ad845b6da1491f131a134c94fab419a026a0608aed7afd3db98d26c4591fe736,1524
200
- pyobo/utils/misc.py,sha256=1dc1bc786ae2ae479facaa6341aa8ea565f167fab285ddb0df387aa7ee5ab9ef,7666
200
+ pyobo/utils/misc.py,sha256=e3df697a77320ea5bdff19b41f40aad0584ec34328368abef485504ca87e79a1,7992
201
201
  pyobo/utils/ndex_utils.py,sha256=128902592d345ab93fe32f2575e42e53269a0bac8dcc18370da81497e2767336,2326
202
202
  pyobo/utils/path.py,sha256=129f254d15a0154f7f5c5e6fa895790771b83dc501825222b4c91a50dc63cefa,4091
203
- pyobo/version.py,sha256=6ff6d2700b14e326e314f95afbb5b5fafe7b58e959aace2bb1029526a8a9ee2d,926
204
- pyobo-0.12.5.dist-info/licenses/LICENSE,sha256=41c80964a1b1956e41c013670812fc5592d5b51bd7b3cd4287d949450488a498,1076
205
- pyobo-0.12.5.dist-info/WHEEL,sha256=ec89e25a684ec3ad8fb2a9be806e47666a27f7dcdcf9b55bff3f1d3ed5e60e0a,78
206
- pyobo-0.12.5.dist-info/entry_points.txt,sha256=00d833beec05ffdff58a90a8c49b5b04ce80e22d8c92ddfd80c3f340eea1bc6b,42
207
- pyobo-0.12.5.dist-info/METADATA,sha256=c48d14635954af46f3f382e4f867fe7ca84ec0d0ac3756c8de05cd8e4cc9a344,21661
208
- pyobo-0.12.5.dist-info/RECORD,,
203
+ pyobo/version.py,sha256=a0f95e1dc5c6ae4d27ebf8475452242e445573a9b03e3602e3b3fd402309fd94,926
204
+ pyobo-0.12.6.dist-info/licenses/LICENSE,sha256=41c80964a1b1956e41c013670812fc5592d5b51bd7b3cd4287d949450488a498,1076
205
+ pyobo-0.12.6.dist-info/WHEEL,sha256=ec89e25a684ec3ad8fb2a9be806e47666a27f7dcdcf9b55bff3f1d3ed5e60e0a,78
206
+ pyobo-0.12.6.dist-info/entry_points.txt,sha256=00d833beec05ffdff58a90a8c49b5b04ce80e22d8c92ddfd80c3f340eea1bc6b,42
207
+ pyobo-0.12.6.dist-info/METADATA,sha256=9725b7bbe5fa4b43a5d11e33fc551f38bfec3c5e2a6066f44cf0ea94f6cc9686,21834
208
+ pyobo-0.12.6.dist-info/RECORD,,
File without changes