#!/usr/bin/env python # coding: utf-8 # In[8]: from ontobio.ontol_factory import OntologyFactory # Create ontology object, for GO # Transparently uses remote SPARQL service. # (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do # not re-execute cell) ofactory = OntologyFactory() ont = ofactory.create('go') # In[9]: ont # In[19]: from ontobio.io.gafparser import GafParser from ontobio.assoc_factory import AssociationSetFactory p = GafParser() afactory = AssociationSetFactory() def make_assocs(group): url = "http://geneontology.org/gene-associations/gene_association.{}.gz".format(group) if group == 'human': url = "http://geneontology.org/gene-associations/goa_human.gaf.gz" assocs = p.parse(url) return afactory.create_from_assocs(assocs, ontology=ont) # In[11]: asoc_mouse = make_assocs('mgi') # In[12]: asoc_mouse.subjects[0:5] # In[16]: asoc_mouse.jaccard_similarity('MGI:MGI:1918911', 'MGI:MGI:3698435') # In[17]: asoc_mouse.annotations('MGI:MGI:1918911') # In[ ]: # In[20]: asoc_hsap = make_assocs('human') # In[21]: asoc_hsap.subjects[0:5] # In[ ]: