{ "cells": [ { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from ontobio.ontol_factory import OntologyFactory\n", "\n", "# Create ontology object, for GO\n", "# Transparently uses remote SPARQL service.\n", "# (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do\n", "# not re-execute cell)\n", "ofactory = OntologyFactory()\n", "ont = ofactory.create('go')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "h:go g:" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ont" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "from ontobio.io.gafparser import GafParser\n", "from ontobio.assoc_factory import AssociationSetFactory\n", "\n", "p = GafParser()\n", "afactory = AssociationSetFactory()\n", "\n", "def make_assocs(group):\n", " url = \"http://geneontology.org/gene-associations/gene_association.{}.gz\".format(group)\n", " if group == 'human':\n", " url = \"http://geneontology.org/gene-associations/goa_human.gaf.gz\"\n", " assocs = p.parse(url)\n", " return afactory.create_from_assocs(assocs, ontology=ont)\n", " \n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "asoc_mouse = make_assocs('mgi')" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['MGI:MGI:1918911',\n", " 'MGI:MGI:1923503',\n", " 'MGI:MGI:1913300',\n", " 'MGI:MGI:3698435',\n", " 'MGI:MGI:1914088']" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asoc_mouse.subjects[0:5]" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asoc_mouse.jaccard_similarity('MGI:MGI:1918911', 'MGI:MGI:3698435')\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['GO:0008150', 'GO:0003674', 'GO:0005575']" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asoc_mouse.annotations('MGI:MGI:1918911')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "asoc_hsap = make_assocs('human')" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['UniProtKB:A0A024R161',\n", " 'UniProtKB:A0A075B6H7',\n", " 'UniProtKB:A0A075B6H8',\n", " 'UniProtKB:A0A075B6H9',\n", " 'UniProtKB:A0A075B6I0']" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asoc_hsap.subjects[0:5]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" } }, "nbformat": 4, "nbformat_minor": 2 }