Class: Bio::KEGG::GENOME

Inherits:
Bio::KEGGDB show all
Includes:
Common::References
Defined in:
lib/bio/db/kegg/genome.rb

Overview

Constant Summary collapse

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

Instance Method Summary collapse

Methods inherited from DB

#exists?, #fetch, #get, open, #tags

Constructor Details

#initialize(entry) ⇒ GENOME

Returns a new instance of GENOME.



38
39
40
# File 'lib/bio/db/kegg/genome.rb', line 38

def initialize(entry)
  super(entry, TAGSIZE)
end

Instance Method Details

#chromosomesObject

CHROMOSOME – Returns contents of the CHROMOSOME records as an Array of Hash.



140
141
142
143
144
145
146
147
148
149
150
151
152
# 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

#commentObject

COMMENT – Returns contents of the COMMENT record as a String.



134
135
136
# File 'lib/bio/db/kegg/genome.rb', line 134

def comment
  field_fetch('COMMENT')
end

#data_sourceObject

DATA_SOURCE – Returns contents of the DATA_SOURCE record as a String.



106
107
108
# File 'lib/bio/db/kegg/genome.rb', line 106

def data_source
  field_fetch('DATA_SOURCE')
end

#definitionObject Also known as: organism

DEFINITION – Returns contents of the DEFINITION record as a String.



75
76
77
# File 'lib/bio/db/kegg/genome.rb', line 75

def definition
  field_fetch('DEFINITION')
end

#diseaseObject

DISEASE – Returns contents of the COMMENT record as a String.



129
130
131
# File 'lib/bio/db/kegg/genome.rb', line 129

def disease
  field_fetch('DISEASE')
end

#entry_idObject

ENTRY – Returns contents of the ENTRY record as a String.



65
66
67
# File 'lib/bio/db/kegg/genome.rb', line 65

def entry_id
  field_fetch('ENTRY')[/\S+/]
end

#lineageObject

Returns contents of the TAXONOMY/LINEAGE record as a String.



101
102
103
# File 'lib/bio/db/kegg/genome.rb', line 101

def lineage
  taxonomy['lineage']
end

#nalenObject Also known as: length

Returns number of nucleotides from the STATISTICS record as a Fixnum.



189
190
191
# File 'lib/bio/db/kegg/genome.rb', line 189

def nalen
  statistics['num_nuc']
end

#nameObject

NAME – Returns contents of the NAME record as a String.



70
71
72
# File 'lib/bio/db/kegg/genome.rb', line 70

def name
  field_fetch('NAME')
end

#num_geneObject

Returns number of protein genes from the STATISTICS record as a Fixnum.



195
196
197
# File 'lib/bio/db/kegg/genome.rb', line 195

def num_gene
  statistics['num_gene']
end

#num_rnaObject

Returns number of rna from the STATISTICS record as a Fixnum.



200
201
202
# File 'lib/bio/db/kegg/genome.rb', line 200

def num_rna
  statistics['num_rna']
end

#original_databasesObject

Returns ORIGINAL_DB record as an Array containing String objects.


Arguments:

Returns

Array containing String objects



124
125
126
# File 'lib/bio/db/kegg/genome.rb', line 124

def original_databases
  lines_fetch('ORIGINAL_DB')
end

#original_dbObject

ORIGINAL_DB – Returns contents of the ORIGINAL_DB record as a String.



111
112
113
114
115
116
117
# 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

#plasmidsObject

PLASMID – Returns contents of the PLASMID records as an Array of Hash.



155
156
157
158
159
160
161
162
163
164
165
166
167
# 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

#referencesObject

REFERENCE – Returns contents of the REFERENCE records as an Array of Bio::Reference objects.



35
# File 'lib/bio/db/kegg/genome.rb', line 35

def references; super; end

#statisticsObject

STATISTICS – Returns contents of the STATISTICS record as a Hash.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# 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

#taxidObject

Returns NCBI taxonomy ID from the TAXONOMY record as a String.



96
97
98
# File 'lib/bio/db/kegg/genome.rb', line 96

def taxid
  taxonomy['taxid']
end

#taxonomyObject

TAXONOMY – Returns contents of the TAXONOMY record as a Hash.



81
82
83
84
85
86
87
88
89
90
91
92
93
# 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