#!/usr/bin/env python # coding: utf-8 # In[1]: from ontobio import OntologyFactory # In[2]: ont = OntologyFactory().create('go') # In[3]: relations=['subClassOf', 'BFO:0000050'] m = ont.create_slim_mapping(subset='goslim_generic', relations=relations) # In[4]: m['GO:0016577'] # In[7]: # show the first 20 GO terms plus their mappings for n in ont.nodes()[0:20]: if n.startswith('GO:'): print('{} {}'.format(n, ont.label(n))) for x in m[n]: print(' --> {} {}'.format(x, ont.label(x))) # In[8]: from ontobio.assoc_factory import AssociationSetFactory MOUSE = 'NCBITaxon:10090' # Create association set # Transparently uses remote Monarch service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) afactory = AssociationSetFactory() aset = afactory.create(ontology=ont, subject_category='gene', object_category='function', # this is ALL GO, not just MF taxon=MOUSE) # In[9]: sample = aset.subjects[0:20] sample # In[10]: for g in sample: print('{} {}'.format(g,aset.label(g))) for a in aset.annotations(g): print(' {} {}'.format(a,ont.label(a))) for mn in m[a]: print(' --> {} {}'.format(mn,ont.label(mn))) # In[11]: t='GO:0006681' m[t] # In[12]: subont=ont.subontology(relations=relations) # In[13]: subont.ancestors('GO:0034641') # In[14]: subont.filter_redundant(m[t]) # In[ ]: