Class | Bio::KEGG::GENES
In: | lib/bio/db/kegg/genes.rb
Parent: | KEGGDB

### Methods

aalen aaseq chromosome codon_usage cu_list dblinks definition division eclinks entry entry_id gbposition gene genes locations motif nalen name naseq new ntlen ntseq organism orthologs pathway pathways position

### Constants

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

### Public Class methods

new(entry)

[Source]

        # File lib/bio/db/kegg/genes.rb, line 83
    83:   def initialize(entry)
    84:     super(entry, TAGSIZE)
    85:   end

### Public Instance methods

aalen()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 240
    240:   def aalen
    241:     fetch('AASEQ')[/\d+/].to_i
    242:   end

aaseq()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 233
    233:   def aaseq
    234:     unless @data['AASEQ']
    235:       @data['AASEQ'] = Bio::Sequence::AA.new(fetch('AASEQ').gsub(/\d+/, ''))
    236:     end
    237:     @data['AASEQ']
    238:   end

chromosome()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 158
    158:   def chromosome
    159:     if position[/:/]
    160:       position.sub(/:.*/, '')
    161:     elsif ! position[/\.\./]
    162:       position
    163:     else
    164:       nil
    165:     end
    166:   end

codon_usage(codon = nil)

[Source]

         # File lib/bio/db/kegg/genes.rb, line 206
    206:   def codon_usage(codon = nil)
    207:     unless @data['CODON_USAGE']
    208:       hash = Hash.new
    209:       list = cu_list
    210:       base = %w(t c a g)
    211:       base.each_with_index do |x, i|
    212:         base.each_with_index do |y, j|
    213:           base.each_with_index do |z, k|
    214:             hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k]
    215:           end
    216:         end
    217:       end
    218:       @data['CODON_USAGE'] = hash
    219:     end
    220:     @data['CODON_USAGE']
    221:   end

cu_list()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 223
    223:   def cu_list
    224:     ary = []
    225:     get('CODON_USAGE').sub(/.*/,'').each_line do |line| # cut 1st line
    226:       line.chomp.sub(/^.{11}/, '').scan(/..../) do |cu|
    227:         ary.push(cu.to_i)
    228:       end
    229:     end
    230:     return ary
    231:   end

dblinks()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 194
    194:   def dblinks
    195:     unless @data['DBLINKS']
    196:       hash = {}
    197:       get('DBLINKS').scan(/(\S+):\s*(.*)\n?/).each do |db, str|
    198:         id_array = str.strip.split(/\s+/)
    199:         hash[db] = id_array
    200:       end
    201:       @data['DBLINKS'] = hash
    202:     end
    203:     @data['DBLINKS']            # Hash of Array of IDs in DBLINKS
    204:   end

definition()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 126
    126:   def definition
    127:     field_fetch('DEFINITION')
    128:   end

division()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 106
    106:   def division
    107:     entry['division']                   # CDS, tRNA etc.
    108:   end

eclinks()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 130
    130:   def eclinks
    131:     ec_list = definition.slice(/\[EC:(.*?)\]/, 1)
    132:     if ec_list
    133:       ec_list.strip.split(/\s+/)
    134:     else
    135:       []
    136:     end
    137:   end

entry()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 88
     88:   def entry
     89:     unless @data['ENTRY']
     90:       hash = Hash.new('')
     91:       if get('ENTRY').length > 30
     92:         e = get('ENTRY')
     93:         hash['id']       = e[12..29].strip
     94:         hash['division'] = e[30..39].strip
     95:         hash['organism'] = e[40..80].strip
     96:       end
     97:       @data['ENTRY'] = hash
     98:     end
     99:     @data['ENTRY']
    100:   end

entry_id()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 102
    102:   def entry_id
    103:     entry['id']
    104:   end

gbposition()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 168
    168:   def gbposition
    169:     position.sub(/.*?:/, '')
    170:   end

gene()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 122
    122:   def gene
    123:     genes.first
    124:   end

genes()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 118
    118:   def genes
    119:     name.split(', ')
    120:   end

locations()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 172
    172:   def locations
    173:     Bio::Locations.new(gbposition)
    174:   end

motif()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 176
    176:   def motif
    177:     unless @data['MOTIF']
    178:       hash = {}
    179:       db = nil
    180:       lines_fetch('MOTIF').each do |line|
    181:         if line[/^\S+:/]
    182:           db, str = line.split(/:/)
    183:         else
    184:           str = line
    185:         end
    186:         hash[db] ||= []
    187:         hash[db] += str.strip.split(/\s+/)
    188:       end
    189:       @data['MOTIF'] = hash
    190:     end
    191:     @data['MOTIF']              # Hash of Array of IDs in MOTIF
    192:   end

nalen()

Alias for ntlen

name()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 114
    114:   def name
    115:     field_fetch('NAME')
    116:   end

naseq()

Alias for ntseq

ntlen()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 252
    252:   def ntlen
    253:     fetch('NTSEQ')[/\d+/].to_i
    254:   end

ntseq()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 244
    244:   def ntseq
    245:     unless @data['NTSEQ']
    246:       @data['NTSEQ'] = Bio::Sequence::NA.new(fetch('NTSEQ').gsub(/\d+/, ''))
    247:     end
    248:     @data['NTSEQ']
    249:   end

organism()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 110
    110:   def organism
    111:     entry['organism']                   # H.sapiens etc.
    112:   end

orthologs()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 139
    139:   def orthologs
    140:     lines_fetch('ORTHOLOGY')
    141:   end

pathway()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 143
    143:   def pathway
    144:     field_fetch('PATHWAY')
    145:   end

pathways()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 147
    147:   def pathways
    148:     pathway.scan(/\[PATH:(.*?)\]/).flatten
    149:   end

position()

[Source]

         # File lib/bio/db/kegg/genes.rb, line 151
    151:   def position
    152:     unless @data['POSITION']
    153:       @data['POSITION'] = fetch('POSITION').gsub(/\s/, '')
    154:     end
    155:     @data['POSITION']
    156:   end

[Validate]