Loading...
Searching...
No Matches
OBMolTorsionIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

| OBMolTorsionIter ()
| OBMolTorsionIter (OBMol *mol)
| OBMolTorsionIter (OBMol &mol)
| OBMolTorsionIter (const OBMolTorsionIter &ai)
| ~OBMolTorsionIter ()
OBMolTorsionIter & | operator= (const OBMolTorsionIter &ai)
| operator bool () const
OBMolTorsionIter & | operator++ ()
std::vector< unsigned int > | operator* () const

## Detailed Description

Iterate over all torsions in an OBMol.

Since
  version 2.1

To facilitate iteration through all torsions in a molecule, without resorting to atom indexes (which will change in the future), a variety of iterator methods are provided.

This has been made significantly easier by a series of macros in the obiter.h header file:

\#define FOR_TORSIONS_OF_MOL(t,m) for( OBMolTorsionIter t(m); t; t++ )
OpenBabel::OBMolTorsionIter::OBMolTorsionIter
OBMolTorsionIter()
Definition obiter.h:325
FOR_TORSIONS_OF_MOL
#define FOR_TORSIONS_OF_MOL(t, m)
Definition obiter.h:409

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::OBMol mol;
OpenBabel::OBAtom *a, *b, *c, *d;
double tor;
FOR_TORSIONS_OF_MOL(t, mol)
{
// The variable a behaves like OBTorsion* when used with -> and * but
// but needs to be explicitly converted when appearing as a parameter
// in a function call - use &*t
a = _mol.GetAtom((*t)[0] + 1); // indices in vector start from 0!!!
b = _mol.GetAtom((*t)[1] + 1);
c = _mol.GetAtom((*t)[2] + 1);
d = _mol.GetAtom((*t)[3] + 1);
tor = mol.GetTorsion(a->GetIdx(), b->GetIdx(), c->GetIdx(), d->GetIdx());
}
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBAtom::GetIdx
unsigned int GetIdx() const
Definition atom.h:189
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBMol::GetTorsion
double GetTorsion(int, int, int, int)
Definition mol.cpp:214
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
obiter.h
STL-style iterators for Open Babel.

## Constructor & Destructor Documentation

## OBMolTorsionIter() [1/4]

OBMolTorsionIter | ( |  | ) |

inline

Referenced by OBMolTorsionIter(), operator++(), and operator=().

## OBMolTorsionIter() [2/4]

OBMolTorsionIter | ( | OBMol * | mol | ) |

## OBMolTorsionIter() [3/4]

OBMolTorsionIter | ( | OBMol & | mol | ) |

## OBMolTorsionIter() [4/4]

OBMolTorsionIter | ( | const OBMolTorsionIter & | ai | ) |

## ~OBMolTorsionIter()

~OBMolTorsionIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBMolTorsionIter & operator= | ( | const OBMolTorsionIter & | ai | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

Returns
  Whether the iterator can still advance (i.e., visit more torsions)

## operator++()

OBMolTorsionIter & operator++ | ( |  | ) |

Preincrement – advance to the next torsion and return.

## operator*()

std::vector< unsigned int > operator* | ( |  | ) | const

inline

Returns
  A vector of four atom indexes specifying the torsion

See also
  OBAtom::GetIdx()

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

- obiter.h
- obiter.cpp