class Bio::KEGG::GENOME
Description¶ ↑
Parser for the KEGG GENOME database
References¶ ↑
Constants
- DELIMITER
- TAGSIZE
Public Class Methods
# File lib/bio/db/kegg/genome.rb, line 38 def initialize(entry) super(entry, TAGSIZE) end
Public Instance Methods
CHROMOSOME – Returns contents of the CHROMOSOME records as an Array of Hash.
# File lib/bio/db/kegg/genome.rb, line 140 def chromosomes unless @data['CHROMOSOME'] @data['CHROMOSOME'] = [] toptag2array(get('CHROMOSOME')).each do |chr| hash = Hash.new('') subtag2array(chr).each do |field| hash[tag_get(field)] = truncate(tag_cut(field)) end @data['CHROMOSOME'].push(hash) end end @data['CHROMOSOME'] end
COMMENT – Returns contents of the COMMENT record as a String.
# File lib/bio/db/kegg/genome.rb, line 134 def comment field_fetch('COMMENT') end
DATA_SOURCE – Returns contents of the DATA_SOURCE record as a String.
# File lib/bio/db/kegg/genome.rb, line 106 def data_source field_fetch('DATA_SOURCE') end
DEFINITION – Returns contents of the DEFINITION record as a String.
# File lib/bio/db/kegg/genome.rb, line 75 def definition field_fetch('DEFINITION') end
DISEASE – Returns contents of the COMMENT record as a String.
# File lib/bio/db/kegg/genome.rb, line 129 def disease field_fetch('DISEASE') end
ENTRY – Returns contents of the ENTRY record as a String.
# File lib/bio/db/kegg/genome.rb, line 65 def entry_id field_fetch('ENTRY')[/\S+/] end
Returns contents of the TAXONOMY/LINEAGE record as a String.
# File lib/bio/db/kegg/genome.rb, line 101 def lineage taxonomy['lineage'] end
Returns number of nucleotides from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 189 def nalen statistics['num_nuc'] end
NAME – Returns contents of the NAME record as a String.
# File lib/bio/db/kegg/genome.rb, line 70 def name field_fetch('NAME') end
Returns number of protein genes from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 195 def num_gene statistics['num_gene'] end
Returns number of rna from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 200 def num_rna statistics['num_rna'] end
ORIGINAL_DB – Returns contents of the ORIGINAL_DB record as a String.
# File lib/bio/db/kegg/genome.rb, line 111 def original_db #field_fetch('ORIGINAL_DB') unless defined?(@original_db) @original_db = fetch('ORIGINAL_DB') end @original_db end
PLASMID – Returns contents of the PLASMID records as an Array of Hash.
# File lib/bio/db/kegg/genome.rb, line 155 def plasmids unless @data['PLASMID'] @data['PLASMID'] = [] toptag2array(get('PLASMID')).each do |chr| hash = Hash.new('') subtag2array(chr).each do |field| hash[tag_get(field)] = truncate(tag_cut(field)) end @data['PLASMID'].push(hash) end end @data['PLASMID'] end
REFERENCE – Returns contents of the REFERENCE records as an Array of Bio::Reference objects.
# File lib/bio/db/kegg/genome.rb, line 35 def references; super; end
STATISTICS – Returns contents of the STATISTICS record as a Hash.
# File lib/bio/db/kegg/genome.rb, line 170 def statistics unless @data['STATISTICS'] hash = Hash.new(0.0) get('STATISTICS').each_line do |line| case line when /nucleotides:\s+(\d+)/ hash['num_nuc'] = $1.to_i when /protein genes:\s+(\d+)/ hash['num_gene'] = $1.to_i when /RNA genes:\s+(\d+)/ hash['num_rna'] = $1.to_i end end @data['STATISTICS'] = hash end @data['STATISTICS'] end
TAXONOMY – Returns contents of the TAXONOMY record as a Hash.
# File lib/bio/db/kegg/genome.rb, line 81 def taxonomy unless @data['TAXONOMY'] taxid, lineage = subtag2array(get('TAXONOMY')) taxid = taxid ? truncate(tag_cut(taxid)) : '' lineage = lineage ? truncate(tag_cut(lineage)) : '' @data['TAXONOMY'] = { 'taxid' => taxid, 'lineage' => lineage, } @data['TAXONOMY'].default = '' end @data['TAXONOMY'] end
Private Instance Methods
(private) Returns a String of the field without a tag name. Needed to redefine because of the PLASMID field.
# File lib/bio/db/kegg/genome.rb, line 55 def tag_cut(str) if /\APLASMID\s+/ =~ str.to_s then $' else super(str) end end
(private) Returns a tag name of the field as a String. Needed to redefine because of the PLASMID field.
# File lib/bio/db/kegg/genome.rb, line 44 def tag_get(str) if /\APLASMID\s+/ =~ str.to_s then 'PLASMID' else super(str) end end