@@ -219,18 +219,27 @@ def _load_ontology(ontology, iris, exclude_deprecated, use_cache=False, term_typ
219
219
def _do_mapping (source_terms , source_term_ids , ontology_terms , mapper , max_mappings , min_score ):
220
220
if mapper == Mapper .TFIDF :
221
221
term_mapper = TFIDFMapper (ontology_terms )
222
- return term_mapper .map (source_terms , source_term_ids , max_mappings = max_mappings , min_score = min_score )
222
+ mappings_df = term_mapper .map (source_terms , source_term_ids , max_mappings = max_mappings , min_score = min_score )
223
223
elif mapper == Mapper .ZOOMA :
224
224
term_mapper = ZoomaMapper ()
225
- return term_mapper .map (source_terms , source_term_ids , ontologies = ontology_terms , max_mappings = max_mappings )
225
+ mappings_df = term_mapper .map (source_terms , source_term_ids , ontologies = ontology_terms , max_mappings = max_mappings )
226
226
elif mapper == Mapper .BIOPORTAL :
227
227
term_mapper = BioPortalAnnotatorMapper ("8f0cbe43-2906-431a-9572-8600d3f4266e" )
228
- return term_mapper .map (source_terms , source_term_ids , ontologies = ontology_terms , max_mappings = max_mappings )
228
+ mappings_df = term_mapper .map (source_terms , source_term_ids , ontologies = ontology_terms , max_mappings = max_mappings )
229
229
elif mapper in {Mapper .LEVENSHTEIN , Mapper .JARO , Mapper .JARO_WINKLER , Mapper .INDEL , Mapper .FUZZY , Mapper .JACCARD }:
230
230
term_mapper = SyntacticMapper (ontology_terms )
231
- return term_mapper .map (source_terms , source_term_ids , mapper , max_mappings = max_mappings )
231
+ mappings_df = term_mapper .map (source_terms , source_term_ids , mapper , max_mappings = max_mappings )
232
232
else :
233
233
raise ValueError ("Unsupported mapper: " + mapper )
234
+ df = _filter_mappings (mappings_df , min_score )
235
+ return df
236
+
237
+ def _filter_mappings (mappings_df , min_score ):
238
+ new_df = pd .DataFrame (columns = mappings_df .columns )
239
+ for index , row in mappings_df .iterrows ():
240
+ if row ['Mapping Score' ] >= min_score :
241
+ new_df .loc [len (new_df .index )] = row
242
+ return new_df
234
243
235
244
def _save_mappings (mappings , output_file , min_score , mapper , target_ontology , base_iris , excl_deprecated , max_mappings , term_type ):
236
245
if os .path .dirname (output_file ): # create output directories if needed
0 commit comments