RDKit
Open-source cheminformatics and machine learning.
RDDepictor.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2017 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 
11 #include <RDGeneral/export.h>
12 #ifndef RDDEPICTOR_H
13 #define RDDEPICTOR_H
14 
15 #include <RDGeneral/types.h>
16 #include <Geometry/point.h>
17 #include <boost/smart_ptr.hpp>
18 
19 namespace RDKit {
20 class ROMol;
21 }
22 
23 namespace RDDepict {
24 
25 #ifdef RDK_BUILD_COORDGEN_SUPPORT
26 RDKIT_DEPICTOR_EXPORT extern bool preferCoordGen;
27 #endif
28 
29 typedef boost::shared_array<double> DOUBLE_SMART_PTR;
30 
31 class RDKIT_DEPICTOR_EXPORT DepictException : public std::exception {
32  public:
33  DepictException(const char *msg) : _msg(msg){};
34  DepictException(const std::string msg) : _msg(msg){};
35  const char *message() const { return _msg.c_str(); };
36  ~DepictException() throw(){};
37 
38  private:
39  std::string _msg;
40 };
41 
42 //! \brief Generate 2D coordinates (a depiction) for a molecule
43 /*!
44 
45  \param mol the molecule were are interested in
46 
47  \param coordMap a map of int to Point2D, between atom IDs and
48  their locations. This is the container the user needs to fill if
49  he/she wants to specify coordinates for a portion of the molecule,
50  defaults to 0
51 
52  \param canonOrient canonicalize the orientation so that the long
53  axes align with the x-axis etc.
54 
55  \param clearConfs clear all existing conformations on the molecule
56  before adding the 2D coordinates instead of simply adding to the
57  list
58 
59  \param nFlipsPerSample - the number of rotatable bonds that are
60  flipped at random for each sample
61 
62  \param nSamples - the number of samples
63 
64  \param sampleSeed - seed for the random sampling process
65 
66  \param permuteDeg4Nodes - try permuting the drawing order of bonds around
67  atoms with four neighbors in order to improve the depiction
68 
69  \return ID of the conformation added to the molecule cotaining the
70  2D coordinates
71 
72 */
74  RDKit::ROMol &mol, const RDGeom::INT_POINT2D_MAP *coordMap = 0,
75  bool canonOrient = false, bool clearConfs = true,
76  unsigned int nFlipsPerSample = 0, unsigned int nSamples = 0,
77  int sampleSeed = 0, bool permuteDeg4Nodes = false, bool forceRDKit = false);
78 
79 //! \brief Compute the 2D coordinates such the interatom distances
80 // mimic those in a distance matrix
81 /*!
82 
83  This function generates 2D coordinates such that the inter-atom
84  distances mimic those specified via dmat. This is done by randomly
85  sampling(flipping) the rotatable bonds in the molecule and
86  evaluating a cost function which contains two components. The
87  first component is the sum of inverse of the squared inter-atom
88  distances, this helps in spreading the atoms far from each
89  other. The second component is the sum of squares of the
90  difference in distance between those in dmat and the generated
91  structure. The user can adjust the relative importance of the two
92  components via a adjustable paramter (see below)
93 
94  ARGUMENTS:
95 
96  \param mol - molecule to generate coordinates for
97 
98  \param dmat - the distance matrix we want to mimic, this is a
99  symmetric N by N matrix where N is the number of atoms in mol. All
100  negative entries in dmat are ignored.
101 
102  \param canonOrient - canonicalize the orientation after the 2D
103  embedding is done
104 
105  \param clearConfs - clear any previously existing conformations on
106  mol before adding a conformation
107 
108  \param weightDistMat - A value between 0.0 and 1.0, this
109  determines the importance of mimicing the inter atoms
110  distances in dmat. (1.0 - weightDistMat) is the weight associated
111  to spreading out the structure (density) in the cost function
112 
113  \param nFlipsPerSample - the number of rotatable bonds that are
114  flipped at random for each sample
115 
116  \param nSamples - the number of samples
117 
118  \param sampleSeed - seed for the random sampling process
119 
120  \param permuteDeg4Nodes - try permuting the drawing order of bonds around
121  atoms with four neighbors in order to improve the depiction
122 
123  \return ID of the conformation added to the molecule cotaining the
124  2D coordinates
125 
126 
127 */
129  RDKit::ROMol &mol, const DOUBLE_SMART_PTR *dmat = 0,
130  bool canonOrient = true, bool clearConfs = true, double weightDistMat = 0.5,
131  unsigned int nFlipsPerSample = 3, unsigned int nSamples = 100,
132  int sampleSeed = 25, bool permuteDeg4Nodes = true, bool forceRDKit = false);
133 
134 //! \brief Compute 2D coordinates where a piece of the molecule is
135 // constrained to have the same coordinates as a reference.
136 /*!
137  This function generates a depiction for a molecule where a piece of the
138  molecule is constrained to have the same coordinates as a reference.
139 
140  This is useful for, for example, generating depictions of SAR data
141  sets so that the cores of the molecules are all oriented the same way.
142 
143  ARGUMENTS:
144 
145  \param mol - the molecule to be aligned, this will come back
146  with a single conformer.
147  \param reference - a molecule with the reference atoms to align to;
148  this should have a depiction.
149  \param confId - (optional) the id of the reference conformation to use
150  \param referencePattern - (optional) a query molecule to be used to
151  generate the atom mapping between the molecule
152  and the reference.
153  \param acceptFailure - (optional) if True, standard depictions will be
154  generated
155  for molecules that don't have a substructure match to
156  the
157  reference; if false, throws a DepictException.
158 
159 */
161  RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId = -1,
162  RDKit::ROMol *referencePattern = static_cast<RDKit::ROMol *>(0),
163  bool acceptFailure = false, bool forceRDKit = false);
164 
165 //! \brief Generate a 2D depiction for a molecule where all or part of
166 // it mimics the coordinates of a 3D reference structure.
167 /*!
168  Generates a depiction for a molecule where a piece of the molecule
169  is constrained to have coordinates similar to those of a 3D reference
170  structure.
171 
172  ARGUMENTS:
173  \param mol - the molecule to be aligned, this will come back
174  with a single conformer containing 2D coordinates
175  \param reference - a molecule with the reference atoms to align to.
176  By default this should be the same as mol, but with
177  3D coordinates
178  \param confId - (optional) the id of the reference conformation to use
179  \param refPattern - (optional) a query molecule to map a subset of
180  the reference onto the mol, so that only some of the
181  atoms are aligned.
182  \param acceptFailure - (optional) if true, standard depictions will be
183  generated
184  for molecules that don't match the reference or the
185  referencePattern; if false, throws a DepictException.
186 */
188  RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId = -1,
189  RDKit::ROMol *referencePattern = 0, bool acceptFailure = false,
190  bool forceRDKit = false);
191 }; // namespace RDDepict
192 
193 #endif
RDKIT_DEPICTOR_EXPORT
#define RDKIT_DEPICTOR_EXPORT
Definition: export.h:125
RDDepict::DepictException
Definition: RDDepictor.h:31
point.h
RDDepict::compute2DCoordsMimicDistMat
RDKIT_DEPICTOR_EXPORT 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, bool forceRDKit=false)
Compute the 2D coordinates such the interatom distances.
types.h
RDDepict::generateDepictionMatching3DStructure
RDKIT_DEPICTOR_EXPORT void generateDepictionMatching3DStructure(RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId=-1, RDKit::ROMol *referencePattern=0, bool acceptFailure=false, bool forceRDKit=false)
Generate a 2D depiction for a molecule where all or part of.
RDDepict::DepictException::DepictException
DepictException(const char *msg)
Definition: RDDepictor.h:33
RDDepict::DepictException::message
const char * message() const
Definition: RDDepictor.h:35
RDKit::ROMol
Definition: ROMol.h:171
RDGeom::INT_POINT2D_MAP
std::map< int, Point2D > INT_POINT2D_MAP
Definition: point.h:518
RDDepict::DepictException::~DepictException
~DepictException()
Definition: RDDepictor.h:36
RDDepict::generateDepictionMatching2DStructure
RDKIT_DEPICTOR_EXPORT void generateDepictionMatching2DStructure(RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId=-1, RDKit::ROMol *referencePattern=static_cast< RDKit::ROMol * >(0), bool acceptFailure=false, bool forceRDKit=false)
Compute 2D coordinates where a piece of the molecule is.
RDKit
Std stuff.
Definition: Atom.h:30
RDDepict::DOUBLE_SMART_PTR
boost::shared_array< double > DOUBLE_SMART_PTR
Definition: EmbeddedFrag.h:26
RDDepict::compute2DCoords
RDKIT_DEPICTOR_EXPORT 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, bool forceRDKit=false)
Generate 2D coordinates (a depiction) for a molecule.
RDDepict::DepictException::DepictException
DepictException(const std::string msg)
Definition: RDDepictor.h:34
RDDepict
Definition: Reaction.h:444
export.h