From: Geoffrey H. <ge...@ge...> - 2006-03-15 19:18:53
|
On Mar 15, 2006, at 5:18 AM, Noel O'Boyle wrote: > It seems that OBConversion.ReadFile(OBMolecule) just reads in the > first > molecule, and I cannot see a way of iterating over the molecules. The OBConversion.Read(OBMol) function should continue to read from the same file. However, since Python and Perl have no concept of "streams", it's not possible to use OBConversion.Read() to set up the input file or string. So something like this (sorry, I haven't written much Python, so the syntax might be off): import openbabel mol = openbabel.OBMol() conv = openbabel.OBConversion() conv.SetInAndOutFormats("sdf", "sdf") obConversion.ReadString(mol, "test.sdf") while (obConversion.Read(mol)) ... Cheers, -Geoff |