pyobo 0.10.11__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 (152) 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 +51 -31
  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 +63 -2
  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 +2 -4
  20. pyobo/cli/utils.py +0 -2
  21. pyobo/constants.py +0 -3
  22. pyobo/getters.py +19 -26
  23. pyobo/gilda_utils.py +28 -8
  24. pyobo/identifier_utils.py +32 -15
  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 +2 -2
  39. pyobo/sources/agrovoc.py +3 -3
  40. pyobo/sources/antibodyregistry.py +4 -5
  41. pyobo/sources/biogrid.py +7 -7
  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 +68 -0
  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 +28 -10
  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 +8 -9
  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 +2 -4
  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 +5 -6
  93. pyobo/sources/reactome.py +2 -4
  94. pyobo/sources/rgd.py +3 -4
  95. pyobo/sources/rhea.py +9 -10
  96. pyobo/sources/ror.py +69 -22
  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 +6 -6
  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 +106 -99
  118. pyobo/struct/typedef.py +19 -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 +5 -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 +9 -7
  132. pyobo/xrefdb/sources/biomappings.py +0 -2
  133. pyobo/xrefdb/sources/cbms2019.py +0 -2
  134. pyobo/xrefdb/sources/chembl.py +5 -7
  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 -4
  141. pyobo/xrefdb/sources/wikidata.py +10 -5
  142. pyobo/xrefdb/xrefs_pipeline.py +15 -16
  143. {pyobo-0.10.11.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.11.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/xrefdb/bengo.py +0 -44
  149. pyobo-0.10.11.dist-info/METADATA +0 -499
  150. pyobo-0.10.11.dist-info/RECORD +0 -169
  151. pyobo-0.10.11.dist-info/entry_points.txt +0 -15
  152. {pyobo-0.10.11.dist-info → pyobo-0.11.0.dist-info}/top_level.txt +0 -0
pyobo/sources/ror.py CHANGED
@@ -1,34 +1,41 @@
1
1
  """Convert the Research Organization Registry (ROR) into an ontology."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  import json
4
6
  import zipfile
5
- from typing import Iterable
7
+ from collections.abc import Iterable
8
+ from typing import Any
6
9
 
7
10
  import bioregistry
8
11
  import zenodo_client
9
12
  from tqdm.auto import tqdm
10
13
 
11
- from pyobo.struct import Obo, Reference, Term, TypeDef
14
+ from pyobo.struct import Obo, Reference, Term
12
15
  from pyobo.struct.struct import acronym
16
+ from pyobo.struct.typedef import (
17
+ has_homepage,
18
+ has_part,
19
+ has_predecessor,
20
+ has_successor,
21
+ located_in,
22
+ part_of,
23
+ see_also,
24
+ )
13
25
 
14
26
  PREFIX = "ror"
15
27
  ROR_ZENODO_RECORD_ID = "10086202"
16
28
 
17
29
  # Constants
18
30
  ORG_CLASS = Reference(prefix="OBI", identifier="0000245")
19
- LOCATED_IN = Reference(prefix="RO", identifier="0001025")
20
- PART_OF = Reference(prefix="BFO", identifier="0000050")
21
- HAS_PART = Reference(prefix="BFO", identifier="0000051")
22
- SUCCESSOR = Reference(prefix="BFO", identifier="0000063")
23
- PREDECESSOR = Reference(prefix="BFO", identifier="0000062")
24
31
 
25
32
  RMAP = {
26
- "Related": TypeDef.from_triple("rdfs", "seeAlso"),
27
- "Child": TypeDef(HAS_PART),
28
- "Parent": TypeDef(PART_OF),
29
- "Predecessor": TypeDef(PREDECESSOR),
30
- "Successor": TypeDef(SUCCESSOR),
31
- "Located in": TypeDef(LOCATED_IN),
33
+ "Related": see_also,
34
+ "Child": has_part,
35
+ "Parent": part_of,
36
+ "Predecessor": has_predecessor,
37
+ "Successor": has_successor,
38
+ "Located in": located_in,
32
39
  }
33
40
  NAME_REMAPPING = {
34
41
  "'s-Hertogenbosch": "Den Bosch", # SMH Netherlands, why u gotta be like this
@@ -43,20 +50,20 @@ class RORGetter(Obo):
43
50
  """An ontology representation of the ROR."""
44
51
 
45
52
  ontology = bioregistry_key = PREFIX
46
- typedefs = list(RMAP.values())
53
+ typedefs = [has_homepage, *RMAP.values()]
47
54
  synonym_typedefs = [acronym]
48
55
  idspaces = {
49
56
  "ror": "https://ror.org/",
50
57
  "geonames": "https://www.geonames.org/",
51
- "envo": "http://purl.obolibrary.org/obo/ENVO_",
52
- "bfo": "http://purl.obolibrary.org/obo/BFO_",
53
- "ro": "http://purl.obolibrary.org/obo/RO_",
54
- "obi": "http://purl.obolibrary.org/obo/OBI_",
55
- "omo": "http://purl.obolibrary.org/obo/OMO_",
58
+ "ENVO": "http://purl.obolibrary.org/obo/ENVO_",
59
+ "BFO": "http://purl.obolibrary.org/obo/BFO_",
60
+ "RO": "http://purl.obolibrary.org/obo/RO_",
61
+ "OBI": "http://purl.obolibrary.org/obo/OBI_",
62
+ "OMO": "http://purl.obolibrary.org/obo/OMO_",
56
63
  "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
57
64
  }
58
65
 
59
- def __post_init__(self): # noqa: D105
66
+ def __post_init__(self):
60
67
  self.data_version, _url, _path = _get_info()
61
68
  super().__post_init__()
62
69
 
@@ -65,6 +72,18 @@ class RORGetter(Obo):
65
72
  return iterate_ror_terms(force=force)
66
73
 
67
74
 
75
+ ROR_ORGANIZATION_TYPE_TO_OBI = {
76
+ "Education": ...,
77
+ "Facility": ...,
78
+ "Company": ...,
79
+ "Government": ...,
80
+ "Healthcare": ...,
81
+ "Other": ...,
82
+ "Archive": ...,
83
+ }
84
+ _MISSED_ORG_TYPES: set[str] = set()
85
+
86
+
68
87
  def iterate_ror_terms(*, force: bool = False) -> Iterable[Term]:
69
88
  """Iterate over terms in ROR."""
70
89
  version, source_uri, records = get_latest(force=force)
@@ -74,10 +93,23 @@ def iterate_ror_terms(*, force: bool = False) -> Iterable[Term]:
74
93
  name = record["name"]
75
94
  name = NAME_REMAPPING.get(name, name)
76
95
 
96
+ organization_types = record.get("types", [])
97
+ description = f"{organization_types[0]} in {record['country']['country_name']}"
98
+ if established := record["established"]:
99
+ description += f" established in {established}"
100
+
77
101
  term = Term(
78
- reference=Reference(prefix=PREFIX, identifier=identifier, name=name), type="Instance"
102
+ reference=Reference(prefix=PREFIX, identifier=identifier, name=name),
103
+ type="Instance",
104
+ definition=description,
79
105
  )
80
106
  term.append_parent(ORG_CLASS)
107
+ # TODO replace term.append_parent(ORG_CLASS) with:
108
+ # for organization_type in organization_types:
109
+ # term.append_parent(ORG_PARENTS[organization_type])
110
+
111
+ for link in record.get("links", []):
112
+ term.append_property(has_homepage, link)
81
113
 
82
114
  if name.startswith("The "):
83
115
  term.append_synonym(name.removeprefix("The "))
@@ -159,5 +191,20 @@ def get_latest(*, force: bool = False):
159
191
  raise FileNotFoundError
160
192
 
161
193
 
194
+ def get_ror_to_country_geonames(**kwargs: Any) -> dict[str, str]:
195
+ """Get a mapping of ROR ids to GeoNames IDs for countries."""
196
+ from pyobo.sources.geonames import get_city_to_country
197
+
198
+ city_to_country = get_city_to_country()
199
+ rv = {}
200
+ for term in iterate_ror_terms(**kwargs):
201
+ city_geonames_reference = term.get_relationship(located_in)
202
+ if city_geonames_reference is None:
203
+ continue
204
+ if city_geonames_reference.identifier in city_to_country:
205
+ rv[term.identifier] = city_to_country[city_geonames_reference.identifier]
206
+ return rv
207
+
208
+
162
209
  if __name__ == "__main__":
163
- RORGetter().write_default(write_obo=True, force=True)
210
+ RORGetter(force=True).write_default(write_obo=True, force=True)
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Importers for selventa terminologies."""
4
2
 
5
3
  from .schem import SCHEMGetter
@@ -1,11 +1,9 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Selventa chemicals.
4
2
 
5
3
  .. seealso:: https://github.com/pyobo/pyobo/issues/27
6
4
  """
7
5
 
8
- from typing import Iterable
6
+ from collections.abc import Iterable
9
7
 
10
8
  import pandas as pd
11
9
 
@@ -1,8 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Selventa complexes."""
4
2
 
5
- from typing import Iterable
3
+ from collections.abc import Iterable
6
4
 
7
5
  import pandas as pd
8
6
 
@@ -1,11 +1,9 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Selventa diseases.
4
2
 
5
3
  .. seealso:: https://github.com/pyobo/pyobo/issues/26
6
4
  """
7
5
 
8
- from typing import Iterable
6
+ from collections.abc import Iterable
9
7
 
10
8
  import pandas as pd
11
9
 
@@ -1,8 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Selventa families."""
4
2
 
5
- from typing import Iterable
3
+ from collections.abc import Iterable
6
4
 
7
5
  import pandas as pd
8
6
 
pyobo/sources/sgd.py CHANGED
@@ -1,8 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for SGD."""
4
2
 
5
- from typing import Iterable
3
+ from collections.abc import Iterable
6
4
  from urllib.parse import unquote_plus
7
5
 
8
6
  from ..struct import Obo, Reference, Synonym, Term, from_species
pyobo/sources/slm.py CHANGED
@@ -1,8 +1,6 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Swisslipids."""
4
2
 
5
- from typing import Iterable
3
+ from collections.abc import Iterable
6
4
 
7
5
  import pandas as pd
8
6
  from tqdm.auto import tqdm
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for UMLS."""
4
2
 
5
3
  from .umls import UMLSGetter, get_obo # noqa: F401
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """CLI for UMLS exporter."""
4
2
 
5
3
  from .umls import UMLSGetter
@@ -1,7 +1,7 @@
1
1
  """Utilities for UMLS synonyms."""
2
2
 
3
+ from collections.abc import Mapping
3
4
  from pathlib import Path
4
- from typing import Mapping
5
5
 
6
6
  import requests
7
7
  from bs4 import BeautifulSoup
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for UMLS.
4
2
 
5
3
  Run with ``python -m pyobo.sources.umls``
@@ -8,7 +6,7 @@ Run with ``python -m pyobo.sources.umls``
8
6
  import itertools as itt
9
7
  import operator
10
8
  from collections import defaultdict
11
- from typing import Iterable, Mapping, Set
9
+ from collections.abc import Iterable, Mapping
12
10
 
13
11
  import bioregistry
14
12
  import pandas as pd
@@ -67,7 +65,7 @@ def get_obo() -> Obo:
67
65
  return UMLSGetter()
68
66
 
69
67
 
70
- def get_semantic_types() -> Mapping[str, Set[str]]:
68
+ def get_semantic_types() -> Mapping[str, set[str]]:
71
69
  """Get UMLS semantic types for each term."""
72
70
  dd = defaultdict(set)
73
71
  with open_umls_semantic_types() as file:
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converters for UniProt resources."""
4
2
 
5
3
  from .uniprot import PREFIX, UniProtGetter
@@ -1,15 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for UniProt."""
4
2
 
3
+ from collections.abc import Iterable
5
4
  from operator import attrgetter
6
5
  from pathlib import Path
7
- from typing import Iterable, List, Optional, cast
6
+ from typing import Optional, cast
8
7
 
9
- import bioversions
10
8
  from tqdm.auto import tqdm
11
9
 
12
10
  from pyobo import Obo, Reference
11
+ from pyobo.api.utils import get_version
13
12
  from pyobo.constants import RAW_MODULE
14
13
  from pyobo.identifier_utils import standardize_ec
15
14
  from pyobo.struct import Term, derives_from, enables, from_species, participates_in
@@ -57,6 +56,7 @@ class UniProtGetter(Obo):
57
56
  gene_product_of,
58
57
  molecularly_interacts_with,
59
58
  derives_from,
59
+ located_in,
60
60
  ]
61
61
 
62
62
  def iter_terms(self, force: bool = False) -> Iterable[Term]:
@@ -154,7 +154,7 @@ def iter_terms(version: Optional[str] = None) -> Iterable[Term]:
154
154
  yield term
155
155
 
156
156
 
157
- def _parse_go(go_terms) -> List[Reference]:
157
+ def _parse_go(go_terms) -> list[Reference]:
158
158
  rv = []
159
159
  if go_terms:
160
160
  for go_term in go_terms.split(";"):
@@ -166,7 +166,7 @@ def _parse_go(go_terms) -> List[Reference]:
166
166
  def ensure(version: Optional[str] = None, force: bool = False) -> Path:
167
167
  """Ensure the reviewed uniprot names are available."""
168
168
  if version is None:
169
- version = bioversions.get_version("uniprot")
169
+ version = get_version("uniprot")
170
170
  return RAW_MODULE.ensure(
171
171
  PREFIX,
172
172
  version,
@@ -27,7 +27,8 @@ DR Cross-reference to external Optional; once or more
27
27
 
28
28
  import itertools as itt
29
29
  from collections import defaultdict
30
- from typing import DefaultDict, Iterable, List, Mapping, Optional, Tuple
30
+ from collections.abc import Iterable, Mapping
31
+ from typing import Optional
31
32
 
32
33
  from tqdm.auto import tqdm
33
34
 
@@ -63,18 +64,18 @@ def iter_terms(force: bool = False) -> Iterable[Term]:
63
64
  path = ensure_path(PREFIX, url=URL, force=force)
64
65
  with open(path) as file:
65
66
  lines = list(file)
66
- it: Iterable[Tuple[str, str]] = ((line[:2], line[2:].strip()) for line in lines[47:-5])
67
+ it: Iterable[tuple[str, str]] = ((line[:2], line[2:].strip()) for line in lines[47:-5])
67
68
  for i, (_, term_lines) in enumerate(itt.groupby(it, key=lambda p: p[0] == "//")):
68
69
  term = _parse(i, term_lines)
69
70
  if term:
70
71
  yield term
71
72
 
72
73
 
73
- def _parse(i, lines: Iterable[Tuple[str, str]]) -> Optional[Term]:
74
- dd_: DefaultDict[str, List[str]] = defaultdict(list)
74
+ def _parse(i, lines: Iterable[tuple[str, str]]) -> Optional[Term]:
75
+ dd_: defaultdict[str, list[str]] = defaultdict(list)
75
76
  for key, value in lines:
76
77
  dd_[key].append(value)
77
- dd: Mapping[str, List[str]] = dict(dd_)
78
+ dd: Mapping[str, list[str]] = dict(dd_)
78
79
 
79
80
  if "//" in dd:
80
81
  return None
pyobo/sources/utils.py CHANGED
@@ -1,9 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Utilities for converters."""
4
2
 
5
3
  import logging
6
- from typing import Mapping, Set, Tuple
4
+ from collections.abc import Mapping
7
5
 
8
6
  from ..utils.io import multisetdict
9
7
 
@@ -15,7 +13,7 @@ __all__ = [
15
13
  logger = logging.getLogger(__name__)
16
14
 
17
15
 
18
- def get_go_mapping(path: str, prefix: str) -> Mapping[str, Set[Tuple[str, str]]]:
16
+ def get_go_mapping(path: str, prefix: str) -> Mapping[str, set[tuple[str, str]]]:
19
17
  """Get a GO mapping file."""
20
18
  with open(path) as file:
21
19
  return multisetdict(
@@ -23,7 +21,7 @@ def get_go_mapping(path: str, prefix: str) -> Mapping[str, Set[Tuple[str, str]]]
23
21
  )
24
22
 
25
23
 
26
- def process_go_mapping_line(line: str, prefix: str) -> Tuple[str, Tuple[str, str]]:
24
+ def process_go_mapping_line(line: str, prefix: str) -> tuple[str, tuple[str, str]]:
27
25
  """Process a GO mapping line."""
28
26
  line1 = line[len(f"{prefix}:") :]
29
27
  line2, go_id = line1.rsplit(";", 1)
@@ -1,10 +1,8 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for WikiPathways."""
4
2
 
5
3
  import logging
6
4
  import urllib.error
7
- from typing import Iterable
5
+ from collections.abc import Iterable
8
6
 
9
7
  from .gmt_utils import parse_wikipathways_gmt
10
8
  from ..constants import SPECIES_REMAPPING
pyobo/sources/zfin.py CHANGED
@@ -1,10 +1,9 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Converter for ZFIN."""
4
2
 
5
3
  import logging
6
4
  from collections import defaultdict
7
- from typing import Iterable, Optional
5
+ from collections.abc import Iterable
6
+ from typing import Optional
8
7
 
9
8
  from tqdm.auto import tqdm
10
9
 
pyobo/ssg/__init__.py CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  import itertools as itt
4
4
  from collections import defaultdict
5
+ from collections.abc import Sequence
5
6
  from operator import attrgetter
6
7
  from pathlib import Path
7
- from typing import Optional, Sequence, Tuple, Union
8
+ from typing import Optional, Union
8
9
 
9
10
  import bioregistry
10
11
  from bioregistry.constants import BIOREGISTRY_DEFAULT_BASE_URL
@@ -37,7 +38,7 @@ def make_site(
37
38
  metaregistry_metaprefix: Optional[str] = None,
38
39
  metaregistry_name: Optional[str] = None,
39
40
  metaregistry_base_url: Optional[str] = None,
40
- show_properties_in_manifest: Optional[Sequence[Tuple[str, str]]] = None,
41
+ show_properties_in_manifest: Optional[Sequence[tuple[str, str]]] = None,
41
42
  ) -> None:
42
43
  """Make a website in the given directory.
43
44
 
pyobo/struct/__init__.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Data structures for OBO."""
4
2
 
5
3
  from .reference import Reference # noqa: F401
pyobo/struct/reference.py CHANGED
@@ -1,13 +1,11 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  """Data structures for OBO."""
4
2
 
5
- from typing import Optional, Tuple
3
+ from typing import Optional
6
4
 
7
5
  import bioregistry
8
6
  import curies
9
7
  from curies.api import ExpansionError
10
- from pydantic import Field, root_validator, validator
8
+ from pydantic import Field, field_validator, model_validator
11
9
 
12
10
  from .utils import obo_escape
13
11
  from ..identifier_utils import normalize_curie
@@ -23,7 +21,7 @@ class Reference(curies.Reference):
23
21
 
24
22
  name: Optional[str] = Field(default=None, description="the name of the reference")
25
23
 
26
- @validator("prefix")
24
+ @field_validator("prefix")
27
25
  def validate_prefix(cls, v): # noqa
28
26
  """Validate the prefix for this reference."""
29
27
  norm_prefix = bioregistry.normalize_prefix(v)
@@ -41,7 +39,7 @@ class Reference(curies.Reference):
41
39
  """Get the preferred curie for this reference."""
42
40
  return f"{self.preferred_prefix}:{self.identifier}"
43
41
 
44
- @root_validator(pre=True)
42
+ @model_validator(mode="before")
45
43
  def validate_identifier(cls, values): # noqa
46
44
  """Validate the identifier."""
47
45
  prefix, identifier = values.get("prefix"), values.get("identifier")
@@ -124,7 +122,7 @@ class Reference(curies.Reference):
124
122
  def _escaped_identifier(self):
125
123
  return obo_escape(self.identifier)
126
124
 
127
- def __str__(self): # noqa: D105
125
+ def __str__(self):
128
126
  identifier_lower = self.identifier.lower()
129
127
  if identifier_lower.startswith(f"{self.prefix.lower()}:"):
130
128
  rv = identifier_lower
@@ -134,7 +132,7 @@ class Reference(curies.Reference):
134
132
  rv = f"{rv} ! {self.name}"
135
133
  return rv
136
134
 
137
- def __hash__(self): # noqa: D105
135
+ def __hash__(self):
138
136
  return hash((self.__class__, self.prefix, self.identifier))
139
137
 
140
138
 
@@ -145,32 +143,32 @@ class Referenced:
145
143
 
146
144
  @property
147
145
  def prefix(self):
148
- """The prefix of the typedef.""" # noqa: D401
146
+ """The prefix of the typedef."""
149
147
  return self.reference.prefix
150
148
 
151
149
  @property
152
150
  def name(self):
153
- """The name of the typedef.""" # noqa: D401
151
+ """The name of the typedef."""
154
152
  return self.reference.name
155
153
 
156
154
  @property
157
155
  def identifier(self) -> str:
158
- """The local unique identifier for this typedef.""" # noqa: D401
156
+ """The local unique identifier for this typedef."""
159
157
  return self.reference.identifier
160
158
 
161
159
  @property
162
160
  def curie(self) -> str:
163
- """The CURIE for this typedef.""" # noqa: D401
161
+ """The CURIE for this typedef."""
164
162
  return self.reference.curie
165
163
 
166
164
  @property
167
165
  def preferred_curie(self) -> str:
168
- """The preferred CURIE for this typedef.""" # noqa: D401
166
+ """The preferred CURIE for this typedef."""
169
167
  return self.reference.preferred_curie
170
168
 
171
169
  @property
172
- def pair(self) -> Tuple[str, str]:
173
- """The pair of namespace/identifier.""" # noqa: D401
170
+ def pair(self) -> tuple[str, str]:
171
+ """The pair of namespace/identifier."""
174
172
  return self.reference.pair
175
173
 
176
174
  @property