Project

ols

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
OLS provides a simple interface to the EBI's Ontology Lookup Service (http://www.ebi.ac.uk/ontology-lookup/). It provides an easy lookup of ontology terms and automagically builds up ontology trees for you.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

rubygems.org/gems/ols github.com/dazoakley/ols

OLS provides a simple interface to the EBI’s Ontology Lookup Service (www.ebi.ac.uk/ontology-lookup/). It provides an easy lookup of ontology terms and automagically builds up ontology graphs.

Install¶ ↑

gem install ols

Basic Usage¶ ↑

Include the module in your code:

require 'rubygems'
require 'ols'

Then, to lookup an ontology term:

ont = OLS.find_by_id('EMAP:3018')

This will create a simple tree object for the EMAP term EMAP:3018

ont.term_id             # => "EMAP:3018"
ont.term_name           # => "TS18,nose"

Find out about your ontology term

ont.is_root?            # => false
ont.is_leaf?            # => false
ont.to_s                # => "EMAP:3018 - TS18,nose"

The graph for the term is built up (parents) and down (children) as it is requested:

ont.parents             # => Array of all parent terms objects
ont.children            # => Array of all direct child term objects

Alternatively, if you want to force load the graph (around this term):

ont.focus_graph!        # => Will load all parents and children into the graph
ont.size                # => 19

Find out more about your graph:

ont.root                # => Gives you the root node - in this case: "EMAP:0"
ont.all_parent_ids      # => An array of all parent ontology terms
ont.all_parent_names    # => An array of all parent ontology term names
ont.all_child_ids       # => An array of all child ontology terms
ont.all_child_names     # => An array of all child ontology term names

Visualise your graph (useful for exploring):

ont.root.print_graph

# Gives the following:
#
# * EMAP:0
#     |---+ EMAP:2636
#         |---+ EMAP:2822
#             |---+ EMAP:2987
#                 |---+ EMAP:3018
#                     |---+ EMAP:3022
#                         |---+ EMAP:3023
#                             |---+ EMAP:3024
#                                 |---> EMAP:3025
#                                 |---> EMAP:3026
#                             |---+ EMAP:3027
#                                 |---> EMAP:3029
#                                 |---> EMAP:3028
#                             |---+ EMAP:3030
#                                 |---> EMAP:3031
#                                 |---> EMAP:3032
#                     |---> EMAP:3019
#                     |---+ EMAP:3020
#                         |---> EMAP:3021
#

More documentation can be found on the OLS module and OLS::Term rdoc pages.

Advanced Usage¶ ↑

More to come…

Caching¶ ↑

If you regularly hit up one or more ontology with lots of queries it might be in your interest to store a local on-disk copy of the entire ontology graph. This will protect you against network problems and will stop you hitting OLS with many repeated service calls.

The OLS gem has a basic caching layer built into it that allows you to store the entire graph for your most used ontologies on disk. To setup/invoke the cache, do the following:

OLS.setup_cache({ :directory => '/tmp/ols_cache' })

This will create a cache directory (/tmp/ols_cache) if it does not exist, or read in configuration files etc if it is an already existing OLS cache directory. If you do not pass in a configuration hash it will use the current working directory by default.

Now, to add an ontology to the cache, you do the following:

OLS.add_ontology_to_cache("EMAP")

This will add the entire EMAP ontology graph to the cache (this will take a while) - now all calls for EMAP terms will go via the cache, all other queries will still call the OLS web services. (There is no dynamic cache build-up over time).

To remove an ontology graph from the cache:

OLS.remove_ontology_from_cache("EMAP")

Different cache back-ends and other features will be built into future releases.

Meta¶ ↑

Written by Darren Oakley (daz dot oakley at gmail dot com)

rubygems.org/gems/ols github.com/dazoakley/ols

License¶ ↑

(The MIT License)

Copyright © 2011 Darren Oakley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.