Python-Ref > Cheminformatics > OpenBabel > OpenBabel and Pybel relationship
 
 

<-^^->
Klíčová slova
Moduly
Knihovní funkce

OpenBabel and Pybel relationship

As was mentioned before, pybel is built around openbabel. When necessary it is possible to access the underlying openbabel structures from pybel modules.
Expand/Shrink
Zdroj: (babel2-1.py)
  1   import pybel
  2   
  3   mol = pybel.readstring( "smi", "O=CC=O")
  4   print "Pybel molecule object:", mol
  5   print "Underlying OpenBabel molecule:", mol.OBMol 
  6   print "------------------------------"
  7   for a in mol.atoms:
  8     print "Pybel atom:", a
  9     print "OpenBabel atom:", a.OBAtom
stdout:
Pybel molecule object: O=CC=O	

Underlying OpenBabel molecule: <openbabel.OBMol; proxy of <Swig Object of type 'OpenBabel::OBMol *' at 0x909690> >
------------------------------
Pybel atom: Atom: 8 (0.00 0.00 0.00)
OpenBabel atom: <openbabel.OBAtom; proxy of <Swig Object of type 'OpenBabel::OBAtom *' at 0x829080> >
Pybel atom: Atom: 6 (0.00 0.00 0.00)
OpenBabel atom: <openbabel.OBAtom; proxy of <Swig Object of type 'OpenBabel::OBAtom *' at 0x823ea0> >
Pybel atom: Atom: 6 (0.00 0.00 0.00)
OpenBabel atom: <openbabel.OBAtom; proxy of <Swig Object of type 'OpenBabel::OBAtom *' at 0x697dc0> >
Pybel atom: Atom: 8 (0.00 0.00 0.00)
OpenBabel atom: <openbabel.OBAtom; proxy of <Swig Object of type 'OpenBabel::OBAtom *' at 0x8c8b90> >
Doba běhu: 846.1 ms
In the following sections we will use pybel when possible and resort to openbabel only when necessary.