Skip to content

Matchmaking process

tudorgroza edited this page Feb 24, 2021 · 5 revisions

TOC

Matchmaking

Input:

  • text
  • upstream field (optional) - used only for selecting the appropriate project-level mapping preferences.
  • project-level mapping preferences:
    • target datasources for Zooma
    • target ontologies for Zooma and OXO
    • preferred mapping ontologies for OLS
zooma_results = annotate(text, target_datasources)
zooma_results += annotate(text, target_ontologies)

// Get initial Zooma suggestions

high_confidence_uris = []
final_uris = []
for each zooma_result in zooma_results:
	if zooma_result.semantic_tags > 1:
		throw warning
		continue
		
	suggested_term = zooma_result.semantic_tags[0]
	if zooma_result.confidence == HIGH:
		add suggested_term to high_confidence_uris
		
	if parent_ontology(suggested_term) in target_ontologies:
		add suggested_term to final_uris	
end for

// Cache ontology terms in the local DB

terms_created = []
for each uri in final_uris:
	ontology_term = create_ontology_term(uri)
	create_mapping_suggestion(text, ontology_term)
	add ontology_term to terms_created
end for

// Find possible auto-mappings
// TODO: Discuss the consequences of overwriting a manual mapping

if text.mapping_status is not UNMAPPED:
	throw warning
	
for ontology_term in terms_created:
	if ontology_term in high_confidence_uris:
		create_mapping(text, ontology_term)
		text.mapping_status = AUTO_MAPPED
		return
end for

for ontology_term in terms_created:
	if text == ontology_term.label:
		create_mapping(text, ontology_term)
		text.mapping_status = AUTO_MAPPED
		return
end for

// Are all the calls to OLS necessary?

for uri in high_confidence_uris:
	ols_terms = retrieve_terms_from_OLS(target: parent_ontology(uri), uri)
	
	if ols_terms.size > 1:
		throw warning
	
	oxo_mappings = find_mappings_from_OXO(ols_terms[0], target_ontologies)
	for oxo_mapping in oxo_mappings:
		ols_terms = retrieve_terms_from_OLS(target: oxo_mapping.target_prefix, oxo_mapping.curie)
		ontology_term = create_ontology_term(ols_terms[0])
		create_mapping_suggestion(text, ontology_term)
	end for
end for

Create local ontology term

Input:

  • uri
  • project-specific preferred mapping ontologies
if term_already_exists_in_DB:
	return

// Collect responses from OLS

preferred_responses = []
for preferred_ontology in project-specific preferred mapping ontologies:
	preferred_responses += retrieve_terms_from_OLS(target: preferred_ontology, uri)
end for

parent_responses = []
if parent_ontology(uri) is not in project-specific preferred mapping ontologies:
	parent_responses = retrieve_terms_from_OLS(target: parent_ontology(uri), uri)

// Parse and assign term status
	
term_status = NEEDS_IMPORT
if preferred_responses is empty and parent_responses is empty:
	term_status = DELETED

if preferred_responses[0] is obsolete or parent_responses[0] is obsolete:
	term_status = OBSOLETE

if preferred_responses is not empty:
	term_stats = CURRENT

// Cache term locally

if term_status == DELETED:
	// TODO: Discuss what's happening here

if term_status == OBSOLETE:
	// TODO: Discuss what's happening here

if term_status == CURRENT:
	create_term(preferred_responses[0])

if term_status == NEEDS_IMPORT:
	create_term(parent_responses[0])

Remarks

  • Both algorithms above are supposed to cater for newly added target matching texts / strings and ontology terms, as well as the scheduled updating processes
  • In its current form, the ontology term creation method will not actually update a term upon running the scheduled updating process, since it returns immediately if the term already exists in the DB
    • TODO: Discuss if this is the intended behaviour