Class: Bio::KEGG::ORTHOLOGY

Inherits:
Bio::KEGGDB show all
Defined in:
lib/bio/db/kegg/orthology.rb

Overview

Description

KO (KEGG Orthology) entry parser.

References

Constant Summary collapse

DELIMITER =
RS = "\n///\n"
TAGSIZE =
12

Instance Method Summary collapse

Methods inherited from DB

#exists?, #fetch, #get, open, #tags

Constructor Details

#initialize(entry) ⇒ ORTHOLOGY

Reads a flat file format entry of the KO database.



31
32
33
# File 'lib/bio/db/kegg/orthology.rb', line 31

def initialize(entry)
  super(entry, TAGSIZE)
end

Instance Method Details

Returns an Array of a database name and entry IDs in DBLINKS field.



71
72
73
74
75
76
# File 'lib/bio/db/kegg/orthology.rb', line 71

def dblinks
  unless @data['DBLINKS']
    @data['DBLINKS'] = lines_fetch('DBLINKS')
  end
  @data['DBLINKS']
end

Returns a Hash of the DB name and an Array of entry IDs in DBLINKS field.



79
80
81
82
83
84
85
86
87
# File 'lib/bio/db/kegg/orthology.rb', line 79

def dblinks_as_hash
  hash = {}
  dblinks.each do |line|
    name, *list = line.split(/\s+/)
    db = name.downcase.sub(/:/, '')
    hash[db] = list
  end
  return hash
end

#definitionObject

Returns DEFINITION field of the entry.



51
52
53
# File 'lib/bio/db/kegg/orthology.rb', line 51

def definition
  field_fetch('DEFINITION')
end

#entry_idObject

Returns ID of the entry.



36
37
38
# File 'lib/bio/db/kegg/orthology.rb', line 36

def entry_id
  field_fetch('ENTRY')[/\S+/]
end

#genesObject

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



90
91
92
93
94
95
# File 'lib/bio/db/kegg/orthology.rb', line 90

def genes
  unless @data['GENES']
    @data['GENES'] = lines_fetch('GENES')
  end
  @data['GENES']
end

#genes_as_hashObject

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



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/bio/db/kegg/orthology.rb', line 98

def genes_as_hash
  hash = {}
  genes.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
  return hash
end

#keggclassObject

Returns CLASS field of the entry.



56
57
58
# File 'lib/bio/db/kegg/orthology.rb', line 56

def keggclass
  field_fetch('CLASS')
end

#keggclassesObject

Returns an Array of biological classes in CLASS field.



61
62
63
# File 'lib/bio/db/kegg/orthology.rb', line 61

def keggclasses
  keggclass.gsub(/ \[[^\]]+/, '').split(/\] ?/)
end

#nameObject

Returns NAME field of the entry.



41
42
43
# File 'lib/bio/db/kegg/orthology.rb', line 41

def name
  field_fetch('NAME')
end

#namesObject

Returns an Array of names in NAME field.



46
47
48
# File 'lib/bio/db/kegg/orthology.rb', line 46

def names
  name.split(', ')
end

#pathwaysObject

Returns an Array of KEGG/PATHWAY ID in CLASS field.



66
67
68
# File 'lib/bio/db/kegg/orthology.rb', line 66

def pathways
  keggclass.scan(/\[PATH:(.*?)\]/).flatten
end