180180)
181181from kg_microbe .transform_utils .transform import Transform
182182from kg_microbe .utils .dummy_tqdm import DummyTqdm
183+ from kg_microbe .utils .mapping_file_utils import load_oxygen_phenotype_mappings
183184from kg_microbe .utils .oak_utils import get_label
184185from kg_microbe .utils .pandas_utils import drop_duplicates
185186from kg_microbe .utils .string_coding import remove_nextlines
@@ -205,6 +206,7 @@ def __init__(
205206 source_name = BACDIVE
206207 super ().__init__ (source_name , input_dir , output_dir )
207208 self .ncbi_impl = get_adapter (f"sqlite:{ NCBITAXON_SOURCE } " )
209+ self .oxygen_phenotype_mappings = load_oxygen_phenotype_mappings ()
208210
209211 def _flatten_to_dicts (self , obj ):
210212 if isinstance (obj , dict ):
@@ -1358,15 +1360,25 @@ def run(self, data_file: Union[Optional[Path], Optional[str]] = None, show_statu
13581360 # e.g. ot_rec might look like {"@ref": 4562, "oxygen tolerance": "microaerophile"}
13591361 ot_label = ot_rec .get ("oxygen tolerance" , "" ).strip ()
13601362 if ot_label :
1361- # Create a node for this oxygen tolerance
1362- # Category is typically "biolink:PhenotypicQuality"
1363- # ID can be something like "oxygen:microaerophile"
1363+ # Check if we have a METPO mapping for this oxygen tolerance term
1364+ mapping = None
1365+ for map_key , map_value in self .oxygen_phenotype_mappings .items ():
1366+ if map_key == ot_label :
1367+ mapping = map_value
1368+ break
1369+ if mapping :
1370+ # Use METPO term
1371+ ot_id = mapping ['curie' ]
1372+ ot_display_label = mapping ['label' ]
1373+ # print(f"DEBUG: Mapped '{ot_label}' -> {ot_id} ({ot_display_label})")
1374+ else :
1375+ # Raise exception if no mapping found
1376+ raise ValueError (f"No METPO mapping found for oxygen tolerance term: '{ ot_label } '" )
13641377
1365- ot_id = f"oxygen:{ ot_label .replace (' ' , '_' ).lower ()} "
13661378 node_writer .writerow ([
13671379 ot_id ,
13681380 PHENOTYPIC_CATEGORY ,
1369- ot_label
1381+ ot_display_label
13701382 ] + [None ]* (len (self .node_header ) - 3 ))
13711383
13721384 # Now create an edge from each organism in species_with_strains
0 commit comments