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.



39
40
41
42
43
# File 'lib/obo/ontology.rb', line 39

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.



37
38
39
# File 'lib/obo/ontology.rb', line 37

def elements
  @elements
end

#headerObject

Returns the value of attribute header.



36
37
38
# File 'lib/obo/ontology.rb', line 36

def header
  @header
end

Instance Method Details

#id_to_castObject



50
51
52
# File 'lib/obo/ontology.rb', line 50

def id_to_cast
  @id_to_cast ||= Hash[ id_to_element.map {|id,el| [id, el.cast_method] } ]
end

#id_to_elementObject



59
60
61
# File 'lib/obo/ontology.rb', line 59

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

#id_to_nameObject

returns an id to name Hash



46
47
48
# File 'lib/obo/ontology.rb', line 46

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

#name_to_idObject

returns a name to id Hash



55
56
57
# File 'lib/obo/ontology.rb', line 55

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