1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#
# = bio/db/kegg/module.rb - KEGG MODULE database class
#
# Copyright:: Copyright (C) 2010 Kozo Nishida <kozo-ni@is.naist.jp>
# Copyright:: Copyright (C) 2010 Toshiaki Katayama <k@bioruby.org>
# License:: The Ruby License
#
#
require 'bio/db'
require 'bio/db/kegg/common'
module Bio
class KEGG
# == Description
#
# Bio::KEGG::MODULE is a parser class for the KEGG MODULE database entry.
#
# == References
#
# * http://www.kegg.jp/kegg-bin/get_htext?ko00002.keg
# * ftp://ftp.genome.jp/pub/kegg/pathway/module
#
class MODULE < KEGGDB
DELIMITER = RS = "\n///\n"
TAGSIZE = 12
#--
# for a private method strings_as_hash.
#++
include Common::StringsAsHash
# Creates a new Bio::KEGG::MODULE object.
# ---
# *Arguments*:
# * (required) _entry_: (String) single entry as a string
# *Returns*:: Bio::KEGG::MODULE object
def initialize(entry)
super(entry, TAGSIZE)
end
# Return the ID, described in the ENTRY line.
# ---
# *Returns*:: String
def entry_id
field_fetch('ENTRY')[/\S+/]
end
# Name of the module, described in the NAME line.
# ---
# *Returns*:: String
def name
field_fetch('NAME')
end
# Definition of the module, described in the DEFINITION line.
# ---
# *Returns*:: String
def definition
field_fetch('DEFINITION')
end
# Name of the KEGG class, described in the CLASS line.
# ---
# *Returns*:: String
def keggclass
field_fetch('CLASS')
end
# Pathways described in the PATHWAY lines.
# ---
# *Returns*:: Array containing String
def pathways_as_strings
lines_fetch('PATHWAY')
end
# Pathways described in the PATHWAY lines.
# ---
# *Returns*:: Hash of pathway ID and its definition
def pathways_as_hash
unless (defined? @pathways_as_hash) && @pathways_as_hash
@pathways_as_hash = strings_as_hash(pathways_as_strings)
end
@pathways_as_hash
end
alias pathways pathways_as_hash
# Orthologs described in the ORTHOLOGY lines.
# ---
# *Returns*:: Array containing String
def orthologs_as_strings
lines_fetch('ORTHOLOGY')
end
# Orthologs described in the ORTHOLOGY lines.
# ---
# *Returns*:: Hash of orthology ID and its definition
def orthologs_as_hash
unless (defined? @orthologs_as_hash) && @orthologs_as_hash
@orthologs_as_hash = strings_as_hash(orthologs_as_strings)
end
@orthologs_as_hash
end
alias orthologs orthologs_as_hash
# All KO IDs in the ORTHOLOGY lines.
# ---
# *Returns*:: Array of orthology IDs
def orthologs_as_array
orthologs_as_hash.keys.map{|x| x.split(/\+|\-|,/)}.flatten.sort.uniq
end
# Reactions described in the REACTION lines.
# ---
# *Returns*:: Array containing String
def reactions_as_strings
lines_fetch('REACTION')
end
# Reactions described in the REACTION lines.
# ---
# *Returns*:: Hash of reaction ID and its definition
def reactions_as_hash
unless (defined? @reactions_as_hash) && @reactions_as_hash
@reactions_as_hash = strings_as_hash(reactions_as_strings)
end
@reactions_as_hash
end
alias reactions reactions_as_hash
# Compounds described in the COMPOUND lines.
# ---
# *Returns*:: Array containing String
def compounds_as_strings
lines_fetch('COMPOUND')
end
# Compounds described in the COMPOUND lines.
# ---
# *Returns*:: Hash of compound ID and its definition
def compounds_as_hash
unless (defined? @compounds_as_hash) && @compounds_as_hash
@compounds_as_hash = strings_as_hash(compounds_as_strings)
end
@compounds_as_hash
end
alias compounds compounds_as_hash
end # MODULE
end # KEGG
end # Bio
|