| Class | Bio::KEGG::GENOME |
| In: |
lib/bio/db/kegg/genome.rb
|
| Parent: | KEGGDB |
| DELIMITER | = | RS = "\n///\n" |
| TAGSIZE | = | 12 |
# File lib/bio/db/kegg/genome.rb, line 28
28: def initialize(entry)
29: super(entry, TAGSIZE)
30: end
CHROMOSOME — Returns contents of the CHROMOSOME records as an Array of Hash.
# File lib/bio/db/kegg/genome.rb, line 133
133: def chromosomes
134: unless @data['CHROMOSOME']
135: @data['CHROMOSOME'] = []
136: toptag2array(get('CHROMOSOME')).each do |chr|
137: hash = Hash.new('')
138: subtag2array(chr).each do |field|
139: hash[tag_get(field)] = truncate(tag_cut(field))
140: end
141: @data['CHROMOSOME'].push(hash)
142: end
143: end
144: @data['CHROMOSOME']
145: end
Returns number of nucleotides from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 182
182: def nalen
183: statistics['num_nuc']
184: end
Returns number of protein genes from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 188
188: def num_gene
189: statistics['num_gene']
190: end
Returns number of rna from the STATISTICS record as a Fixnum.
# File lib/bio/db/kegg/genome.rb, line 193
193: def num_rna
194: statistics['num_rna']
195: end
PLASMID — Returns contents of the PLASMID records as an Array of Hash.
# File lib/bio/db/kegg/genome.rb, line 148
148: def plasmids
149: unless @data['PLASMID']
150: @data['PLASMID'] = []
151: toptag2array(get('PLASMID')).each do |chr|
152: hash = Hash.new('')
153: subtag2array(chr).each do |field|
154: hash[tag_get(field)] = truncate(tag_cut(field))
155: end
156: @data['PLASMID'].push(hash)
157: end
158: end
159: @data['PLASMID']
160: end
REFERENCE — Returns contents of the REFERENCE records as an Array of Bio::Reference objects.
# File lib/bio/db/kegg/genome.rb, line 96
96: def references
97: unless @data['REFERENCE']
98: ary = []
99: toptag2array(get('REFERENCE')).each do |ref|
100: hash = Hash.new('')
101: subtag2array(ref).each do |field|
102: case tag_get(field)
103: when /AUTHORS/
104: authors = truncate(tag_cut(field))
105: authors = authors.split(', ')
106: authors[-1] = authors[-1].split(/\s+and\s+/)
107: authors = authors.flatten.map { |a| a.sub(',', ', ') }
108: hash['authors'] = authors
109: when /TITLE/
110: hash['title'] = truncate(tag_cut(field))
111: when /JOURNAL/
112: journal = truncate(tag_cut(field))
113: if journal =~ /(.*) (\d+):(\d+)-(\d+) \((\d+)\) \[UI:(\d+)\]$/
114: hash['journal'] = $1
115: hash['volume'] = $2
116: hash['pages'] = $3
117: hash['year'] = $5
118: hash['medline'] = $6
119: else
120: hash['journal'] = journal
121: end
122: end
123: end
124: ary.push(Reference.new(hash))
125: end
126: @data['REFERENCE'] = References.new(ary)
127: end
128: @data['REFERENCE']
129: end
STATISTICS — Returns contents of the STATISTICS record as a Hash.
# File lib/bio/db/kegg/genome.rb, line 163
163: def statistics
164: unless @data['STATISTICS']
165: hash = Hash.new(0.0)
166: get('STATISTICS').each_line do |line|
167: case line
168: when /nucleotides:\s+(\d+)/
169: hash['num_nuc'] = $1.to_i
170: when /protein genes:\s+(\d+)/
171: hash['num_gene'] = $1.to_i
172: when /RNA genes:\s+(\d+)/
173: hash['num_rna'] = $1.to_i
174: end
175: end
176: @data['STATISTICS'] = hash
177: end
178: @data['STATISTICS']
179: end
TAXONOMY — Returns contents of the TAXONOMY record as a Hash.
# File lib/bio/db/kegg/genome.rb, line 50
50: def taxonomy
51: unless @data['TAXONOMY']
52: taxid, lineage = subtag2array(get('TAXONOMY'))
53: taxid = taxid ? truncate(tag_cut(taxid)) : ''
54: lineage = lineage ? truncate(tag_cut(lineage)) : ''
55: @data['TAXONOMY'] = {
56: 'taxid' => taxid,
57: 'lineage' => lineage,
58: }
59: @data['TAXONOMY'].default = ''
60: end
61: @data['TAXONOMY']
62: end