Loading...
Searching...
No Matches
OBBuilder Class Reference

`#include <openbabel/builder.h>`

## Public Member Functions

| OBBuilder ()
Call the build algorithm
bool | Build (OBMol &mol, bool stereoWarnings=true)

## Setup build parameters

void | SetKeepRings ()
void | UnsetKeepRings ()
void | AddRingFragment (OBSmartsPattern *sp, const std::vector< vector3 > &coords)
void | LoadFragments ()
std::vector< vector3 > | GetFragmentCoord (std::string smiles)
static vector3 | GetNewBondVector (OBAtom *atom)
static vector3 | GetNewBondVector (OBAtom *atom, double length)
static bool | Connect (OBMol &mol, int a, int b, vector3 &newpos, int bondOrder=1)
static bool | Connect (OBMol &mol, int a, int b, int bondOrder=1)
static bool | Swap (OBMol &mol, int a, int b, int c, int d)
static bool | CorrectStereoBonds (OBMol &mol)
static bool | CorrectStereoAtoms (OBMol &mol, bool warn=true)
static bool | IsSpiroAtom (unsigned long atomId, OBMol &mol)
static OBBitVec | GetFragment (OBAtom *atom)
static void | AddNbrs (OBBitVec &fragment, OBAtom *atom)

## Detailed Description

Class to build 3D structures.

Class for 3D structure generation.

Since
  version 2.2

The OBBuilder class is used for generating 3D structures.

Below is and example which explain the basics.

//
// code to read molecule from smiles goes here...
//
OBBuilder builder;
builder.Build(mol);
//
// code to write molecule to 3D file format goes here...
//
OpenBabel::OBBuilder::OBBuilder
OBBuilder()
Definition builder.h:45
OpenBabel::OBBuilder::Build
bool Build(OBMol &mol, bool stereoWarnings=true)
Definition builder.cpp:1073

## Constructor & Destructor Documentation

## OBBuilder()

OBBuilder | ( |  | ) |

inline

## Member Function Documentation

## Build()

bool Build | ( | OBMol & | mol,
|  | bool | stereoWarnings = true )

The mol object contains all connectivity information (atomic numbers, bonds, bond orders, ..) but no 3D coordinates. Build generates these coordinates and assigns them.

Parameters

  mol | Molecule with the connectivity (from SMILES for example). The coordinates are also changed in this mol.
  stereoWarnings | Warn if the stereochemistry is incorrect (default is true)

## SetKeepRings()

void SetKeepRings | ( |  | ) |

inline

If the molecule already contains 3D coordinates, if you set KeepRings to true it will use retain the 3D coordinates of the rings. By default KeepRings is false, and ring conformations are obtained by lookup in a library of ring conformers. However, since the ring conformer library is not exhaustive, if the ring system is not found in the library, the resulting 3D structure can be poor, and require geometry optimisation before it is reasonable. If your starting point is a 3D structure, you can set KeepRings to true, and the conformation will be taken from the input. The remaining (acyclic) bonds will still all be built by the builder.

## UnsetKeepRings()

void UnsetKeepRings | ( |  | ) |

inline

## AddRingFragment()

void AddRingFragment | ( | OBSmartsPattern * | sp,
|  | const std::vector< vector3 > & | coords )

Used by LoadFragments to check for invalid (all zero coordinates) fragments.

Referenced by LoadFragments().

## LoadFragments()

void LoadFragments | ( |  | ) |

Load fragment info from file, if is it has not already been done.

Referenced by Build().

## GetFragmentCoord()

std::vector< vector3 > GetFragmentCoord | ( | std::string | smiles | ) |

Referenced by Build().

## GetNewBondVector() [1/2]

vector3 GetNewBondVector | ( | OBAtom * | atom | ) |

static

Get the position for a new neighbour on atom. Returns non-finite vector if there is no reasonable location.

Parameters

  atom | Atom for which we want a new neighbour location.

Returns
  The position for the new atom.

Referenced by OBMol::AddHydrogens(), OBMol::AddNewHydrogens(), Connect(), CorrectStereoAtoms(), OpenBabel::GetCorrectedBondVector(), OBAtom::GetNewBondVector(), and GetNewBondVector().

## GetNewBondVector() [2/2]

vector3 GetNewBondVector | ( | OBAtom * | atom,
|  | double | length )

static

## Connect() [1/2]

bool Connect | ( | OBMol & | mol,
|  | int | a,
|  | int | b,
|  | vector3 & | newpos,
|  | int | bondOrder = 1 )

static

Atoms a and b are part of two fragments that are not connected in mol. Connect will translate and rotate the fragment that contains b so that a and b are separated by a bond. This bond is also added.

Parameters

  mol | The molecule to be modified
  a | Index for atom in fragment that should not be rotated.
  b | Index for atom in fragment that should be rotated.
  newpos | Direction for new bond between a and b
  bondOrder | Bond order of the new bond between a and b.

Returns
  true if successful or fails when failed (most likely cause for failing: a and b are in the same fragment, they are connected)

Referenced by Build(), Connect(), and Swap().

## Connect() [2/2]

bool Connect | ( | OBMol & | mol,
|  | int | a,
|  | int | b,
|  | int | bondOrder = 1 )

static

Atoms a and b are part of two fragments that are not connected in mol. Connect will translate and rotate the fragment that contains b so that a and b are separated by a bond. This bond is also added.

Parameters

  mol | The molecule to be modified
  a | Index for atom in fragment that should not be rotated.
  b | Index for atom in fragment that should be rotated.
  bondOrder | Bond order of the new bond bewtween a and b.

Returns
  true if successful or fails when failed (most likely cause for failing: a and b are in the same fragment, they are connected)

## Swap()

bool Swap | ( | OBMol & | mol,
|  | int | a,
|  | int | b,
|  | int | c,
|  | int | d )

static

Swap group b, bonded to a with group d, bonded to c. The bonds a-b and b-c cannot be part of a ring. Atoms a and b will not be moved. Atoms b, d and their connected atoms (after deleting bonds ab and cd) will be translated/rotated.

Example:

\ / /
b d
\ / Swap(a,b,c,d) \ /
a---x ----> a---x
/ \ / / \ /
x c---d x c---b
\
OpenBabel::OBBuilder::Swap
static bool Swap(OBMol &mol, int a, int b, int c, int d)
Definition builder.cpp:994

This function can also be used to invert chiral centers if a and c are the same atom.

Example

1 3
| Swap(C,1,C,3) |
2>-C-<3 -----> 2>-C-<1
| |
4 4

Referenced by CorrectStereoAtoms().

## CorrectStereoBonds()

bool CorrectStereoBonds | ( | OBMol & | mol | ) |

static

Atoms a and b must be bonded and this bond cannot be part of a ring. The bond will be broken and the smiles fragment will be inserted bewteen the two remaining fragments. The fragment that contains a will not be translated or rotated. Parameters c and d are the index in the smiles to which atoms a and b will be connected respectivly.

Correct double bond stereochemistry

Returns
  Success or failure

Referenced by Build().

## CorrectStereoAtoms()

bool CorrectStereoAtoms | ( | OBMol & | mol,
|  | bool | warn = true )

static

Correct stereochemistry at tetrahedral atoms with at least two non-ring bonds. It also works for spiro atoms.

Returns
  Success or failure

Referenced by Build().

## IsSpiroAtom()

bool IsSpiroAtom | ( | unsigned long | atomId,
|  | OBMol & | mol )

static

Does this atom connect two rings which are not otherwise connected?

Referenced by CorrectStereoAtoms().

## GetFragment()

OBBitVec GetFragment | ( | OBAtom * | atom | ) |

static

Get the fragment to which this atom belongs.

Parameters

  atom | Atom in the fragment.

Returns
  The OBBitVec defining the fragment to which a belongs.

Referenced by Build(), and Connect().

## AddNbrs()

void AddNbrs | ( | OBBitVec & | fragment,
|  | OBAtom * | atom )

static

Referenced by AddNbrs(), and GetFragment().

The documentation for this class was generated from the following files:

- builder.h
- builder.cpp