| Class | Bio::KEGG::GENES |
| In: |
lib/bio/db/kegg/genes.rb
|
| Parent: | KEGGDB |
| DELIMITER | = | RS = "\n///\n" |
| TAGSIZE | = | 12 |
# File lib/bio/db/kegg/genes.rb, line 83
83: def initialize(entry)
84: super(entry, TAGSIZE)
85: end
# 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
# 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
# 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
# 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
# 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
# File lib/bio/db/kegg/genes.rb, line 126
126: def definition
127: field_fetch('DEFINITION')
128: end
# File lib/bio/db/kegg/genes.rb, line 106
106: def division
107: entry['division'] # CDS, tRNA etc.
108: end
# 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
# 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
# File lib/bio/db/kegg/genes.rb, line 168
168: def gbposition
169: position.sub(/.*?:/, '')
170: end
# File lib/bio/db/kegg/genes.rb, line 172
172: def locations
173: Bio::Locations.new(gbposition)
174: end
# 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
# 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
# File lib/bio/db/kegg/genes.rb, line 110
110: def organism
111: entry['organism'] # H.sapiens etc.
112: end
# File lib/bio/db/kegg/genes.rb, line 147
147: def pathways
148: pathway.scan(/\[PATH:(.*?)\]/).flatten
149: end