297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
# File 'lib/chem/db/kcf.rb', line 297
def read input, &method
status = :NEW
mol = KCFMolecule.new
input.each do |line|
case line[0..11]
when /ANUMBER/
mol.a_no = /A(\d+)/.match(line)[1].to_i
when /ENTRY/
entry = /C(\d+)/.match(line)[1].to_i
when /ATOM/
n_atoms = /(\d+)/.match(line)[1].to_i
status = :ATOM
when /BOND/
n_bonds = /(\d+)/.match(line)[1].to_i
status = :BOND
when /\/\/\//
if(method)
yield mol
end
mol = KCFMolecule.new
status = :NEW
else
case status
when :ATOM
atom = KCFAtom.new
atom.number, atom.kcf_type, atom.element, atom.x, atom.y, = line[12..-1].scanf("%d%s%s%f%f%s")
mol.atoms[atom.number] = atom
when :BOND
bond = KCFBond.new
no, b, e, bond.multiplicity, prop = line[12..-1].scanf("%d%d%d%d%s")
bond.b = mol.atoms[b]
bond.e = mol.atoms[e]
mol.bonds.push(bond)
end
end
end
end
|