Skip to content

Commit 033fd5f

Browse files
committed
Add replacement info
1 parent 15b8877 commit 033fd5f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/pyobo/sources/cvx.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pandas as pd
99

10-
from pyobo import Obo, Term
10+
from pyobo import Obo, Reference, Term
1111

1212
__all__ = [
1313
"CVXGetter",
@@ -28,6 +28,11 @@ def iter_terms(self, force: bool = False) -> Iterable[Term]:
2828
return iter_terms()
2929

3030

31+
# This got split, which it's not obvious how to deal with this
32+
MANUAL_OBSOLETE = {"15"}
33+
REPLACEMENTS = {"31": "85", "154": "86", "180": "13"}
34+
35+
3136
def iter_terms() -> Iterable[Term]:
3237
"""Iterate over terms in CVX."""
3338
dd = defaultdict(set)
@@ -63,15 +68,19 @@ def iter_terms() -> Iterable[Term]:
6368
if cvx == "99":
6469
continue # this is a placeholder
6570

66-
is_obsolete = pd.notna(notes) and "do not use" in notes.lower()
67-
if is_obsolete:
68-
# there are some records that have been obsoleted/replaced
69-
continue
70-
term = Term.from_triple(PREFIX, cvx, full_name)
71+
is_obsolete = cvx in MANUAL_OBSOLETE or (pd.notna(notes) and "do not use" in notes.lower())
72+
term = Term(
73+
reference=Reference(prefix=PREFIX, identifier=cvx, name=full_name),
74+
is_obsolete=is_obsolete,
75+
)
7176
if short_name != full_name:
7277
term.append_synonym(short_name)
7378
if pd.notna(notes):
7479
term.append_comment(notes)
80+
if is_obsolete:
81+
replacement_identifier = REPLACEMENTS.get(cvx)
82+
if replacement_identifier:
83+
term.append_replaced_by(Reference(prefix=PREFIX, identifier=replacement_identifier))
7584
if pd.notna(status):
7685
term.append_property("status", status)
7786
if pd.notna(nonvaccine):

src/pyobo/struct/struct.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
orthologous,
5454
part_of,
5555
see_also,
56+
term_replaced_by,
5657
)
5758
from .utils import comma_separate, obo_escape_slim
5859
from ..constants import (
@@ -299,6 +300,11 @@ def append_comment(self, value: str) -> "Term":
299300
self.append_property(comment.curie, value)
300301
return self
301302

303+
def append_replaced_by(self, reference: ReferenceHint) -> "Term":
304+
"""Add a replaced by relationship."""
305+
self.append_relationship(term_replaced_by, reference)
306+
return self
307+
302308
def append_parent(self, reference: ReferenceHint) -> "Term":
303309
"""Add a parent to this entity."""
304310
reference = _ensure_ref(reference)

0 commit comments

Comments
 (0)