Class: OboParser::OboParser
- Inherits:
-
Object
- Object
- OboParser::OboParser
- Defined in:
- lib/obo_parser.rb
Defined Under Namespace
Classes: Stanza, Tag, Term, Typedef
Instance Attribute Summary collapse
-
#terms ⇒ Object
Returns the value of attribute terms.
-
#typedefs ⇒ Object
Returns the value of attribute typedefs.
Instance Method Summary collapse
-
#id_hash ⇒ Hash
Returns a hash of ‘id:012345’ => ‘term label’.
-
#id_index ⇒ Hash
Returns a hash of ‘id:012345’ => Term.
-
#initialize ⇒ OboParser
constructor
A new instance of OboParser.
-
#term_hash ⇒ Object
Warning! This assumes terms are unique, they are NOT required to be so in an OBO file.
-
#term_strings ⇒ Object
:yields: Array of Strings.
Constructor Details
#initialize ⇒ OboParser
Returns a new instance of OboParser.
18 19 20 21 22 |
# File 'lib/obo_parser.rb', line 18 def initialize @terms = [] @typedefs = [] true end |
Instance Attribute Details
#terms ⇒ Object
Returns the value of attribute terms.
16 17 18 |
# File 'lib/obo_parser.rb', line 16 def terms @terms end |
#typedefs ⇒ Object
Returns the value of attribute typedefs.
16 17 18 |
# File 'lib/obo_parser.rb', line 16 def typedefs @typedefs end |
Instance Method Details
#id_hash ⇒ Hash
Returns a hash of ‘id:012345’ => ‘term label’
37 38 39 |
# File 'lib/obo_parser.rb', line 37 def id_hash @terms.inject({}) {|sum, t| sum.update(t.id.value => t.name.value)} end |
#id_index ⇒ Hash
Returns a hash of ‘id:012345’ => Term
44 45 46 |
# File 'lib/obo_parser.rb', line 44 def id_index @terms.inject({}) {|sum, t| sum.update(t.id.value => t)} end |
#term_hash ⇒ Object
Warning! This assumes terms are unique, they are NOT required to be so in an OBO file. Ignores hash colisions!!
30 31 32 |
# File 'lib/obo_parser.rb', line 30 def term_hash # :yields: Hash (String => String) (name => id) @terms.inject({}) {|sum, t| sum.update(t.name.value => t.id.value)} end |
#term_strings ⇒ Object
:yields: Array of Strings
24 25 26 |
# File 'lib/obo_parser.rb', line 24 def term_strings # :yields: Array of Strings @terms.collect{|t| t.name.value}.sort end |