An OBO file parser.
Ruby
Latest commit 042db8d Aug 29, 2017
Permalink
Failed to load latest commit information.
lib
obo_parser
spec .travis config. viz test. gem bumps. Aug 29, 2017
tasks
test Update to use bundler/rspec. Apr 2, 2017
.document
.gitignore
.travis Travis config Aug 29, 2017
Gemfile
Gemfile.lock Fix cutoff check Aug 29, 2017
Guardfile
LICENSE major refactoring of the underlying data model Apr 5, 2011
README.md Update README.md Aug 29, 2017
Rakefile Module organization. Gemfile bump. Stubbing Viz utilities. Aug 29, 2017
obo_parser.gemspec

README.md

Build Status Dependency Status

obo_parser

A simple Ruby gem for parsing OBO 1.2 (?4) formatted ontology files. Useful for reporting, comparing, and mapping data to other databases. There is presently no functionality for logical inference across the ontology.

Installation

gem install obo_parser

Use

General

require 'obo_parser'
o = parse_obo_file(File.read('my_ontology.obo'))  # => An OboParser instance  
first_term = o.terms.first                        # => An OboParser#Term instance 

first_term.id.value                                 # => 'HAO:1234'

d = first_term.def                                  # => An OboParser#Tag instance
d.tag                                               # => 'def'
d.value                                             # => 'Some defintition'
d.xrefs                                             # => ['xref:123', 'xref:456'] 
d.comment                                           # => 'Some comment'

t = first_term.name                                 # => An OboParser#Tag instance    
t.tag                                               # => 'name'
t.value                                             # => 'Some Term name' 

o = first_term.other_tags                           # => [OboParser#Tag, ... ] An array of tags that are not specially referenced in an OboParser::Stanza
o.first                                             # => An OboParser#Tag instance    

first_typedef = o.typdefs.first                   # => An OboParser#Typdef instance 
first_typdef.id.value                               # => 'Some typedef id'
first_typdef.name.value                             # => 'Some typedef name'

o.terms.first.tags_named('synonym')               # => [OboParser#Tag, ... ]
o.terms.first.tags_named('synonym').first.tag     # => 'synonym'
o.terms.first.tags_named('synonym').first.value   # => 'Some label'

o.terms.first.relationships                       # => [['relationship', 'FOO:123'], ['other_relationship', 'FOO:456'] ...] An array of [relation, related term id], includes 'is_a', 'disjoint_from' and Typedefs

Convenience methods

o.term_hash                                       # => { term (String) => id (String), ... for each [Term] in the file. } !! Assumes names terms are unique, they might not be, in which case you get key collisions. 
o.id_hash                                         # => { id (String) => term (String), ... for each [Term] in the file. } 

See also /test/test_obo_parser.rb

Utilities

A small set of methods (e.g. comparing OBO ontologies) utilizing the gem are included in /lib/utilities.rb. For example: 1) shared labels across sets of ontologies can be found and returned, 2) ontologies can be dumped into a simple Cytoscape node/edge format; 3) given a set of correspondances between two ontologies various reports can be made.

Viz

OboParser::Utilities::Viz.mock_coordinate_space(o, size: 100) # => STDOUT tab delimited table with x, y, z, identifier, label 

Contributing

Fork, test, code, test, pull request.

Copyright

Copyright (c) 2010-2017 Matt Yoder. See LICENSE for details.

License

MIT