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')
ont
h:go g:
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)
asoc_mouse = make_assocs('mgi')
asoc_mouse.subjects[0:5]
['MGI:MGI:1918911', 'MGI:MGI:1923503', 'MGI:MGI:1913300', 'MGI:MGI:3698435', 'MGI:MGI:1914088']
asoc_mouse.jaccard_similarity('MGI:MGI:1918911', 'MGI:MGI:3698435')
1.0
asoc_mouse.annotations('MGI:MGI:1918911')
['GO:0008150', 'GO:0003674', 'GO:0005575']
asoc_hsap = make_assocs('human')
asoc_hsap.subjects[0:5]
['UniProtKB:A0A024R161', 'UniProtKB:A0A075B6H7', 'UniProtKB:A0A075B6H8', 'UniProtKB:A0A075B6H9', 'UniProtKB:A0A075B6I0']