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 )
@@ -60,11 +65,22 @@ def iter_terms() -> Iterable[Term]:
60
65
cvx_df [col ] = cvx_df [col ].map (lambda s : s .strip () if pd .notna (s ) else s )
61
66
terms = {}
62
67
for cvx , short_name , full_name , notes , status , nonvaccine , _updated in cvx_df .values :
63
- term = Term .from_triple (PREFIX , cvx , full_name )
68
+ if cvx == "99" :
69
+ continue # this is a placeholder
70
+
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
+ )
64
76
if short_name != full_name :
65
77
term .append_synonym (short_name )
66
78
if pd .notna (notes ):
67
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 ))
68
84
if pd .notna (status ):
69
85
term .append_property ("status" , status )
70
86
if pd .notna (nonvaccine ):
0 commit comments