GOTerm Object

A PyGOTerm represents one term in the loaded Gene Ontology.

Main fields

Field

Type

Description

id

str

GO identifier (for example GO:0006397)

name

str

Human-readable label

namespace

str

One of biological_process, molecular_function, cellular_component

definition

str

GO definition text

parents

list[str]

Immediate is_a parents

children

list[str]

Immediate is_a children

depth

int | None

Maximum distance to root (longest path through the DAG)

level

int | None

Minimum distance to root (shortest path through the DAG)

is_obsolete

bool

Obsolescence flag

alt_ids

list[str]

Alternate GO IDs

replaced_by

str | None

Suggested canonical replacement for obsolete terms

consider

list[str]

Alternative replacements

synonyms

list[str]

Synonym strings

xrefs

list[str]

Cross-references

relationships

list[tuple[str, str]]

Additional relationships beyond is_a (for example ("part_of", "GO:0006396"))

comment

str | None

GO comment field

Field notes

depth vs. level: Because GO is a DAG (not a tree), a term can have multiple paths to the root. depth is the longest such path and level is the shortest. See Ontology API for details.

relationships: This field contains non-is_a relationships as (type, target_id) tuples – for example part_of, regulates, has_part. The parents and children fields only reflect is_a edges.

None and empty values: depth and level can be None for the root terms or if the OBO file does not provide them. replaced_by and comment are None when not present in the OBO entry. List fields (parents, children, alt_ids, consider, synonyms, xrefs, relationships) are empty lists when no values exist.

Example

import go3

go3.load_go_terms("go-basic.obo")
term = go3.get_term_by_id("GO:0006397")

print(term.id)          # "GO:0006397"
print(term.name)        # "mRNA processing"
print(term.namespace)   # "biological_process"
print(term.depth)       # e.g. 7
print(term.level)       # e.g. 5
print(term.parents)     # list of is_a parent GO IDs
print(term.relationships)  # e.g. [("part_of", "GO:0006396")]

Inspecting an obsolete term

import go3

go3.load_go_terms("go-basic.obo")

# Obsolete terms are loaded but flagged
term = go3.get_term_by_id("GO:0005765")  # example; check your OBO for valid obsolete IDs
print(term.is_obsolete)   # True
print(term.replaced_by)   # replacement GO ID, or None
print(term.consider)      # list of alternative GO IDs to consider

API reference

class PyGOTerm

Bases: object

Python-exposed struct representing a GO term (for use in the Python API).

Fields

idstr

GO term identifier.

namestr

Human-readable name of the term.

namespacestr

Ontology namespace.

definitionstr

Textual definition of the term.

parentslist of str

List of parent GO term IDs.

childrenlist of str

List of child GO term IDs.

depthOptional[int]

Maximum distance to a root term.

levelOptional[int]

Minimum distance to a root term.

is_obsoletebool

True if the term is obsolete.

alt_idslist of str

Alternative GO IDs for this term.

replaced_byOptional[str]

If obsolete, the term that replaces this one.

considerlist of str

Suggested replacement terms if obsolete.

synonymslist of str

List of synonyms.

xrefslist of str

Cross-references to other databases.

relationshipslist of (str, str)

Other relationships (e.g., part_of).

commentOptional[str]

Additional comments.

alt_ids
children
comment
consider
definition
depth
id
is_obsolete
level
name
namespace
parents
relationships
replaced_by
synonyms
xrefs