RDCode: RDDepict Namespace Reference

# RDDepict Namespace Reference

## Classes
struct | gtIIPair
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...
## 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
RDGeom::INT_POINT2D_MAP | embedRing (const RDKit::INT_VECT &ring)
| Some utility functions used in generating 2D coordinates.
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.
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.
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 fall on opposite sides.
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 with other rings.
template<class T>
T | rankAtomsByRank (const RDKit::ROMol &mol, const T &commAtms, bool ascending=true)
| Sort a list of atoms by their CIP rank.
double | computeSubAngle (unsigned int degree, RDKit::Atom::HybridizationType htype)
| computes a subangle for an atom of given hybridization and degree
int | rotationDir (const RDGeom::Point2D &center, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2, double remAngle)
| computes the rotation direction between two vectors
RDGeom::Point2D | computeNormal (const RDGeom::Point2D &center, const RDGeom::Point2D &other)
| computes and return the normal of a vector between two points
double | computeAngle (const RDGeom::Point2D &center, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2)
| computes the rotation angle between two vectors
int | pickFirstRingToEmbed (const RDKit::ROMol &mol, const RDKit::VECT_INT_VECT &fusedRings)
| pick the ring to embed first in a fused system
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
RDKit::INT_VECT | getAllRotatbleBonds (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
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.
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.
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.
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.
## Variables
const double | BOND_LEN = 1.5
const double | COLLISION_THRES = 0.35
const double | BOND_THRES = 0.50
const double | ANGLE_OPEN = 0.1222
const unsigned int | MAX_COLL_ITERS = 15
const double | HETEROATOM_COLL_SCALE = 1.3
const unsigned int | NUM_BONDS_FLIPS = 3

## Typedef Documentation

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

Definition at line 149 of file DepictUtils.h.

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

Definition at line 22 of file EmbeddedFrag.h.

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

Definition at line 117 of file EmbeddedFrag.h.

typedef INT_EATOM_MAP::const_iterator RDDepict::INT_EATOM_MAP_CI

Definition at line 119 of file EmbeddedFrag.h.

typedef INT_EATOM_MAP::iterator RDDepict::INT_EATOM_MAP_I

Definition at line 118 of file EmbeddedFrag.h.

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

Definition at line 145 of file DepictUtils.h.

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

Definition at line 146 of file DepictUtils.h.

typedef INT_PAIR_VECT::const_iterator RDDepict::INT_PAIR_VECT_CI

Definition at line 147 of file DepictUtils.h.

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

Definition at line 40 of file DepictUtils.h.

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

Definition at line 39 of file DepictUtils.h.

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

Definition at line 29 of file DepictUtils.h.

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

Definition at line 37 of file DepictUtils.h.

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

Definition at line 27 of file DepictUtils.h.

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

Definition at line 30 of file DepictUtils.h.

## Function Documentation

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

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

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
  | nSample | - the number of samples
  | sampleSeed | - seed for the random sampling process

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

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 250 of file DepictUtils.h.

References RDGeom::Point2D::angleTo().

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

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 232 of file DepictUtils.h.

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

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 168 of file DepictUtils.h.

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

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

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

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 with other rings.

RDKit::INT_VECT RDDepict::getAllRotatbleBonds | ( | 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

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.

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

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

template<class T>

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

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

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

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

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

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 211 of file DepictUtils.h.

References RDKit::PI, RDGeom::Point2D::x, and RDGeom::Point2D::y.

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 fall on opposite sides.

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

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

## Variable Documentation

const double RDDepict::ANGLE_OPEN = 0.1222

Definition at line 22 of file DepictUtils.h.

const double RDDepict::BOND_LEN = 1.5

Definition at line 19 of file DepictUtils.h.

const double RDDepict::BOND_THRES = 0.50

Definition at line 21 of file DepictUtils.h.

const double RDDepict::COLLISION_THRES = 0.35

Definition at line 20 of file DepictUtils.h.

const double RDDepict::HETEROATOM_COLL_SCALE = 1.3

Definition at line 24 of file DepictUtils.h.

const unsigned int RDDepict::MAX_COLL_ITERS = 15

Definition at line 23 of file DepictUtils.h.

const unsigned int RDDepict::NUM_BONDS_FLIPS = 3

Definition at line 25 of file DepictUtils.h.