Class: Chem::KEGG::KCFCorrespondence
- Inherits:
-
Object
- Object
- Chem::KEGG::KCFCorrespondence
- Defined in:
- lib/chem/db/kcf.rb
Instance Attribute Summary collapse
-
#compounds ⇒ Object
readonly
Returns the value of attribute compounds.
-
#correspondence ⇒ Object
readonly
Returns the value of attribute correspondence.
Instance Method Summary collapse
-
#initialize(input) ⇒ KCFCorrespondence
constructor
A new instance of KCFCorrespondence.
- #make_rxn(dir) ⇒ Object
- #parse(input) ⇒ Object
Constructor Details
#initialize(input) ⇒ KCFCorrespondence
Returns a new instance of KCFCorrespondence.
222 223 224 225 226 227 228 |
# File 'lib/chem/db/kcf.rb', line 222 def initialize input @name = [] @input = input @compounds = [] @correspondence = {} parse(input) end |
Instance Attribute Details
#compounds ⇒ Object (readonly)
Returns the value of attribute compounds.
220 221 222 |
# File 'lib/chem/db/kcf.rb', line 220 def compounds @compounds end |
#correspondence ⇒ Object (readonly)
Returns the value of attribute correspondence.
220 221 222 |
# File 'lib/chem/db/kcf.rb', line 220 def correspondence @correspondence end |
Instance Method Details
#make_rxn(dir) ⇒ Object
230 231 232 233 234 235 236 237 238 |
# File 'lib/chem/db/kcf.rb', line 230 def make_rxn dir reactant = KCF.open("#{dir}#{@compounds[0]}.kcf") product = KCF.open("#{dir}#{@compounds[1]}.kcf") rxn = KCFRXN.new(reactant, product) @correspondence.each do |k, corres| rxn.corresponds(corres[0][0], corres[1][0]) end rxn.setup_bonds end |
#parse(input) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/chem/db/kcf.rb', line 240 def parse input while ! /\/\/\//.match(line = input.readline) case line[0...12] when 'ENTRY ' @no = /(\d+)/.match(line)[1].to_i when 'NAME ' @name.push(line[12...-1]) when 'COMPOUND ' @compounds.push(line[12...-1]) when 'TYPE ' @type = line[12...-1] when 'ALIGN ' @align = line[12...-1].to_i alignment_mode = true else ary = line[12...-1].split @correspondence[ary[0].to_i] = ary[1..2].collect{|e| a = e.split(':'); [a[0].to_i, a[1]]} end end end |