In [ ]:
Parents are terms directly above a GO term
1) If using only the default is_a relationship, the only parent is circled in green:
2) If adding the optional relationship, regulates, the two parents are circled in purple:
Ancestors are all terms above a GO term, traversing up all of the GO hierarchy.
3) If adding the optional relationship, regulates, there are four ancestors are circled in blue:
If using only the default is_a relationship, there are three ancestors (not circled)
In [1]:
import os
from goatools.obo_parser import GODag
# Load a small test GO DAG and all the optional relationships,
# like 'regulates' and 'part_of'
godag = GODag('../tests/data/i126/viral_gene_silence.obo',
optional_attrs={'relationship'})
In [2]:
GO_ID = 'GO:0019222' # regulation of metabolic process
In [3]:
from goatools.godag.go_tasks import get_go2parents
optional_relationships = set()
go2parents_isa = get_go2parents(godag, optional_relationships)
print('{GO} parent: {P}'.format(
GO=GO_ID,
P=go2parents_isa[GO_ID]))
In [4]:
optional_relationships = {'regulates', 'negatively_regulates', 'positively_regulates'}
go2parents_reg = get_go2parents(godag, optional_relationships)
print('{GO} parents: {P}'.format(
GO=GO_ID,
P=go2parents_reg[GO_ID]))
In [5]:
from goatools.gosubdag.gosubdag import GoSubDag
gosubdag_r0 = GoSubDag([GO_ID], godag, prt=None)
print('{GO} ancestors: {P}'.format(
GO=GO_ID,
P=gosubdag_r0.rcntobj.go2parents[GO_ID]))
In [6]:
gosubdag_r1 = GoSubDag([GO_ID], godag, relationships=optional_relationships, prt=None)
print('{GO} ancestors: {P}'.format(
GO=GO_ID,
P=gosubdag_r1.rcntobj.go2parents[GO_ID]))