RDDepict Namespace Reference

## Classes

class | EmbeddedAtom
| Class that contains the data for an atoms that has alredy been embedded. More...
class | EmbeddedFrag
| Class containing a fragment of a molecule that has already been embedded. More...
struct | gtIIPair

## Typedefs

typedef std::vector< const RDGeom::Point2D * > | VECT_C_POINT
typedef std::pair< int, int > | PAIR_I_I
typedef std::vector< PAIR_I_I > | VECT_PII
typedef std::priority_queue< PAIR_I_I, VECT_PII, gtIIPair > | PR_QUEUE
typedef std::pair< double, PAIR_I_I > | PAIR_D_I_I
typedef std::list< PAIR_D_I_I > | LIST_PAIR_DII
typedef std::pair< int, int > | INT_PAIR
typedef std::vector< INT_PAIR > | INT_PAIR_VECT
typedef INT_PAIR_VECT::const_iterator | INT_PAIR_VECT_CI
typedef std::pair< double, INT_PAIR > | DOUBLE_INT_PAIR
typedef boost::shared_array< double > | DOUBLE_SMART_PTR
typedef std::map< unsigned int, EmbeddedAtom > | INT_EATOM_MAP
typedef INT_EATOM_MAP::iterator | INT_EATOM_MAP_I
typedef INT_EATOM_MAP::const_iterator | INT_EATOM_MAP_CI

## Functions

void | compute2DCoordsForReaction (RDKit::ChemicalReaction &rxn, double spacing=2.0, bool updateProps=true, bool canonOrient=false, unsigned int nFlipsPerSample=0, unsigned int nSamples=0, int sampleSeed=0, bool permuteDeg4Nodes=false)
| Generate 2D coordinates (a depiction) for a reaction. More...
RDGeom::INT_POINT2D_MAP | embedRing (const RDKit::INT_VECT &ring)
| Some utility functions used in generating 2D coordinates. More...
void | transformPoints (RDGeom::INT_POINT2D_MAP &nringCor, const RDGeom::Transform2D &trans)
RDGeom::Point2D | computeBisectPoint (const RDGeom::Point2D &rcr, double ang, const RDGeom::Point2D &nb1, const RDGeom::Point2D &nb2)
| Find a point that bisects the angle at rcr. More...
void | reflectPoints (RDGeom::INT_POINT2D_MAP &coordMap, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2)
| Reflect a set of point through a the line joining two point. More...
RDGeom::Point2D | reflectPoint (const RDGeom::Point2D &point, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2)
RDKit::INT_VECT | setNbrOrder (unsigned int aid, const RDKit::INT_VECT &nbrs, const RDKit::ROMol &mol)
| Set the neighbors yet to added to aid such that the atoms with the most subs. More...
RDKit::INT_VECT | findNextRingToEmbed (const RDKit::INT_VECT &doneRings, const RDKit::VECT_INT_VECT &fusedRings, int &nextId)
| From a given set of rings find the ring the largest common elements. More...
template<class T >
T | rankAtomsByRank (const RDKit::ROMol &mol, const T &commAtms, bool ascending=true)
| Sort a list of atoms by their CIP rank. More...
double | computeSubAngle (unsigned int degree, RDKit::Atom::HybridizationType htype)
| computes a subangle for an atom of given hybridization and degree More...
int | rotationDir (const RDGeom::Point2D &center, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2, double remAngle)
| computes the rotation direction between two vectors More...
RDGeom::Point2D | computeNormal (const RDGeom::Point2D &center, const RDGeom::Point2D &other)
| computes and return the normal of a vector between two points More...
double | computeAngle (const RDGeom::Point2D &center, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2)
| computes the rotation angle between two vectors More...
int | pickFirstRingToEmbed (const RDKit::ROMol &mol, const RDKit::VECT_INT_VECT &fusedRings)
| pick the ring to embed first in a fused system More...
RDKit::INT_VECT | getRotatableBonds (const RDKit::ROMol &mol, unsigned int aid1, unsigned int aid2)
| find the rotatable bonds on the shortest path between two atoms we will ignore ring atoms, and double bonds which are marked cis/trans More...
RDKit::INT_VECT | getAllRotatableBonds (const RDKit::ROMol &mol)
| find all the rotatable bonds in a molecule we will ignore ring atoms, and double bonds which are marked cis/trans More...
void | getNbrAtomAndBondIds (unsigned int aid, const RDKit::ROMol *mol, RDKit::INT_VECT &aids, RDKit::INT_VECT &bids)
| Get the ids of the atoms and bonds that are connected to aid. More...
INT_PAIR_VECT | findBondsPairsToPermuteDeg4 (const RDGeom::Point2D &center, const RDKit::INT_VECT &nbrBids, const VECT_C_POINT &nbrLocs)
| Find pairs of bonds that can be permuted at a non-ring degree 4 atom. More...
int | getAtomDepictRank (const RDKit::Atom *at)
| returns the rank of the atom for determining draw order More...
unsigned int | compute2DCoords (RDKit::ROMol &mol, const RDGeom::INT_POINT2D_MAP *coordMap=0, bool canonOrient=false, bool clearConfs=true, unsigned int nFlipsPerSample=0, unsigned int nSamples=0, int sampleSeed=0, bool permuteDeg4Nodes=false)
| Generate 2D coordinates (a depiction) for a molecule. More...
unsigned int | compute2DCoordsMimicDistMat (RDKit::ROMol &mol, const DOUBLE_SMART_PTR *dmat=0, bool canonOrient=true, bool clearConfs=true, double weightDistMat=0.5, unsigned int nFlipsPerSample=3, unsigned int nSamples=100, int sampleSeed=25, bool permuteDeg4Nodes=true)
| Compute the 2D coordinates such the interatom distances. More...

## Variables

double | BOND_LEN
double | COLLISION_THRES
double | BOND_THRES
double | ANGLE_OPEN
unsigned int | MAX_COLL_ITERS
double | HETEROATOM_COLL_SCALE
unsigned int | NUM_BONDS_FLIPS

## Typedef Documentation

## DOUBLE_INT_PAIR

typedef std::pair<double, INT_PAIR> RDDepict::DOUBLE_INT_PAIR

Definition at line 162 of file DepictUtils.h.

## DOUBLE_SMART_PTR

typedef boost::shared_array<double> RDDepict::DOUBLE_SMART_PTR

Definition at line 25 of file EmbeddedFrag.h.

## INT_EATOM_MAP

typedef std::map<unsigned int, EmbeddedAtom> RDDepict::INT_EATOM_MAP

Definition at line 133 of file EmbeddedFrag.h.

## INT_EATOM_MAP_CI

typedef INT_EATOM_MAP::const_iterator RDDepict::INT_EATOM_MAP_CI

Definition at line 135 of file EmbeddedFrag.h.

## INT_EATOM_MAP_I

typedef INT_EATOM_MAP::iterator RDDepict::INT_EATOM_MAP_I

Definition at line 134 of file EmbeddedFrag.h.

## INT_PAIR

typedef std::pair<int, int> RDDepict::INT_PAIR

Definition at line 158 of file DepictUtils.h.

## INT_PAIR_VECT

typedef std::vector<INT_PAIR> RDDepict::INT_PAIR_VECT

Definition at line 159 of file DepictUtils.h.

## INT_PAIR_VECT_CI

typedef INT_PAIR_VECT::const_iterator RDDepict::INT_PAIR_VECT_CI

Definition at line 160 of file DepictUtils.h.

## LIST_PAIR_DII

typedef std::list<PAIR_D_I_I> RDDepict::LIST_PAIR_DII

Definition at line 44 of file DepictUtils.h.

## PAIR_D_I_I

typedef std::pair<double, PAIR_I_I> RDDepict::PAIR_D_I_I

Definition at line 43 of file DepictUtils.h.

## PAIR_I_I

typedef std::pair<int, int> RDDepict::PAIR_I_I

Definition at line 33 of file DepictUtils.h.

## PR_QUEUE

typedef std::priority_queue<PAIR_I_I, VECT_PII, gtIIPair> RDDepict::PR_QUEUE

Definition at line 41 of file DepictUtils.h.

## VECT_C_POINT

typedef std::vector<const RDGeom::Point2D *> RDDepict::VECT_C_POINT

Definition at line 31 of file DepictUtils.h.

## VECT_PII

typedef std::vector<PAIR_I_I> RDDepict::VECT_PII

Definition at line 34 of file DepictUtils.h.

## Function Documentation

## compute2DCoords()

unsigned int RDDepict::compute2DCoords | ( | RDKit::ROMol & | mol,
|  | const RDGeom::INT_POINT2D_MAP * | coordMap = `0`,
|  | bool | canonOrient = `false`,
|  | bool | clearConfs = `true`,
|  | unsigned int | nFlipsPerSample = `0`,
|  | unsigned int | nSamples = `0`,
|  | int | sampleSeed = `0`,
|  | bool | permuteDeg4Nodes = `false`
| ) |  |

Generate 2D coordinates (a depiction) for a molecule.

Parameters

  mol | the molecule were are interested in
  coordMap | a map of int to Point2D, between atom IDs and their locations. This is the container the user needs to fill if he/she wants to specify coordinates for a portion of the molecule, defaults to 0
  canonOrient | canonicalize the orientation so that the long axes align with the x-axis etc.
  clearConfs | clear all existing conformations on the molecule before adding the 2D coordinates instead of simply adding to the list
  nFlipsPerSample | - the number of rotatable bonds that are flipped at random for each sample
  nSamples | - the number of samples
  sampleSeed | - seed for the random sampling process
  permuteDeg4Nodes | - try permuting the drawing order of bonds around atoms with four neighbors in order to improve the depiction

Returns
  ID of the conformation added to the molecule cotaining the 2D coordinates

Referenced by RDKit::Drawing::MolToDrawing().

## compute2DCoordsForReaction()

void RDDepict::compute2DCoordsForReaction | ( | RDKit::ChemicalReaction & | rxn,
|  | double | spacing = `2.0`,
|  | bool | updateProps = `true`,
|  | bool | canonOrient = `false`,
|  | unsigned int | nFlipsPerSample = `0`,
|  | unsigned int | nSamples = `0`,
|  | int | sampleSeed = `0`,
|  | bool | permuteDeg4Nodes = `false`
| ) |  |

Generate 2D coordinates (a depiction) for a reaction.

Parameters

  rxn | the reaction we are interested in
  spacing | the spacing between components of the reaction
  updateProps | if set, properties such as conjugation and hybridization will be calculated for the reactant and product templates before generating coordinates. This should result in better depictions, but can lead to errors in some cases.
  canonOrient | canonicalize the orientation so that the long axes align with the x-axis etc.
  nFlipsPerSample | - the number of rotatable bonds that are flipped at random for each sample
  nSamples | - the number of samples
  sampleSeed | - seed for the random sampling process
  permuteDeg4Nodes | - try permuting the drawing order of bonds around atoms with four neighbors in order to improve the depiction

for the other parameters see the documentation for compute2DCoords()

## compute2DCoordsMimicDistMat()

unsigned int RDDepict::compute2DCoordsMimicDistMat | ( | RDKit::ROMol & | mol,
|  | const DOUBLE_SMART_PTR * | dmat = `0`,
|  | bool | canonOrient = `true`,
|  | bool | clearConfs = `true`,
|  | double | weightDistMat = `0.5`,
|  | unsigned int | nFlipsPerSample = `3`,
|  | unsigned int | nSamples = `100`,
|  | int | sampleSeed = `25`,
|  | bool | permuteDeg4Nodes = `true`
| ) |  |

Compute the 2D coordinates such the interatom distances.

This function generates 2D coordinates such that the inter-atom distances mimic those specified via dmat. This is done by randomly sampling(flipping) the rotatable bonds in the molecule and evaluating a cost function which contains two components. The first component is the sum of inverse of the squared inter-atom distances, this helps in spreading the atoms far from each other. The second component is the sum of squares of the difference in distance between those in dmat and the generated structure. The user can adjust the relative importance of the two components via a adjustable paramter (see below)

ARGUMENTS:

Parameters

  mol | - molecule to generate coordinates for
  dmat | - the distance matrix we want to mimic, this is a symmetric N by N matrix where N is the number of atoms in mol. All negative entries in dmat are ignored.
  canonOrient | - canonicalize the orientation after the 2D embedding is done
  clearConfs | - clear any previously existing conformations on mol before adding a conformation
  weightDistMat | - A value between 0.0 and 1.0, this determines the importance of mimicing the the inter atoms distances in dmat. (1.0 - weightDistMat) is the weight associated to spreading out the structure (density) in the cost function
  nFlipsPerSample | - the number of rotatable bonds that are flipped at random for each sample
  nSamples | - the number of samples
  sampleSeed | - seed for the random sampling process
  permuteDeg4Nodes | - try permuting the drawing order of bonds around atoms with four neighbors in order to improve the depiction

Returns
  ID of the conformation added to the molecule cotaining the 2D coordinates

## computeAngle()

double RDDepict::computeAngle | ( | const RDGeom::Point2D & | center,
|  | const RDGeom::Point2D & | loc1,
|  | const RDGeom::Point2D & | loc2
| ) |  |

inline

computes the rotation angle between two vectors

Parameters

  center | the common point
  loc1 | endpoint 1
  loc2 | endpoint 2

Returns
  the angle (in radians)

Definition at line 270 of file DepictUtils.h.

References RDGeom::Point2D::angleTo(), findBondsPairsToPermuteDeg4(), getAllRotatableBonds(), getNbrAtomAndBondIds(), getRotatableBonds(), and pickFirstRingToEmbed().

## computeBisectPoint()

RDGeom::Point2D RDDepict::computeBisectPoint | ( | const RDGeom::Point2D & | rcr,
|  | double | ang,
|  | const RDGeom::Point2D & | nb1,
|  | const RDGeom::Point2D & | nb2
| ) |  |

Find a point that bisects the angle at rcr.

The new point lies between nb1 and nb2. The line (rcr, newPt) bisects the angle 'ang' at rcr

## computeNormal()

RDGeom::Point2D RDDepict::computeNormal | ( | const RDGeom::Point2D & | center,
|  | const RDGeom::Point2D & | other
| ) |  |

inline

computes and return the normal of a vector between two points

Parameters

  center | the common point
  other | the endpoint

Returns
  the normal

Definition at line 252 of file DepictUtils.h.

References RDGeom::Point2D::normalize(), RDGeom::Point2D::x, and RDGeom::Point2D::y.

## computeSubAngle()

double RDDepict::computeSubAngle | ( | unsigned int | degree,
|  | RDKit::Atom::HybridizationType | htype
| ) |  |

inline

computes a subangle for an atom of given hybridization and degree

Parameters

  degree | the degree of the atom (number of neighbors)
  htype | the atom's hybridization

Returns
  the subangle (in radians)

Definition at line 181 of file DepictUtils.h.

References M_PI, RDKit::Atom::SP2, RDKit::Atom::SP3, and RDKit::Atom::UNSPECIFIED.

## embedRing()

RDGeom::INT_POINT2D_MAP RDDepict::embedRing | ( | const RDKit::INT_VECT & | ring | ) |

Some utility functions used in generating 2D coordinates.

Embed a ring as a convex polygon in 2D

The process here is very straightforward:

We take the center of the ring to lie at the origin, so put the first point at the origin and then sweep anti-clockwise by an angle A = 360/n for the next point.

The length of the arm (l) we want to sweep is easy to compute given the bond length (b) we want to use for each bond in the ring (for now we will assume that this bond legnth is the same for all bonds in the ring:

l = b/sqrt(2*(1 - cos(A))

the above formula derives from the triangle formula, where side 'c' is given in terms of sides 'a' and 'b' as:

c = a^2 + b^2 - 2.a.b.cos(A)

where A is the angle between a and b

## findBondsPairsToPermuteDeg4()

INT_PAIR_VECT RDDepict::findBondsPairsToPermuteDeg4 | ( | const RDGeom::Point2D & | center,
|  | const RDKit::INT_VECT & | nbrBids,
|  | const VECT_C_POINT & | nbrLocs
| ) |  |

Find pairs of bonds that can be permuted at a non-ring degree 4 atom.

This function will return only those pairs that cannot be permuted by flipping a rotatble bond

       D
       |
       b3
       |

A-b1-B-b2-C | b4 | E For example in teh above situation on the pairs (b1, b3) and (b1, b4) will be returned All other permutations can be achieved via a rotatable bond flip.

ARGUMENTS:

Parameters

  center | - location of the central atom
  nbrBids | - a vector (of length 4) containing the ids of the bonds to the neighbors
  nbrLocs | - locations of the neighbors

Referenced by computeAngle().

## findNextRingToEmbed()

RDKit::INT_VECT RDDepict::findNextRingToEmbed | ( | const RDKit::INT_VECT & | doneRings,
|  | const RDKit::VECT_INT_VECT & | fusedRings,
|  | int & | nextId
| ) |  |

From a given set of rings find the ring the largest common elements.

## getAllRotatableBonds()

RDKit::INT_VECT RDDepict::getAllRotatableBonds | ( | const RDKit::ROMol & | mol | ) |

find all the rotatable bonds in a molecule we will ignore ring atoms, and double bonds which are marked cis/trans

Note that rotatable in this context doesn't connect to the standard chemical definition of a rotatable bond; we're just talking about bonds than can be flipped in order to clean up the depiction.

Parameters

  mol | the molecule of interest

Returns
  a set of the indices of the rotatable bonds

Referenced by computeAngle().

## getAtomDepictRank()

int RDDepict::getAtomDepictRank | ( | const RDKit::Atom * | at | ) |

inline

returns the rank of the atom for determining draw order

Definition at line 350 of file DepictUtils.h.

References RDKit::Atom::getAtomicNum(), and RDKit::Atom::getDegree().

## getNbrAtomAndBondIds()

void RDDepict::getNbrAtomAndBondIds | ( | unsigned int | aid,
|  | const RDKit::ROMol * | mol,
|  | RDKit::INT_VECT & | aids,
|  | RDKit::INT_VECT & | bids
| ) |  |

Get the ids of the atoms and bonds that are connected to aid.

Referenced by computeAngle().

## getRotatableBonds()

RDKit::INT_VECT RDDepict::getRotatableBonds | ( | const RDKit::ROMol & | mol,
|  | unsigned int | aid1,
|  | unsigned int | aid2
| ) |  |

find the rotatable bonds on the shortest path between two atoms we will ignore ring atoms, and double bonds which are marked cis/trans

Note that rotatable in this context doesn't connect to the standard chemical definition of a rotatable bond; we're just talking about bonds than can be flipped in order to clean up the depiction.

Parameters

  mol | the molecule of interest
  aid1 | index of the first atom
  aid2 | index of the second atom

Returns
  a set of the indices of the rotatable bonds

Referenced by computeAngle().

## pickFirstRingToEmbed()

int RDDepict::pickFirstRingToEmbed | ( | const RDKit::ROMol & | mol,
|  | const RDKit::VECT_INT_VECT & | fusedRings
| ) |  |

pick the ring to embed first in a fused system

Parameters

  mol | the molecule of interest
  fusedRings | the collection of the molecule's fused rings

Returns
  the index of the ring with the least number of substitutions

Referenced by computeAngle().

## rankAtomsByRank()

template<class T >

T RDDepict::rankAtomsByRank | ( | const RDKit::ROMol & | mol,
|  | const T & | commAtms,
|  | bool | ascending = `true`
| ) |  |

Sort a list of atoms by their CIP rank.

Parameters

  mol | molecule of interest
  commAtms | atoms that need to be ranked
  ascending | sort to an ascending order or a descending order

## reflectPoint()

RDGeom::Point2D RDDepict::reflectPoint | ( | const RDGeom::Point2D & | point,
|  | const RDGeom::Point2D & | loc1,
|  | const RDGeom::Point2D & | loc2
| ) |  |

Referenced by RDDepict::EmbeddedAtom::Reflect().

## reflectPoints()

void RDDepict::reflectPoints | ( | RDGeom::INT_POINT2D_MAP & | coordMap,
|  | const RDGeom::Point2D & | loc1,
|  | const RDGeom::Point2D & | loc2
| ) |  |

Reflect a set of point through a the line joining two point.

ARGUMENTS:

Parameters

  coordMap | a map of <int, point2D> going from atom id to current coordinates of the points that need to be reflected: The coordinates are overwritten
  loc1 | the first point of the line that is to be used as a mirror
  loc2 | the second point of the line to be used as a mirror

## rotationDir()

int RDDepict::rotationDir | ( | const RDGeom::Point2D & | center,
|  | const RDGeom::Point2D & | loc1,
|  | const RDGeom::Point2D & | loc2,
|  | double | remAngle
| ) |  |

inline

computes the rotation direction between two vectors

Let:

v1 = loc1 - center

v2 = loc2 - center

If remaining angle(v1, v2) is < 180 and corss(v1, v2) > 0.0 then the rotation dir is +1.0

else if remAngle(v1, v2) is > 180 and cross(v1, v2) < 0.0 then rotation dir is -1.0

else if remAngle(v1, v2) is < 180 and cross(v1, v2) < 0.0 then rotation dir is -1.0

finally if remAngle(v1, v2) is > 180 and cross(v1, v2) < 0.0 then rotation dir is +1.0

Parameters

  center | the common point
  loc1 | endpoint 1
  loc2 | endpoint 2
  remAngle | the remaining angle about center in radians

Returns
  the rotation direction (1 or -1)

Definition at line 230 of file DepictUtils.h.

References M_PI, RDGeom::Point2D::x, and RDGeom::Point2D::y.

## setNbrOrder()

RDKit::INT_VECT RDDepict::setNbrOrder | ( | unsigned int | aid,
|  | const RDKit::INT_VECT & | nbrs,
|  | const RDKit::ROMol & | mol
| ) |  |

Set the neighbors yet to added to aid such that the atoms with the most subs.

Ok this needs some explanation

- Let A, B, C, D be the substituent on the central atom X (given by atom index aid)
- also let A be the atom that is already embedded
- Now we want the order in which the remaining neighbors B,C,D are added to X such that the atoms with atom with largest number of substituent fall on opposite sides of X so as to minimize atom clashes later in the depiction

E.g. let say we have the following situation

              B
           |  |
           A--X--C
           |  |
            --D--
              |

In this case the the number substituent of A, B, C, D are 3, 1, 1, 4 respectively so want to A and D to go opposite sides and so that we draw

              B
           |  |  |
           A--X--D--
           |  |  |
              C

And the correct ordering of the neighbors is B,D,C

## transformPoints()

void RDDepict::transformPoints | ( | RDGeom::INT_POINT2D_MAP & | nringCor,
|  | const RDGeom::Transform2D & | trans
| ) |  |

## Variable Documentation

## ANGLE_OPEN

double RDDepict::ANGLE_OPEN

## BOND_LEN

double RDDepict::BOND_LEN

## BOND_THRES

double RDDepict::BOND_THRES

## COLLISION_THRES

double RDDepict::COLLISION_THRES

## HETEROATOM_COLL_SCALE

double RDDepict::HETEROATOM_COLL_SCALE

## MAX_COLL_ITERS

unsigned int RDDepict::MAX_COLL_ITERS

## NUM_BONDS_FLIPS

unsigned int RDDepict::NUM_BONDS_FLIPS