Virtual Ontology (indra.ontology.virtual_ontology)¶
This module implements a virtual ontology which communicates with a REST service to perform all ontology functions.
-
class
indra.ontology.virtual.ontology.VirtualOntology(url, ontology='bio')[source]¶ A virtual ontology class which uses a remote REST service to perform all operations. It is particularly useful if the host machine has limited resources and keeping the ontology graph in memory is not desirable.
Parameters: - url (str) – The base URL of the ontology graph web service.
- ontology (Optional[str]) – The identifier of the ontology recognized by the web service. Default: bio
-
get_component_label(ns, id)[source]¶ Return the component label of an entity.
Parameters: - ns (str) – An entity’s name space.
- id (str) – An entity’s ID.
Returns: The component label of the given entity or None if not available.
Return type: int or None
-
get_id_from_name(ns, name)[source]¶ Return an entity’s ID given its name space and standard name.
Parameters: - ns (str) – The name space in which the standard name is defined.
- name (str) – The standard name defined in the name space.
Returns: The ID corresponding to the given standard name in the given name space or None if it’s not available.
Return type: str
-
get_node_property(ns, id, property)[source]¶ Return a given property of a given entity.
Parameters: - ns (str) – An entity’s name space.
- id (str) – An entity’s ID.
- property (str) – The property to look for on the given node.
Returns: The name associated with the given entity or None if the node is not in the ontology or doesn’t have the given property.
Return type: str or None
-
initialize()[source]¶ Initialize the ontology by adding nodes and edges.
By convention, ontologies are implemented such that the constructor does not add all the nodes and edges, which can take a long time. This function is called automatically when any of the user-facing methods ot IndraOntology is called. This way, the ontology is only fully constructed if it is used.