In [1]:
from goatools.base import get_godag
godag = get_godag('go-basic.obo', optional_attrs='relationship')
In [2]:
goid = 'GO:0050807'
In [3]:
def prt_flds(gosubdag):
"""Print the available printing fields"""
print('Print fields:')
for fld in sorted(gosubdag.prt_attr['flds']):
print(' {F}'.format(F=fld))
In [4]:
from goatools.gosubdag.gosubdag import GoSubDag
# Create a subset of the GO DAG which contains:
# * The selected GO term and
# * All the GO terms above it
gosubdag = GoSubDag(goid, godag, relationships=True, prt=False)
# Get additional information for chosen GO
ntgo = gosubdag.go2nt[goid]
# Choose fields and custom printing format
# prt_flds(gosubdag) # Uncomment to see the available print fields
prtfmt = '{NS} {GO} D{depth:02} {GO_name}'
# Print detailed information for GO
print(prtfmt.format(**ntgo._asdict()))
In [5]:
from goatools.gosubdag.plot.gosubdag_plot import GoSubDagPlot
GoSubDagPlot(gosubdag).plt_dag('reg_synapse_org.png')
In [6]:
from goatools.godag.go_tasks import get_go2parents
go2parents = get_go2parents(gosubdag.go2obj, gosubdag.relationships)
for goid_parent in go2parents[goid]:
print(prtfmt.format(**gosubdag.go2nt[goid_parent]._asdict()))
In [7]:
from goatools.godag.go_tasks import get_go2parents_isa
go2parents = get_go2parents_isa(gosubdag.go2obj)
for goid_parent in go2parents[goid]:
print(prtfmt.format(**gosubdag.go2nt[goid_parent]._asdict()))
In [8]:
goterm = godag[goid]
print('Parents up "is_a": required relationship')
for p_term in goterm.parents:
print(prtfmt.format(**gosubdag.go2nt[p_term.item_id]._asdict()))
if 'part_of' in goterm.relationship:
print('\nParents up "part_of" optional relationship:')
for p_go in goterm.relationship['part_of']:
print(prtfmt.format(**gosubdag.go2nt[p_go.item_id]._asdict()))
if 'regulates' in goterm.relationship:
print('\nParents up "regulates" optional relationship:')
for p_go in goterm.relationship['regulates']:
print(prtfmt.format(**gosubdag.go2nt[p_go.item_id]._asdict()))
# godag must be loaded with: optional_attrs='relationship'
# gosubdag must be loaded with: relationships=True
print('\nAncestors up all loaded relationships:')
for p_go in gosubdag.rcntobj.go2ancestors[goid]:
print(prtfmt.format(**gosubdag.go2nt[p_go]._asdict()))
Copyright (C) 2019-present, DV Klopfenstein, H Tang. All rights reserved.