Semantic Similarity Interface

class oaklib.interfaces.semsim_interface.SemanticSimilarityInterface(resource: Optional[oaklib.resource.OntologyResource] = None, strict: bool = False)[source]

An interface for calculating similarity measures between pairs of terms or collections of terms

all_by_all_pairwise_similarity(subjects: Iterable[str], objects: Iterable[str], predicates: Optional[List[str]] = None) Iterator[oaklib.datamodels.similarity.TermPairwiseSimilarity][source]

Compute similarity for all combinations of terms in subsets vs all terms in objects

Parameters
  • subjects

  • objects

  • predicates

Returns

common_ancestors(subject: str, object: str, predicates: Optional[List[str]] = None, subject_ancestors: Optional[List[str]] = None, object_ancestors: Optional[List[str]] = None) Iterable[str][source]

Common ancestors of a subject-object pair

Parameters
  • subject

  • object

  • predicates

  • subject_ancestors – optional pre-generated ancestor list

  • object_ancestors – optional pre-generated ancestor list

Returns

get_information_content(curie: str, background: Optional[str] = None, predicates: Optional[List[str]] = None) float[source]

Returns the information content of a term

IC(t) = -log2(Pr(t))

Parameters
  • curie

  • background

  • predicates

Returns

most_recent_common_ancestors(subject: str, object: str, predicates: Optional[List[str]] = None) Iterable[str][source]

Most recent common ancestors (MRCAs) for a pair of entities

The MRCAs are the set of Common Ancestors (CAs) that are not themselves proper ancestors of another CA

Parameters
  • subject

  • object

  • predicates

Returns

multiset_most_recent_common_ancestors(subjects: List[str], predicates: Optional[List[str]] = None, asymmetric=True) Iterable[Tuple[str, str, str]][source]

All pairwise common ancestors for all pairs in a set of terms

Parameters
  • subjects

  • predicates

  • asymmetric

Returns

pairwise_similarity(subject: str, object: str, predicates: Optional[List[str]] = None, subject_ancestors: Optional[List[str]] = None, object_ancestors: Optional[List[str]] = None) oaklib.datamodels.similarity.TermPairwiseSimilarity[source]

Pairwise similarity between a pair of ontology terms

Parameters
  • subject

  • object

  • predicates

  • subject_ancestors – optional pre-generated ancestor list

  • object_ancestors – optional pre-generated ancestor list

Returns