RDKit
Opensource cheminformatics and machine learning.

Classes  
class  DepictException 
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 ¢er, const RDGeom::Point2D &loc1, const RDGeom::Point2D &loc2, double remAngle) 
computes the rotation direction between two vectors More...  
RDGeom::Point2D  computeNormal (const RDGeom::Point2D ¢er, const RDGeom::Point2D &other) 
computes and return the normal of a vector between two points More...  
double  computeAngle (const RDGeom::Point2D ¢er, 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 ¢er, const RDKit::INT_VECT &nbrBids, const VECT_C_POINT &nbrLocs) 
Find pairs of bonds that can be permuted at a nonring 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...  
void  generateDepictionMatching2DStructure (RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId=1, RDKit::ROMol *referencePattern=static_cast< RDKit::ROMol * >(0), bool acceptFailure=false) 
Compute 2D coordinates where a piece of the molecule is. More...  
void  generateDepictionMatching3DStructure (RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId=1, RDKit::ROMol *referencePattern=0, bool acceptFailure=false) 
Generate a 2D depiction for a molecule where all or part of. 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 std::pair<double, INT_PAIR> RDDepict::DOUBLE_INT_PAIR 
Definition at line 162 of file DepictUtils.h.
typedef boost::shared_array< double > RDDepict::DOUBLE_SMART_PTR 
Definition at line 25 of file EmbeddedFrag.h.
typedef std::map<unsigned int, EmbeddedAtom> RDDepict::INT_EATOM_MAP 
Definition at line 140 of file EmbeddedFrag.h.
typedef INT_EATOM_MAP::const_iterator RDDepict::INT_EATOM_MAP_CI 
Definition at line 142 of file EmbeddedFrag.h.
typedef INT_EATOM_MAP::iterator RDDepict::INT_EATOM_MAP_I 
Definition at line 141 of file EmbeddedFrag.h.
typedef std::pair<int, int> RDDepict::INT_PAIR 
Definition at line 158 of file DepictUtils.h.
typedef std::vector<INT_PAIR> RDDepict::INT_PAIR_VECT 
Definition at line 159 of file DepictUtils.h.
typedef INT_PAIR_VECT::const_iterator RDDepict::INT_PAIR_VECT_CI 
Definition at line 160 of file DepictUtils.h.
typedef std::list<PAIR_D_I_I> RDDepict::LIST_PAIR_DII 
Definition at line 44 of file DepictUtils.h.
typedef std::pair<double, PAIR_I_I> RDDepict::PAIR_D_I_I 
Definition at line 43 of file DepictUtils.h.
typedef std::pair<int, int> RDDepict::PAIR_I_I 
Definition at line 33 of file DepictUtils.h.
typedef std::priority_queue<PAIR_I_I, VECT_PII, gtIIPair> RDDepict::PR_QUEUE 
Definition at line 41 of file DepictUtils.h.
typedef std::vector<const RDGeom::Point2D *> RDDepict::VECT_C_POINT 
Definition at line 31 of file DepictUtils.h.
typedef std::vector<PAIR_I_I> RDDepict::VECT_PII 
Definition at line 34 of file DepictUtils.h.
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.
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 xaxis 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 
Referenced by RDKit::Drawing::MolToDrawing(), and RDDepict::DepictException::~DepictException().
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.
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 xaxis 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()
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 interatom 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 interatom 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:
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 
Referenced by RDDepict::DepictException::~DepictException().

inline 
computes the rotation angle between two vectors
center  the common point 
loc1  endpoint 1 
loc2  endpoint 2 
Definition at line 270 of file DepictUtils.h.
References RDGeom::Point2D::angleTo(), findBondsPairsToPermuteDeg4(), getAllRotatableBonds(), getNbrAtomAndBondIds(), getRotatableBonds(), and pickFirstRingToEmbed().
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

inline 
computes and return the normal of a vector between two points
center  the common point 
other  the endpoint 
Definition at line 252 of file DepictUtils.h.
References RDGeom::Point2D::normalize(), RDGeom::Point2D::x, and RDGeom::Point2D::y.

inline 
computes a subangle for an atom of given hybridization and degree
degree  the degree of the atom (number of neighbors) 
htype  the atom's hybridization 
Definition at line 181 of file DepictUtils.h.
References M_PI, RDKit::Atom::SP2, RDKit::Atom::SP3, and RDKit::Atom::UNSPECIFIED.
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 anticlockwise 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 nonring degree 4 atom.
This function will return only those pairs that cannot be permuted by flipping a rotatble bond
D  b3 
Ab1Bb2C  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:
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().
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.
void RDDepict::generateDepictionMatching2DStructure  (  RDKit::ROMol &  mol, 
const RDKit::ROMol &  reference,  
int  confId = 1 , 

RDKit::ROMol *  referencePattern = static_cast< RDKit::ROMol * >(0) , 

bool  acceptFailure = false 

) 
Compute 2D coordinates where a piece of the molecule is.
This function generates a depiction for a molecule where a piece of the molecule is constrained to have the same coordinates as a reference.
This is useful for, for example, generating depictions of SAR data sets so that the cores of the molecules are all oriented the same way.
ARGUMENTS:
mol   the molecule to be aligned, this will come back with a single conformer. 
reference   a molecule with the reference atoms to align to; this should have a depiction. 
confId   (optional) the id of the reference conformation to use 
referencePattern   (optional) a query molecule to be used to generate the atom mapping between the molecule and the reference. 
acceptFailure   (optional) if True, standard depictions will be generated for molecules that don't have a substructure match to the reference; if false, throws a DepictException. 
Referenced by RDDepict::DepictException::~DepictException().
void RDDepict::generateDepictionMatching3DStructure  (  RDKit::ROMol &  mol, 
const RDKit::ROMol &  reference,  
int  confId = 1 , 

RDKit::ROMol *  referencePattern = 0 , 

bool  acceptFailure = false 

) 
Generate a 2D depiction for a molecule where all or part of.
Generates a depiction for a molecule where a piece of the molecule is constrained to have coordinates similar to those of a 3D reference structure.
ARGUMENTS:
mol   the molecule to be aligned, this will come back with a single conformer containing 2D coordinates 
reference   a molecule with the reference atoms to align to. By default this should be the same as mol, but with 3D coordinates 
confId   (optional) the id of the reference conformation to use 
refPattern   (optional) a query molecule to map a subset of the reference onto the mol, so that only some of the atoms are aligned. 
acceptFailure   (optional) if true, standard depictions will be generated for molecules that don't match the reference or the referencePattern; if false, throws a DepictException. 
Referenced by RDDepict::DepictException::~DepictException().
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.
mol  the molecule of interest 
Referenced by computeAngle().

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().
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().
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.
mol  the molecule of interest 
aid1  index of the first atom 
aid2  index of the second atom 
Referenced by computeAngle().
int RDDepict::pickFirstRingToEmbed  (  const RDKit::ROMol &  mol, 
const RDKit::VECT_INT_VECT &  fusedRings  
) 
pick the ring to embed first in a fused system
mol  the molecule of interest 
fusedRings  the collection of the molecule's fused rings 
Referenced by computeAngle().
T RDDepict::rankAtomsByRank  (  const RDKit::ROMol &  mol, 
const T &  commAtms,  
bool  ascending = true 

) 
Sort a list of atoms by their CIP rank.
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:
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 

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
center  the common point 
loc1  endpoint 1 
loc2  endpoint 2 
remAngle  the remaining angle about center in radians 
Definition at line 230 of file DepictUtils.h.
References M_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.
Ok this needs some explanation
E.g. let say we have the following situation
B   AXC   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    AXD    C
And the correct ordering of the neighbors is B,D,C
void RDDepict::transformPoints  (  RDGeom::INT_POINT2D_MAP &  nringCor, 
const RDGeom::Transform2D &  trans  
) 
double RDDepict::ANGLE_OPEN 
double RDDepict::BOND_LEN 
double RDDepict::BOND_THRES 
double RDDepict::COLLISION_THRES 
double RDDepict::HETEROATOM_COLL_SCALE 
unsigned int RDDepict::MAX_COLL_ITERS 
unsigned int RDDepict::NUM_BONDS_FLIPS 