RDF Utils#

Utility methods that are used for handling RDF.

kgx.utils.rdf_utils#

Returns a Biolink Model element for a given predicate.

Parameters:
  • prefix_manager (PrefixManager) – An instance of prefix manager

  • predicate (Any) – The CURIE of a predicate

Returns:

The corresponding Biolink Model element

Return type:

Optional[Element]

kgx.utils.rdf_utils.infer_category(iri: URIRef, rdfgraph: Graph) Optional[List][source]#

Infer category for a given iri by traversing rdfgraph.

Parameters:
  • iri (rdflib.term.URIRef) – IRI

  • rdfgraph (rdflib.Graph) – A graph to traverse

Returns:

A list of category corresponding to the given IRI

Return type:

Optional[List]

kgx.utils.rdf_utils.process_predicate(prefix_manager: PrefixManager, p: Union[URIRef, str], predicate_mapping: Optional[Dict] = None) Tuple[source]#

Process a predicate where the method checks if there is a mapping in Biolink Model.

Parameters:
  • prefix_manager (PrefixManager) – An instance of prefix manager

  • p (Union[URIRef, str]) – The predicate

  • predicate_mapping (Optional[Dict]) – Predicate mappings

Returns:

A tuple that contains the Biolink CURIE (if available), the Biolink slot_uri CURIE (if available), the CURIE form of p, the reference of p

Return type:

Tuple[str, str, str, str]