Class: Obo::Ontology

Inherits:
Object
  • Object
show all
Defined in:
lib/obo/ontology.rb

Constant Summary collapse

DIR =
File.expand_path(File.dirname(__FILE__) + '/../../obo')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_or_io) ⇒ Ontology

Returns a new instance of Ontology.



9
10
11
12
13
# File 'lib/obo/ontology.rb', line 9

def initialize(file_or_io)
  obo = Obo::Parser.new(file_or_io)
  @elements = obo.elements.to_a
  @header = elements.shift
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



7
8
9
# File 'lib/obo/ontology.rb', line 7

def elements
  @elements
end

#headerObject

Returns the value of attribute header.



6
7
8
# File 'lib/obo/ontology.rb', line 6

def header
  @header
end

Instance Method Details

#id_to_elementObject



23
24
25
# File 'lib/obo/ontology.rb', line 23

def id_to_element
  @id_to_element ||= build_hash('id', nil)
end

#id_to_nameObject

returns an id to name Hash



16
17
18
# File 'lib/obo/ontology.rb', line 16

def id_to_name
  @id_to_name ||= build_hash('id', 'name')
end

#name_to_idObject

returns a name to id Hash



20
21
22
# File 'lib/obo/ontology.rb', line 20

def name_to_id
  @name_to_id ||= build_hash('name', 'id')
end