Class Bio::KEGG::GENES
In: lib/bio/db/kegg/genes.rb  (CVS)
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

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

# File lib/bio/db/kegg/genes.rb, line 158
  def chromosome
    if position[/:/]
      position.sub(/:.*/, '')
    elsif ! position[/\.\./]
      position
    else
      nil
    end
  end

[Source]

# File lib/bio/db/kegg/genes.rb, line 206
  def codon_usage(codon = nil)
    unless @data['CODON_USAGE']
      hash = Hash.new
      list = cu_list
      base = %w(t c a g)
      base.each_with_index do |x, i|
        base.each_with_index do |y, j|
          base.each_with_index do |z, k|
            hash["#{x}#{y}#{z}"] = list[i*16 + j*4 + k]
          end
        end
      end
      @data['CODON_USAGE'] = hash
    end
    @data['CODON_USAGE']
  end

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

# File lib/bio/db/kegg/genes.rb, line 88
  def entry
    unless @data['ENTRY']
      hash = Hash.new('')
      if get('ENTRY').length > 30
        e = get('ENTRY')
        hash['id']       = e[12..29].strip
        hash['division'] = e[30..39].strip
        hash['organism'] = e[40..80].strip
      end
      @data['ENTRY'] = hash
    end
    @data['ENTRY']
  end

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

# File lib/bio/db/kegg/genes.rb, line 176
  def motif
    unless @data['MOTIF']
      hash = {}
      db = nil
      lines_fetch('MOTIF').each do |line|
        if line[/^\S+:/]
          db, str = line.split(/:/)
        else
          str = line
        end
        hash[db] ||= []
        hash[db] += str.strip.split(/\s+/)
      end
      @data['MOTIF'] = hash
    end
    @data['MOTIF']              # Hash of Array of IDs in MOTIF
  end
nalen()

Alias for ntlen

[Source]

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

Alias for ntseq

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]