Module: Bio::KEGG::Common::GenesAsHash

Included in:
ENZYME, ORTHOLOGY
Defined in:
lib/bio/db/kegg/common.rb

Overview

This module provides genes_as_hash method.

Bio::KEGG::* internal use only.

Instance Method Summary (collapse)

Instance Method Details

- (Object) genes_as_hash

Returns a Hash of the organism ID and an Array of entry IDs in GENES field.



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/bio/db/kegg/common.rb', line 157

def genes_as_hash
  unless defined? @genes_as_hash
    hash = {}
    genes_as_strings.each do |line|
      name, *list = line.split(/\s+/)
      org = name.downcase.sub(/:/, '')
      genes = list.map {|x| x.sub(/\(.*\)/, '')}
      #names = list.map {|x| x.scan(/.*\((.*)\)/)}
      hash[org] = genes
    end
    @genes_as_hash = hash
  end
  @genes_as_hash
end