Introduction to Open Babel API

Open Babel is a full chemical software toolbox. In addition to converting file formats, it offers a complete programming library for developing chemistry software. The library is written primarily in C++ and also offers interfaces to other languages (e.g., Perl and Python) using essentially the same API.

The heart of Open Babel lies in the OBMol, OBAtom, and OBBond classes, which handle operations on atoms, bonds and molecules. Newcomers should start with looking at the OBMol class, designed to store the basic information in a molecule and to perceive information about a molecule.

One of the key philosophies in the code is that transformations and automatic perception of properties are performed in a "lazy" manner. That is, until you call for partial atomic charges, no charges are calculated. This ensures faster transformations of chemical data -- properties that are not needed for your code will typically not be calculated. When such data is needed, appropriate routines are called, and a "flag" is set (e.g., via OBMol::SetFlag or OBAtom::SetFlag etc.) so that the code is only run once.

Arbitrary custom data and text descriptors can be stored in any atom, bond, molecule, or residue using the OBGenericData or OBPairData classes.

Conversion between various chemical file formats is accomplished through the OBConversion and OBFormat classes, often through use of the OBMoleculeFormat subclass which is designed for easy read/write access to one or more OBMol objects. The philosophy of the file format codes is to parse as much chemical information from a given file as possible (no data left behind) and ideally any perception or transformations will occur when writing to some other format later.