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 *what() const noexcept override{ return _msg.c_str(); };
36  const char *message() const noexcept{ return what(); };
37  ~DepictException() noexcept {};
38 
39  private:
40  std::string _msg;
41 };
42 
43 //! \brief Generate 2D coordinates (a depiction) for a molecule
44 /*!
45 
46  \param mol the molecule were are interested in
47 
48  \param coordMap a map of int to Point2D, between atom IDs and
49  their locations. This is the container the user needs to fill if
50  he/she wants to specify coordinates for a portion of the molecule,
51  defaults to 0
52 
53  \param canonOrient canonicalize the orientation so that the long
54  axes align with the x-axis etc.
55 
56  \param clearConfs clear all existing conformations on the molecule
57  before adding the 2D coordinates instead of simply adding to the
58  list
59 
60  \param nFlipsPerSample - the number of rotatable bonds that are
61  flipped at random for each sample
62 
63  \param nSamples - the number of samples
64 
65  \param sampleSeed - seed for the random sampling process
66 
67  \param permuteDeg4Nodes - try permuting the drawing order of bonds around
68  atoms with four neighbors in order to improve the depiction
69 
70  \return ID of the conformation added to the molecule containing the
71  2D coordinates
72 
73 */
75  RDKit::ROMol &mol, const RDGeom::INT_POINT2D_MAP *coordMap = 0,
76  bool canonOrient = false, bool clearConfs = true,
77  unsigned int nFlipsPerSample = 0, unsigned int nSamples = 0,
78  int sampleSeed = 0, bool permuteDeg4Nodes = false, bool forceRDKit = false);
79 
80 //! \brief Compute the 2D coordinates such the interatom distances
81 // mimic those in a distance matrix
82 /*!
83 
84  This function generates 2D coordinates such that the inter-atom
85  distances mimic those specified via dmat. This is done by randomly
86  sampling(flipping) the rotatable bonds in the molecule and
87  evaluating a cost function which contains two components. The
88  first component is the sum of inverse of the squared inter-atom
89  distances, this helps in spreading the atoms far from each
90  other. The second component is the sum of squares of the
91  difference in distance between those in dmat and the generated
92  structure. The user can adjust the relative importance of the two
93  components via a adjustable parameter (see below)
94 
95  ARGUMENTS:
96 
97  \param mol - molecule to generate coordinates for
98 
99  \param dmat - the distance matrix we want to mimic, this is a
100  symmetric N by N matrix where N is the number of atoms in mol. All
101  negative entries in dmat are ignored.
102 
103  \param canonOrient - canonicalize the orientation after the 2D
104  embedding is done
105 
106  \param clearConfs - clear any previously existing conformations on
107  mol before adding a conformation
108 
109  \param weightDistMat - A value between 0.0 and 1.0, this
110  determines the importance of mimicing the inter atoms
111  distances in dmat. (1.0 - weightDistMat) is the weight associated
112  to spreading out the structure (density) in the cost function
113 
114  \param nFlipsPerSample - the number of rotatable bonds that are
115  flipped at random for each sample
116 
117  \param nSamples - the number of samples
118 
119  \param sampleSeed - seed for the random sampling process
120 
121  \param permuteDeg4Nodes - try permuting the drawing order of bonds around
122  atoms with four neighbors in order to improve the depiction
123 
124  \return ID of the conformation added to the molecule containing the
125  2D coordinates
126 
127 
128 */
130  RDKit::ROMol &mol, const DOUBLE_SMART_PTR *dmat = 0,
131  bool canonOrient = true, bool clearConfs = true, double weightDistMat = 0.5,
132  unsigned int nFlipsPerSample = 3, unsigned int nSamples = 100,
133  int sampleSeed = 25, bool permuteDeg4Nodes = true, bool forceRDKit = false);
134 
135 //! \brief Compute 2D coordinates where a piece of the molecule is
136 // constrained to have the same coordinates as a reference.
137 /*!
138  This function generates a depiction for a molecule where a piece of the
139  molecule is constrained to have the same coordinates as a reference.
140 
141  This is useful for, for example, generating depictions of SAR data
142  sets so that the cores of the molecules are all oriented the same way.
143 
144  ARGUMENTS:
145 
146  \param mol - the molecule to be aligned, this will come back
147  with a single conformer.
148  \param reference - a molecule with the reference atoms to align to;
149  this should have a depiction.
150  \param confId - (optional) the id of the reference conformation to use
151  \param referencePattern - (optional) a query molecule to be used to
152  generate the atom mapping between the molecule
153  and the reference.
154  \param acceptFailure - (optional) if True, standard depictions will be
155  generated
156  for molecules that don't have a substructure match to
157  the
158  reference; if false, throws a DepictException.
159 
160 */
162  RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId = -1,
163  RDKit::ROMol *referencePattern = static_cast<RDKit::ROMol *>(0),
164  bool acceptFailure = false, bool forceRDKit = false);
165 
166 //! \brief Generate a 2D depiction for a molecule where all or part of
167 // it mimics the coordinates of a 3D reference structure.
168 /*!
169  Generates a depiction for a molecule where a piece of the molecule
170  is constrained to have coordinates similar to those of a 3D reference
171  structure.
172 
173  ARGUMENTS:
174  \param mol - the molecule to be aligned, this will come back
175  with a single conformer containing 2D coordinates
176  \param reference - a molecule with the reference atoms to align to.
177  By default this should be the same as mol, but with
178  3D coordinates
179  \param confId - (optional) the id of the reference conformation to use
180  \param refPattern - (optional) a query molecule to map a subset of
181  the reference onto the mol, so that only some of the
182  atoms are aligned.
183  \param acceptFailure - (optional) if true, standard depictions will be
184  generated
185  for molecules that don't match the reference or the
186  referencePattern; if false, throws a DepictException.
187 */
189  RDKit::ROMol &mol, const RDKit::ROMol &reference, int confId = -1,
190  RDKit::ROMol *referencePattern = 0, bool acceptFailure = false,
191  bool forceRDKit = false);
192 }; // namespace RDDepict
193 
194 #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::~DepictException
~DepictException() noexcept
Definition: RDDepictor.h:37
RDDepict::DepictException::message
const char * message() const noexcept
Definition: RDDepictor.h:36
RDKit::ROMol
Definition: ROMol.h:171
RDGeom::INT_POINT2D_MAP
std::map< int, Point2D > INT_POINT2D_MAP
Definition: point.h:518
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:445
RDDepict::DepictException::what
const char * what() const noexcept override
Definition: RDDepictor.h:35
export.h