# Generate a single conformer¶

There are several steps involved in generating a low-energy conformer from a 0D or 2D structure.

## OBBuilder¶

The :obapi:`OBBuilder` class is the part of Open Babel that can take a
2D or 0D structure and generate a 3D structure. The 3D structure is
made very quickly using a combination of rules (e.g. sp^{3} atoms should have four bonds arranged in a tetrahedron) and common fragments (e.g. cyclohexane is shaped like a chair).

The 3D structures that come straight out of OBBuilder may be useful for some purposes but most people will want to “clean them up”. This is because they may have clashes or have high energy structures due to some strain. The conformer search or geometry optimization methods described below are typically used after calling OBBuilder.

Full discussion of the methods for coordinate generation is available in ‘Fast, efficient fragment-based coordinate generation for Open Babel’ *J. Cheminf.* (2019) **11**, Art. 49.<https://doi.org/10.1186/s13321-019-0372-5>. Please cite this paper if you use the coordinate generation features in Open Babel.

The functionality of OBBuilder is not directly available through **obabel** but it is used as the necessary first step of the Gen3D operation discussed below.

## Conformer searching¶

Given a 3D structure, the goal of conformer searching is to find a low energy conformation. This may be useful as a “clean-up” procedure after an initial 3D structure generation. Note that conformer searching does not alter stereochemistry.

The Open Babel library provides access to several algorithms for conformer searching. All of these algorithms adopt the torsion-driving approach; that is, conformations are generated by setting torsion angles to one of a number of allowed values. The allowed values are listed in the data file `torlib.txt`

; for example, C-C bonds in alkanes have three allowed values: -60, 60 and 180.

- :obapi:`Systematic Rotor Search <SystematicRotorSearch>`: Systematically iterate through all possible conformers according to Open Babel’s torsion library. This approach is thorough and will find the global minimum. However as the number of conformations increases by multiples for each additional rotational bond, this can take quite a while for molecules with even just 7 rotatable bonds. This approach scales to the power of N, where N is the number of rotatable bonds.
- :obapi:`Fast Rotor Search <FastRotorSearch>`: This iterates through the same conformer space as the SystematicRotorSearch but it greedily optimises the torsion angle at each rotatable bond in turn, starting from the most central. Thus it scales linearly with the number of rotatable bonds.
- :obapi:`Random Rotor Search <RandomRotorSearch>`: Conformations are generated by randomly choosing from the allowed torsion angles.
- :obapi:`Weighted Rotor Search <WeightedRotorSearch>`: This method uses an iterative procedure to find a global minimum. As with the Random Rotor Search, it randomly choses from the allowed torsion angles but the choice is reweighted based on the energy of the generated conformer. Over time, the generated conformer for each step should become increasingly better.

For each of these methods, the lowest energy conformation found is selected. In some cases, the entire set of conformations generated is also available. Many of these methods include an option to optimize the geometry of conformations during the search. This greatly slows down the procedure but may produce more accurate results.

The choice of which algorithm to use depends on the speed/accuracy tradeoff with which you are happy, and also on the number of rotatable bonds in the molecule. Are you looking for a reasonable structure for 3D display? Or are you looking for a structure close to the global minimum?

To use from **obabel**, see the help for the conformer operation (`obabel -L conformer`

). This operation is used both for conformer searching and for the genetic algorithm conformer generation described below.

Here is an example of use from Python:

```
>>> ff = ob.OBForceField.FindForceField("mmff94")
>>> ff.Setup(obmol)
True
>>> print ff.Energy()
15.179054202
>>> ff.SystematicRotorSearch(100)
>>> print ff.Energy()
10.8861155747
```

## Gen3D¶

To illustrate how some of the above methods might be used in practice, consider the **gen3d** operation. This operation (invoked using `--gen3d`

at the commandline) generates 3D structures for 0D or 2D structures using the following series of steps, all of which have been described above:

- Use the OBBuilder to create a 3D structure using rules and fragment templates
- Do 250 steps of a steepest descent geometry optimization with the MMFF94 forcefield
- Do 200 iterations of a Weighted Rotor conformational search (optimizing each conformer with 25 steps of a steepest descent)
- Do 250 steps of a conjugate gradient geometry optimization

Taken together, all of these steps ensure that the generated structure is likely to be the global minimum energy conformer. However, for many applications where 100s if not 1000s of molecules need to be processed, gen3d is rather slow:

`--fastest`

only generate coordinates, no force field or conformer search`--fast`

perform quick forcefield optimization`--medium`

(default)forcefield optimization + fast conformer search`--better`

more optimization + fast conformer search`--best`

more optimization + significant conformer search

Details on some of the trade-offs involved are outlined in ‘Fast, efficient fragment-based coordinate generation for Open Babel’ *J. Cheminf.* (2019) **11**, Art. 49.<https://doi.org/10.1186/s13321-019-0372-5>. If you use the 3D coordinate generation, please cite this paper.