oakx_grape package#

Submodules#

oakx_grape.grape_implementation module#

Plugin for ensmallen/grape.

class oakx_grape.grape_implementation.GrapeImplementation(resource=None, strict=False, multilingual=None, preferred_language=<factory>, autosave=<factory>, exclude_owl_top_and_bottom=<factory>, ontology_metamodel_mapper=None, _converter=None, graph=None, transposed_graph=None, uses_biolink=None, _cached_graphs_by_predicates=None, wrapped_adapter=None, **_kwargs)#

Bases: RelationGraphInterface, OboGraphInterface, ValidatorInterface, SearchInterface, SubsetterInterface, MappingProviderInterface, PatcherInterface, SemanticSimilarityInterface, MetadataInterface, DifferInterface

An experimental wrapper for Grape/Ensmallen.

This is intended primarily for semsim.

all_by_all_pairwise_similarity(subjects, objects, predicates=None)#

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

Unlike the standard OAK all_by_all_pairwise_similarity, the grape implementation does all comparisons at once.

Return type:

Iterator[TermPairwiseSimilarity]

delegated_methods: ClassVar[List[str]] = [<function BasicOntologyInterface.label>, <function BasicOntologyInterface.labels>, <function BasicOntologyInterface.curie_to_uri>, <function BasicOntologyInterface.uri_to_curie>, <function BasicOntologyInterface.ontologies>, <function BasicOntologyInterface.obsoletes>, <function SearchInterface.basic_search>, <function OboGraphInterface.node>]#

all methods that should be delegated to wrapped_adapter

entities(filter_obsoletes=True, owl_type=None)#

Implement OAK interface.

Return type:

Iterable[str]

graph: Graph = None#

the main graph. In this graph, ensmallen “neighbors” corresponds

incoming_relationship_map(*args, **kwargs)#

Implement OAK interface.

Return type:

Dict[str, List[str]]

incoming_relationships(curie, predicates=None)#

Implement OAK interface.

Return type:

Iterator[Tuple[str, str]]

Map from biolink (use in KGX) to RO/OWL.

Note this is only necessary for graphs from kgx obo

Parameters:

predicate (str) –

Return type:

str

Returns:

outgoing_relationship_map(*args, **kwargs)#

Implement OAK interface.

Return type:

Dict[str, List[str]]

outgoing_relationships(curie, predicates=None)#

Implement OAK interface.

Return type:

Iterator[Tuple[str, str]]

pairwise_similarity(subject, object, predicates=None, subject_ancestors=None, object_ancestors=None, counts=None)#

Implement term pairwise similarity.

Return type:

TermPairwiseSimilarity

predict()#

Implement OAK interface.

Return type:

Iterator[Tuple[float, str, Optional[str], str]]

preprocess_to_dag(graph, predicates)#

Process input graph to be compatible with grape models.

Return type:

Graph

termset_pairwise_similarity(subjects, objects, predicates=None, labels=False, counts=None)#

Implement term set pairwise similarity.

Return type:

TermSetPairwiseSimilarity

transposed_graph: Graph = None#

the main graph, with inverted directions. ensmallen does not handle child traversal, so we maintain two graphs

wrapped_adapter: BasicOntologyInterface = None#

An OAK implementation that takes care of everything that ensmallen cannot handle

oakx_grape.grape_implementation.get_graph_function_by_name(name, module='kgobo')#

Dynamically import a Grape class based on its reference.

Parameters:
  • name (str) – e.g. PATO

  • module – e.g. kgobo (default)

Return type:

Callable

Returns:

A function that can be called to to create a graph

oakx_grape.loader module#

Loads ensmallen graphs.

oakx_grape.loader.load_graph_from_adapter(oi, transpose=False, name='Unnamed')#

Create an ensmallen graph from an OAK ontology interface.

This currently works by serializing the OAK graph as minimal KGX, and using Grape/ensmallen to load.

Return type:

Graph

Module contents#

oakx_grape package.