Placeholder for enums & Ref/Refs related functions. More...
#include <openbabel/stereo/stereo.h>
Public Types | |
enum | Type { CisTrans = (1<<0), ExtendedCisTrans = (1<<1), SquarePlanar = (1<<2), Tetrahedral = (1<<3), ExtendedTetrahedral = (1<<4), TrigonalBipyramidal = (1<<5), Octahedral = (1<<6) } |
enum | BondDirection { NotStereo = 0, UpBond = 1, DownBond = 6, UnknownDir = 4 } |
enum | Shape { ShapeU = 1, ShapeZ = 2, Shape4 = 3 } |
enum | View { ViewFrom = 1, ViewTowards = 2 } |
enum | Winding { Clockwise = 1, AntiClockwise = 2 } |
Ref & Refs types | |
enum | { NoRef = UINT_MAX, ImplicitRef = UINT_MAX - 1 } |
typedef unsigned long | Ref |
typedef std::vector< Ref > | Refs |
typedef Refs::iterator | RefIter |
typedef Refs::const_iterator | ConstRefIter |
Static Public Member Functions | |
Refs utility functions | |
static Refs | MakeRefs (Ref ref1, Ref ref2, Ref ref3, Ref ref4=NoRef) |
static bool | ContainsSameRefs (const Refs &refs1, const Refs &refs2) |
static bool | ContainsRef (const Refs &refs, unsigned long ref) |
Low-level functions used by implementation. | |
static int | NumInversions (const Refs &refs) |
static void | Permutate (Refs &refs, int i, int j) |
static Refs | Permutated (const Refs &refs, int i, int j) |
Placeholder for enums & Ref/Refs related functions.
The OBStereo struct contains a number of enums with predefined values. These are OBStereo::BondDirection, OBStereo::Type, OBStereo::Shape, OBStereo::View, OBStereo::Winding. There are enums which only apply to certain types of stereochemistry but having them in 1 place makes it easier to remember.
The OBStereo struct also contains typedefs and functions which are crucial to fully understand how to use the OBStereoBase derived classes (i.e. OBTetrahedralStereo, OBCisTransStereo, ...). Ref variables and Refs lists are a way to uniquely reference atoms in the molecule. In most cases these Ref variables are the same as the unique atom ids (OBAtom::GetId). However, 2 special cases are provided:
There are utility functions which make it easier to handle Refs. The most frequently used one is OBStereo::MakeRefs to create lists containing 3 or 4 Ref values. Formats and library use normally doesn't need the other functions.
typedef unsigned long Ref |
All stereo classes work with variables of the type Ref to uniquely identify atoms. In most cases these Ref variables are the same as the unique atom ids.
typedef Refs::iterator RefIter |
Iterator (std::iterator) for a Refs list.
typedef Refs::const_iterator ConstRefIter |
Iterator (std::iterator) for a const Refs list.
enum Type |
The various types of stereochemistry
enum BondDirection |
Bond directions used by StereoFrom0D() to translate to internal CisTransStereo representation.
enum Shape |
Shapes used by OBTetraPlanarStereo subclasses for setting/getting reference ids.
enum View |
Views used by OBTetraNonPlanarStereo subclasses for setting/getting reference ids.
enum Winding |
anonymous enum |
Create a Refs list filled with ref1
, ref2
, ref3
& ref4
. ref4
is not added to the returned Refs if it is equal to NoRef.
Check if refs1
and refs2
contain the same Ref values regardless of their order.
OBStereo::ContainsSameRefs(OBStereo::MakeRefs(1, 2, 3), OBStereo::MakeRefs(2, 3, 1)) // true OBStereo::ContainsSameRefs(OBStereo::MakeRefs(1, 2, 3), OBStereo::MakeRefs(3, 2, 1)) // true OBStereo::ContainsSameRefs(OBStereo::MakeRefs(1, 2, 3), OBStereo::MakeRefs(3, 4, 1)) // false
refs1
and refs2
contain the same Ref values. static bool ContainsRef | ( | const Refs & | refs, |
unsigned long | ref | ||
) | [static] |
refs
contains ref
. static int NumInversions | ( | const Refs & | refs ) | [static] |
Compute the inversion vector for refs
and return the sum of it's elements. The ith element in the inversion vector is the number of element to the right of element i with a lower value.
The number of inversions is the same as the number of interchanges of consecutive elements.
When working with 3 refs from a tetrahedral configuration:
permutation inversion vector sum ------------------------------------- 123 0 0 0 0 (even) -> clockwise 132 0 1 0 1 (odd) -> anti-clockwise 213 1 0 0 1 (odd) -> anti-clockwise 231 1 1 0 2 (even) -> clockwise 312 2 0 0 2 (even) -> clockwise 321 2 1 0 3 (odd) -> anti-clockwise
static void Permutate | ( | Refs & | refs, |
int | i, | ||
int | j | ||
) | [static] |
Permutate element i
with j
in refs
.
refs | The sequence with N elements to permutate. |
i | Element i (0...N-1) will be mutated to j and vice versa. |
j | Element j (0...N-1) will be mutated to i and vice versa. |
Referenced by OBTetraNonPlanarStereo::ChangeView(), OBTetraNonPlanarStereo::ChangeWinding(), OBTetraNonPlanarStereo::Invert(), OBTetraPlanarStereo::ToConfig(), and OBTetraNonPlanarStereo::ToConfig().
Get refs
with element i
and j
permutated.
refs | The sequence with N elements to permutate. |
i | Element i (0...N-1) will be mutated to j and vice versa. |
j | Element j (0...N-1) will be mutated to i and vice versa. |
refs
with elements i
and j
permutated.i
equals j
.