Ontology

ancestors(go_id)

Returns the list of all ancestors in the ontology for the given GO Term.

Parameters:

go_id (str) – GO term ID.

Returns:

List of IDs of all the ancestors in the ontology.

Return type:

list of str

common_ancestor(go_id1, go_id2)

Returns the list of all the common ancestors in the ontology for the given GO Terms.

Parameters:
  • go_id1 (str) – GO term ID 1.

  • go_id2 (str) – GO term ID 2.

Returns:

List of IDs of all the common ancestors in the ontology.

Return type:

list of str

deepest_common_ancestor(go_id1, go_id2)

Returns the deepest common ancestor in the ontology for the given GO Terms.

Parameters:
  • go_id1 (str) – GO term ID 1.

  • go_id2 (str) – GO term ID 2.

Returns:

ID of the deepest common ancestor in the ontology.

Return type:

Option<String>

get_term_by_id(go_id)

Get the PyGOTerm object for a given GO term ID.

Parameters:

go_id (str) – GO term ID.

Returns:

The GO term as a Python object, or None if not found.

Return type:

Option<PyGOTerm>

load_go_terms(path=None)

Load GO terms from an OBO file and cache them globally.

Parameters:

path (Optional[str]) – Optional path to the OBO file.

Returns:

List of GO terms as Python objects.

Return type:

list of PyGOTerm

Ontology Functions

import go3
go3.load_go_terms()
term = go3.get_term_by_id("GO:0006397")
print(term.name)
  • load_go_terms: Loads the GO ontology from an OBO file (downloads if not present).

  • get_term_by_id: Retrieve a GO term by its ID.

  • ancestors: List all ancestors of a GO term.

  • common_ancestor: List all common ancestors of two terms.

  • deepest_common_ancestor: Find the deepest common ancestor (MICA) of two terms.