class OboParser::OboParser

Attributes

terms[RW]
typedefs[RW]

Public Class Methods

new() click to toggle source
# File lib/obo_parser.rb, line 18
def initialize 
  @terms = []
  @typedefs = [] 
  true
end

Public Instance Methods

id_hash() click to toggle source

Returns a hash of 'id:012345' => 'term label'

@return [Hash] a hash of {id => string} for the file

# File lib/obo_parser.rb, line 39
def id_hash
  @terms.inject({}) {|sum, t| sum.update(t.id.value => t.name.value)}
end
id_index() click to toggle source

Returns a hash of 'id:012345' => Term

@return [Hash] a hash of {id => Term} for the file

# File lib/obo_parser.rb, line 46
def id_index 
  @terms.inject({}) {|sum, t| sum.update(t.id.value => t)}
end
term_hash() click to toggle source

Warning! This assumes terms are unique, they are NOT required to be so in an OBO file. Ignores hash colisions!! @return [Hash]

(String => String) (name => id)
# File lib/obo_parser.rb, line 32
def term_hash
  @terms.inject({}) {|sum, t| sum.update(t.name.value => t.id.value)}
end
term_strings() { |Array of Strings| ... } click to toggle source
# File lib/obo_parser.rb, line 24
def term_strings # :yields: Array of Strings
  @terms.collect{|t| t.name.value}.sort
end