pyobo 0.10.9__py3-none-any.whl → 0.10.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyobo/api/names.py CHANGED
@@ -30,11 +30,11 @@ __all__ = [
30
30
  logger = logging.getLogger(__name__)
31
31
 
32
32
 
33
- def get_name_by_curie(curie: str) -> Optional[str]:
33
+ def get_name_by_curie(curie: str, *, version: Optional[str] = None) -> Optional[str]:
34
34
  """Get the name for a CURIE, if possible."""
35
35
  prefix, identifier = normalize_curie(curie)
36
36
  if prefix and identifier:
37
- return get_name(prefix, identifier)
37
+ return get_name(prefix, identifier, version=version)
38
38
  return None
39
39
 
40
40
 
@@ -74,9 +74,9 @@ def _help_get(
74
74
 
75
75
 
76
76
  @wrap_norm_prefix
77
- def get_name(prefix: str, identifier: str) -> Optional[str]:
77
+ def get_name(prefix: str, identifier: str, *, version: Optional[str] = None) -> Optional[str]:
78
78
  """Get the name for an entity."""
79
- return _help_get(get_id_name_mapping, prefix, identifier)
79
+ return _help_get(get_id_name_mapping, prefix, identifier, version=version)
80
80
 
81
81
 
82
82
  @lru_cache()
pyobo/sources/expasy.py CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  import logging
6
6
  from collections import defaultdict
7
- from typing import Dict, Iterable, Mapping, Optional, Set, Tuple
7
+ from typing import Any, Dict, Iterable, Mapping, Optional, Set, Tuple
8
8
 
9
9
  from .utils import get_go_mapping
10
10
  from ..struct import Obo, Reference, Synonym, Term
11
- from ..struct.typedef import enables, has_member
11
+ from ..struct.typedef import enables, has_member, term_replaced_by
12
12
  from ..utils.path import ensure_path
13
13
 
14
14
  __all__ = [
@@ -93,12 +93,29 @@ def get_terms(version: str, force: bool = False) -> Iterable[Term]:
93
93
 
94
94
  database_path = ensure_path(PREFIX, url=EXPASY_DATABASE_URL, version=version)
95
95
  with open(database_path) as file:
96
- _data = get_database(file)
96
+ id_to_data = get_database(file)
97
97
 
98
98
  ec2go = get_ec2go(version=version)
99
99
 
100
100
  ec_code_to_alt_ids = {}
101
- for ec_code, data in _data.items():
101
+ for ec_code, data in id_to_data.items():
102
+ if data.get("deleted"):
103
+ terms[ec_code] = Term(
104
+ reference=Reference(prefix=PREFIX, identifier=ec_code), is_obsolete=True
105
+ )
106
+ continue
107
+
108
+ transfer_ids = data.get("transfer_id")
109
+ if transfer_ids:
110
+ term = terms[ec_code] = Term(
111
+ reference=Reference(prefix=PREFIX, identifier=ec_code), is_obsolete=True
112
+ )
113
+ for transfer_id in transfer_ids:
114
+ term.append_relationship(
115
+ term_replaced_by, Reference(prefix=PREFIX, identifier=transfer_id)
116
+ )
117
+ continue
118
+
102
119
  parent_ec_code = data["parent"]["identifier"]
103
120
  parent_term = terms[parent_ec_code]
104
121
 
@@ -210,7 +227,7 @@ def get_database(lines: Iterable[str]) -> Mapping:
210
227
  for groups in _group_by_id(lines):
211
228
  _, expasy_id = groups[0]
212
229
 
213
- rv[expasy_id] = ec_data_entry = {
230
+ ec_data_entry: Dict[str, Any] = {
214
231
  "concept": {
215
232
  "namespace": PREFIX,
216
233
  "identifier": expasy_id,
@@ -230,10 +247,10 @@ def get_database(lines: Iterable[str]) -> Mapping:
230
247
  if descriptor == "//":
231
248
  continue
232
249
  elif descriptor == DE and value == "Deleted entry.":
233
- continue
250
+ ec_data_entry["deleted"] = True
234
251
  elif descriptor == DE and value.startswith("Transferred entry: "):
235
- value = value[len("Transferred entry: ") :].rstrip()
236
- ec_data_entry["transfer_id"] = value
252
+ value = value[len("Transferred entry: ") :].rstrip().rstrip(".")
253
+ ec_data_entry["transfer_id"] = value.split(" and ")
237
254
  elif descriptor == DE:
238
255
  ec_data_entry["concept"]["name"] = value.rstrip(".") # type:ignore
239
256
  elif descriptor == AN:
@@ -259,11 +276,7 @@ def get_database(lines: Iterable[str]) -> Mapping:
259
276
  )
260
277
  )
261
278
 
262
- for expasy_id, data in rv.items():
263
- transfer_id = data.pop("transfer_id", None)
264
- if transfer_id is not None:
265
- rv[expasy_id]["alt_ids"].append(transfer_id) # type:ignore
266
-
279
+ rv[expasy_id] = ec_data_entry
267
280
  return rv
268
281
 
269
282
 
pyobo/version.py CHANGED
@@ -14,7 +14,7 @@ __all__ = [
14
14
  "get_git_hash",
15
15
  ]
16
16
 
17
- VERSION = "0.10.9"
17
+ VERSION = "0.10.10"
18
18
 
19
19
 
20
20
  def get_git_hash() -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyobo
3
- Version: 0.10.9
3
+ Version: 0.10.10
4
4
  Summary: Handling and writing OBO
5
5
  Home-page: https://github.com/pyobo/pyobo
6
6
  Download-URL: https://github.com/pyobo/pyobo/releases
@@ -11,12 +11,12 @@ pyobo/obographs.py,sha256=JKE0a7e-gmxqdJoeX2zb_xQ6Tv5PAe60YhnIpAvrrYg,3758
11
11
  pyobo/plugins.py,sha256=dXWGoFuQktNeQUWSJlPz2a7FeLysggc9ry6auEZdw98,1227
12
12
  pyobo/reader.py,sha256=3VTWQMmA-AHi3RdA2jb48d2deXO-lYKqXbcMa9Qhi_4,21271
13
13
  pyobo/resource_utils.py,sha256=JBcJRihZhNwp78-qWZPrzSCGoYfyOjzBwMkfmOkO_no,4289
14
- pyobo/version.py,sha256=ONSzSms19NKy9Bl2q8M4P_Mlo0MkqMGJ7X1SKZuec4M,977
14
+ pyobo/version.py,sha256=S2agZOhWCaqxb1jQk8O_DDd5X86GPoXvcBAAxtmCpsc,978
15
15
  pyobo/api/__init__.py,sha256=Hq8p5uPW8fFYG2KfLqUsHhtLkTPqE4TqItGkedZzvXM,1326
16
16
  pyobo/api/alts.py,sha256=xmAb-gGQCJ9MbaFvoNK6E-V0B3TV9hxulkfbkHIvOso,2617
17
17
  pyobo/api/hierarchy.py,sha256=2KtyTkqOKJzejNqVvlhPQD_w0fKzrOQp1BSx-Ina3t0,9413
18
18
  pyobo/api/metadata.py,sha256=62E7j0ZW3vYK2Rh-R7NCMKnChbYjZwPjVDoaE1AsCOc,1070
19
- pyobo/api/names.py,sha256=A5HprOfdt7twF2LfjdQQaIj3FNj4_GD7MZ7CrKllY5M,7559
19
+ pyobo/api/names.py,sha256=m_5UjixlUS10FCrlmNoNJ8pI_z-YB2xqgROGvPGIQBY,7661
20
20
  pyobo/api/properties.py,sha256=BKqUgN8nTpYrc0fROdaGGkptELgjbGT6TC_N2X8FIQM,7813
21
21
  pyobo/api/relations.py,sha256=VEQCQjPamehyGaL-wFzUYH9OeVq9pVzj70sl9K3ttKw,5996
22
22
  pyobo/api/species.py,sha256=xRPRoD6n1wcDaqlC_tHLw3rKMWa4razWsSPNa228g_4,2181
@@ -70,7 +70,7 @@ pyobo/sources/dictybase_gene.py,sha256=EgWBwUZ83ev7x5Lp_nUkgSq2zumkDjJ7_13m3f6kJ
70
70
  pyobo/sources/drugbank.py,sha256=pb2IdVQF4FqDvefwRdqlDV5j6pR9R1b3rGxHC-GSWb4,11028
71
71
  pyobo/sources/drugbank_salt.py,sha256=hx16G41mP2KXT4fsAQRCRkJMGn-z5cafs-bwm4wMtwo,1783
72
72
  pyobo/sources/drugcentral.py,sha256=05mGolBIyKCxAYzpH9LY_ZQrTVnizup2JUiWi2wW9OI,3587
73
- pyobo/sources/expasy.py,sha256=h8RcFtRd4wHBDVHC7tK8C1dT2M0dCknhfoWao7DLOx4,9507
73
+ pyobo/sources/expasy.py,sha256=Ul6DFtHKw3fU1ec93c9f29kXxod2Rn-jPWOYl1xrRa8,10051
74
74
  pyobo/sources/famplex.py,sha256=bn3WaJdrDf9BxsG9vnnnnGOwCrnrJ-vTMxOnxgrtUb4,5816
75
75
  pyobo/sources/flybase.py,sha256=0-BCNsp-L-CgGPN9VdJec6-8e4-fJuzaZAZiNra3ZUQ,5768
76
76
  pyobo/sources/geonames.py,sha256=XpSc-_6653MrjunVJhqbHHLtkT8kmbJZzfRuF6DoWU8,7929
@@ -161,9 +161,9 @@ pyobo/xrefdb/sources/intact.py,sha256=F0z6WrOwI79aZSuM5MsvQwzqoyzh9J0UuB4Mseoj9X
161
161
  pyobo/xrefdb/sources/ncit.py,sha256=unoIKJqdcfitTc6pU9P1SxJ1w8ax0iDjvEOlqe64nCY,3745
162
162
  pyobo/xrefdb/sources/pubchem.py,sha256=GaqgqtSV-T_P-900nL3alPx_ZB36MlmnEepOnZMONA4,780
163
163
  pyobo/xrefdb/sources/wikidata.py,sha256=bOI2zUkkLbmXvOMJZmVWq1xKlMCuL_3l1NVsaoJr1x4,3387
164
- pyobo-0.10.9.dist-info/LICENSE,sha256=GRbxxtZEWtZiFGDENk1gntCQK4HEJYYbylEJEwpSLao,1076
165
- pyobo-0.10.9.dist-info/METADATA,sha256=BDEySfczBniUX3mHWKWI4XC9uxrbB_XPCRhp3Q5I8uE,20045
166
- pyobo-0.10.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
167
- pyobo-0.10.9.dist-info/entry_points.txt,sha256=Du5V6qw_T917Z5ZoMhLTTJoolK7kkVuUWkdE7aJWea0,669
168
- pyobo-0.10.9.dist-info/top_level.txt,sha256=oVdkT-pbiGoSdGSQplXFuP1KQGJNf4GdRC65jn6y9t0,6
169
- pyobo-0.10.9.dist-info/RECORD,,
164
+ pyobo-0.10.10.dist-info/LICENSE,sha256=GRbxxtZEWtZiFGDENk1gntCQK4HEJYYbylEJEwpSLao,1076
165
+ pyobo-0.10.10.dist-info/METADATA,sha256=rzbhrEqNk6WZVG-Z6qDwkOaobEwleVjGz5m-tSB3Zqg,20046
166
+ pyobo-0.10.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
167
+ pyobo-0.10.10.dist-info/entry_points.txt,sha256=Du5V6qw_T917Z5ZoMhLTTJoolK7kkVuUWkdE7aJWea0,669
168
+ pyobo-0.10.10.dist-info/top_level.txt,sha256=oVdkT-pbiGoSdGSQplXFuP1KQGJNf4GdRC65jn6y9t0,6
169
+ pyobo-0.10.10.dist-info/RECORD,,