Skip to main content

Library for working with OBO Library Ontologies and associations

Project description

|Build Status| |DOI|

ontobio - a python API for working with ontology graphs
=======================================================

This module provides objects and utility methods for working with
ontologies and associations of entities (genes, variants, etc) to
ontology classes.

The ontologies and associations can either be local files or provided by
remote services (currently the OntoBee SPARQL service for ontologies and
a Monarch or GO Golr service for associations).

API Docs
========

`ontobio <https://www.pydoc.io/pypi/ontobio-0.1.5/index.html>`__ on
pydoc.io

Ontologies
==========

There are two ways of initiating an ontology object:

- via a local obo-json file
- via remote connections to OBO PURLs
- via remote query to a SPARQL service (currently ontobee, but soon
others)

Persistent caching is used (currently cachier) to avoid repeated
expensive I/O connections

This is handled via the `ontol\_manager.py <ontobio/ontol_manager.py>`__
module. This creates an ontology object (see
`ontol.py <ontobio/ontol.py>`__ ).

Note that object modeling is lightweight - we use the python networkx
package for representing the basic graph portion of an ontology. See
also the `obographs <https://github.com/geneontology/obographs>`__ spec.

Associations
============

See the ontobio.golr package

Command Line Usage
==================

Initial Setup
-------------

::

export PATH $HOME/repos/bioink-api/ontobio/bin
ogr -h

Note you need to be connected to a network

Note: command line interface may change

Connecting to ontologies
------------------------

Specify an ontology with the ``-r`` option. this will always be the OBO
name, for example ``go``, ``cl``, ``mp``, etc

- ``-r go`` connect to GO via default method (currently SPARQL)
- ``-r obo:go`` connect to GO via download and cache of ontology from
PURL
- ``-r /users/my/my-ontologies/go.json`` use local download of ontology

In the following we assume default method, but can be substituted.

Ancestors queries
-----------------

List all ancestors:

::

ogr -r cl neuron

Show ancestors as tree, following only subclass:

::

ogr -r cl -p subClassOf -t tree neuron

generates:

::

% GO:0005623 ! cell
% CL:0000003 ! native cell
% CL:0000255 ! eukaryotic cell
% CL:0000548 ! animal cell
% CL:0002319 ! neural cell
% CL:0000540 ! neuron *
% CL:0002371 ! somatic cell
% CL:0002319 ! neural cell
% CL:0000540 ! neuron *

Descendants of neuron, parts and subtypes

::

ogr -r cl -p subClassOf -p BFO:0000050 -t tree -d d neuron

Descendants and ancestors of neuron, parts and subtypes

::

ogr -r cl -p subClassOf -p BFO:0000050 -t tree -d du neuron

All ancestors of all classes 2 levels down from subclass-roots within
CL:

::

ogr -r cl -P CL -p subClassOf -t tree -d u -L 2

Visualization using obographviz
-------------------------------

Requires: https://www.npmjs.com/package/obographviz

Add og2dot.js to path

::

ogr -p subClassOf BFO:0000050 -r go -t png a nucleus

This proceeds by:

1. Using the python ontobio library to extract a networkx subgraph
around the specified node
2. Write as obographs-json
3. Calls og2dot.js

Output:

.. figure:: https://github.com/biolink/biolink-api/raw/master/ontobio/docs/nucleus.png
:alt: img

img
Search
------

List exact matches to neuron

::

ogr -r cl neuron

Terms starting with neuron, SQL style

::

ogr -r cl neuron%

Terms starting with neuron, regex (equivalent to above)

::

ogr -r cl -s r ^neuron

Terms ending with neuron

::

ogr -r cl -s r neuron$

Terms containing the string neuron

::

ogr -r cl -s r neuron

Note: any of the above can be fed into other renderers, e.g. trees,
graphs

E.g. terms containing neuron, to obo

::

ogr -r cl %neuron% -t obo

E.g. terms ending neuron, to tree

::

ogr -r cl %neuron -t tree

Release instructions
--------------------

This section is only relevant for project maintainers. To create a new
release, do the following:

1. Bump the ``__version__`` in
```ontobio/__init__.py`` <ontobio/__init__.py>`__.

2. Run the following commands:

``sh TAG=v`python setup.py --version` git add ontobio/__init__.py git commit --message="Upgrade to $TAG" git push git tag --annotate $TAG --message="Upgrade to $TAG" git push --tags``

.. |Build Status| image:: https://travis-ci.org/biolink/ontobio.svg?branch=master
:target: https://travis-ci.org/biolink/ontobio
.. |DOI| image:: https://zenodo.org/badge/13996/biolink/ontobio.svg
:target: https://zenodo.org/badge/latestdoi/13996/biolink/ontobio


Project details


Release history Release notifications | RSS feed

This version

0.1.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ontobio-0.1.5.tar.gz (38.6 kB view details)

Uploaded Source

Built Distributions

ontobio-0.1.5-py3.5.egg (45.9 kB view details)

Uploaded Source

ontobio-0.1.5-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file ontobio-0.1.5.tar.gz.

File metadata

  • Download URL: ontobio-0.1.5.tar.gz
  • Upload date:
  • Size: 38.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ontobio-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d883c509f740c5dba20ab16fca66c38ef71099b2d969aeb196a23dfc99a96592
MD5 4b05ee38752eec63748da9bd01385acc
BLAKE2b-256 57a7cad3fca09e7e0212501011bc100f8e875ee9d8238a6e7bef635cc09158bb

See more details on using hashes here.

Provenance

File details

Details for the file ontobio-0.1.5-py3.5.egg.

File metadata

  • Download URL: ontobio-0.1.5-py3.5.egg
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ontobio-0.1.5-py3.5.egg
Algorithm Hash digest
SHA256 a21b5a8130549beaf3e86fab52788ee61602d67e1c975d70073bedf630b451a3
MD5 257bf057864882d121ec96b3c29e0fb4
BLAKE2b-256 0c917098c22636e4ee069642b4845c4f664df9db492e19607ddffdb2038a28bb

See more details on using hashes here.

Provenance

File details

Details for the file ontobio-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ontobio-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 881f91182a0082d80931c1f36d36e5d697fe6ae440c4bd576f8e8f9e69a5a9d3
MD5 c52c3fd9b709a545600c5aa6077dd7d5
BLAKE2b-256 36560bfa33c6682e496aeb4a77498e26f2d37fbeff3cb3af60db05d2106a4458

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page