Class: Chem::KEGG::KeggReactionLstParser
- Inherits:
-
Object
- Object
- Chem::KEGG::KeggReactionLstParser
- Includes:
- KeggFormat, Enumerable
- Defined in:
- lib/chem/db/kegg.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(filename) ⇒ KeggReactionLstParser
constructor
A new instance of KeggReactionLstParser.
Methods included from KeggFormat
#compound_folder=, #each_entry
Constructor Details
#initialize(filename) ⇒ KeggReactionLstParser
Returns a new instance of KeggReactionLstParser.
337 338 339 |
# File 'lib/chem/db/kegg.rb', line 337 def initialize filename @input = open(filename) end |
Instance Method Details
#each ⇒ Object
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/chem/db/kegg.rb', line 341 def each @input.each do |line| rxn = KEGGReaction.new r_number, comps = line.split(":") rxn.entry = r_number cc = comps.split(/<=>/) reactant = cc[0].split("+").collect do |c| ary = c.split #compound = KeggCompound.new if ary.length == 1 #compound.entry = c.strip [c.strip, 1] else #compound.entry = ary[1].strip [c.strip, ary[0].to_i] end end product = cc[1].split("+").collect do |c| ary = c.split #compound = KeggCompound.new if ary.length == 1 #compound.entry = c.strip [c.strip, 1] else #compound.entry = ary[1].strip [c.strip, ary[0].to_i] end end rxn.compounds = [reactant, product] yield rxn end end |