Class: Bio::KEGG::ORTHOLOGY
- Inherits:
-
Bio::KEGGDB
- Object
- DB
- NCBIDB
- Bio::KEGGDB
- Bio::KEGG::ORTHOLOGY
- 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
-
#dblinks ⇒ Object
Returns an Array of a database name and entry IDs in DBLINKS field.
-
#dblinks_as_hash ⇒ Object
Returns a Hash of the DB name and an Array of entry IDs in DBLINKS field.
-
#definition ⇒ Object
Returns DEFINITION field of the entry.
-
#entry_id ⇒ Object
Returns ID of the entry.
-
#genes ⇒ Object
Returns an Array of the organism ID and entry IDs in GENES field.
-
#genes_as_hash ⇒ Object
Returns a Hash of the organism ID and an Array of entry IDs in GENES field.
-
#initialize(entry) ⇒ ORTHOLOGY
constructor
Reads a flat file format entry of the KO database.
-
#keggclass ⇒ Object
Returns CLASS field of the entry.
-
#keggclasses ⇒ Object
Returns an Array of biological classes in CLASS field.
-
#name ⇒ Object
Returns NAME field of the entry.
-
#names ⇒ Object
Returns an Array of names in NAME field.
-
#pathways ⇒ Object
Returns an Array of KEGG/PATHWAY ID in CLASS field.
Methods inherited from DB
#exists?, #fetch, #get, open, #tags
Constructor Details
Instance Method Details
#dblinks ⇒ Object
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 |
#dblinks_as_hash ⇒ Object
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 |
#definition ⇒ Object
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_id ⇒ Object
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 |
#genes ⇒ Object
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_hash ⇒ Object
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 |
#keggclass ⇒ Object
Returns CLASS field of the entry.
56 57 58 |
# File 'lib/bio/db/kegg/orthology.rb', line 56 def keggclass field_fetch('CLASS') end |
#keggclasses ⇒ Object
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 |
#name ⇒ Object
Returns NAME field of the entry.
41 42 43 |
# File 'lib/bio/db/kegg/orthology.rb', line 41 def name field_fetch('NAME') end |
#names ⇒ Object
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 |
#pathways ⇒ Object
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 |