7
7
8
8
import pandas as pd
9
9
10
- from pyobo import Obo , Term
10
+ from pyobo import Obo , Reference , Term
11
11
12
12
__all__ = [
13
13
"CVXGetter" ,
@@ -28,6 +28,11 @@ def iter_terms(self, force: bool = False) -> Iterable[Term]:
28
28
return iter_terms ()
29
29
30
30
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
+
31
36
def iter_terms () -> Iterable [Term ]:
32
37
"""Iterate over terms in CVX."""
33
38
dd = defaultdict (set )
@@ -63,15 +68,19 @@ def iter_terms() -> Iterable[Term]:
63
68
if cvx == "99" :
64
69
continue # this is a placeholder
65
70
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
+ )
71
76
if short_name != full_name :
72
77
term .append_synonym (short_name )
73
78
if pd .notna (notes ):
74
79
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 ))
75
84
if pd .notna (status ):
76
85
term .append_property ("status" , status )
77
86
if pd .notna (nonvaccine ):
0 commit comments