109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/chem/db/kcf.rb', line 109
def each
while ! @input.eof?
entry = ReactionEntry.new
state = :INITIAL
while ! /\/\/\//.match(line = @input.readline)
type = line[0...12]
if 'ENTRY ' == type
entry.entry = line[12...-1]
elsif 'NAME ' == type || state == :NAME
state = :NAME
entry.name = line[12...-1]
elsif 'DEFINITION ' == type || state == :DEFINITION
state = :DEFINITION
entry.definition.push(line[12...-1])
elsif 'EQUATION ' == type
ary = line[12...-1].split('<=>')
entry.reactants = ary[0].split('+').collect{|mol| mol.strip}
entry.products = ary[1].split('+').collect{|mol| mol.strip}
elsif 'RPAIR ' == type
entry.rpair = line[12...-1]
elsif 'ENZYME ' == type
entry.ec = line[12...-1].split('.').collect{|n| n.to_i}
elsif 'COMMENT ' == type || state == :COMMENT
state = :COMMENT
entry..push(line[12...-1])
elsif 'PATHWAY ' == type || state == :PATHWAY
state = :PATHWAY
else
puts "Error Unknown line : %s" % line
end
end
yield entry
end
end
|