From: Noel O'B. <no...@ca...> - 2005-12-06 10:03:08
|
Dear all, I have been thinking about developing a more Pythonic interface to OpenBabel, PyOpenBabel, along the same idea as PyDaylight, for the Daylight library (Andrew Dalke). It is a wrapper around the SWIG interface to OpenBabel. The motivation is: (1) to provide easy access to attributes and methods (no need for GetVar()) (2) to keep things simple (only one good way to do things) (3) things should work 'as expected' in Python (iterators, etc.) For example, the following sort of commands should work: ----------------------- for atom in molecule.atoms: (or even 'for atom in molecule' !) print atom.coords print atom.element text = molecule.write("SDF") molecule.write("SMILES",filename="mymolecule.smi") print vars(atom).keys() # Show the attributes of 'atom', like dir(atom) ['index', 'hyb', 'valence', 'coordidx', 'formalcharge', 'idx', 'implicitvalence', 'type', 'partialcharge', 'heterovalence', 'isotope', 'cidx', 'coords', 'vector', 'atomicnum', 'atomicmass', 'OBAtom', 'spin', 'exactmass', 'heavyvalence', 'data'] ----------------------- It should be possible to access 90% of the OpenBabel library following these guidelines, and the other 10% can be accessed by 'advanced users' through the original OpenBabel objects, atom.OBAtom in the example above. I have done some work towards this goal (attached) although file format conversion will have to wait until OpenBabel is ready. If there is some interest in this, I will put it up on SourceForge. Comments, suggestions are welcome, of course. Regards, Noel |