RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
Chirality.h
Go to the documentation of this file.
1//
2// Copyright (C) 2008-2022 Greg Landrum and other RDKit contributors
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/*! \file Chirality.h
11
12*/
13#include <RDGeneral/export.h>
14#ifndef RD_CHIRALITY_20AUG2008_H
15#define RD_CHIRALITY_20AUG2008_H
16#include <RDGeneral/types.h>
17#include <GraphMol/Bond.h>
18#include <boost/dynamic_bitset.hpp>
19#include <limits>
20
21namespace RDKit {
22class Atom;
23class Bond;
24class ROMol;
25class Conformer;
26
27namespace Chirality {
28
29//! double bond stereo will be ignored/removed for rings smaller than this:
30constexpr unsigned int minRingSizeForDoubleBondStereo = 8;
31
32constexpr auto nonTetrahedralStereoEnvVar = "RDK_ENABLE_NONTETRAHEDRAL_STEREO";
33constexpr auto useLegacyStereoEnvVar = "RDK_USE_LEGACY_STEREO_PERCEPTION";
35 true; //!< whether or not nontetrahedral stereo is perceived by default
37 true; //!< whether or not the legacy stereo perception code is used by
38 //!< default
39
42
45
46RDKIT_GRAPHMOL_EXPORT extern bool
47 useLegacyStereoPerception; //!< Toggle usage of the legacy stereo
48 //!< perception code
49
50RDKIT_GRAPHMOL_EXPORT extern bool
51 useLegacyStereoPerception; //!< Toggle usage of the legacy stereo
52 //!< perception code
53
54/// @cond
55/*!
56 \param mol the molecule to be altered
57 \param ranks used to return the set of ranks.
58 Should be at least mol.getNumAtoms() long.
59
60 <b>Notes:</b>
61 - All atoms gain a property common_properties::_CIPRank with their overall
62 CIP ranking.
63
64*/
67
69
70// this routine removes chiral markers and stereo indications that should not be
71// present this is only called when the molecule has not been sanitized and when
72// the new stereo (not legacy) is in use
73
75
76/**
77 * Returns the first neighboring bond that can be found which has a stereo
78 * bond direction set. If no such bond can be found, it returns null. No
79 * checks are made to ensure there aren't any other conflicting directed bonds.
80 */
82 const Atom *atom);
83
84/**
85 * This just translates the labels, setting/translating StereoAtoms or the
86 * label is not the responsibility of this function. If the passed label is not
87 * E/Z, it will be returned unchanged.
88 */
90 Bond::BondStereo label);
91/// @endcond
92
93enum class StereoType {
99 Bond_Double, // single double bond and odd-numbered cumulenes
100 Bond_Cumulene_Even, // even-numbered cumulenes
102};
103
105
106enum class StereoSpecified {
107 Unspecified, // no information provided
108 Specified,
109 Unknown // deliberately marked as unknown
110};
111
113 // REVIEW: absolute stereo data member?
114#ifdef _MSC_VER
115 static const unsigned NOATOM =
116 std::numeric_limits<unsigned>::max(); // used to mark missing atoms
117#else
118 static const unsigned NOATOM; // used to mark missing atoms
119#endif
120 StereoType type = StereoType::Unspecified;
121 StereoSpecified specified = StereoSpecified::Unspecified;
122 unsigned centeredOn = NOATOM;
123 StereoDescriptor descriptor = StereoDescriptor::None;
124 unsigned permutation = 0; // for the non-tetrahedral stereo cases
125 std::vector<unsigned> controllingAtoms; // all atoms around the atom or bond.
126 // Order is important
127 bool operator==(const StereoInfo &other) const {
128 return type == other.type && specified == other.specified &&
129 centeredOn == other.centeredOn && descriptor == other.descriptor &&
130 permutation == other.permutation &&
131 controllingAtoms == other.controllingAtoms;
132 }
133 bool operator!=(const StereoInfo &other) const { return !(*this == other); }
134};
135
136//! identifies potential stereoatoms and stereobonds in a molecule
137/*!
138 Note that this function is still somewhat experimental and the API
139 and results may change in a future release.
140
141 \param mol the molecule to look for stereo in
142 \param cleanIt remove chirality/stereo specifications from atoms/bonds that
143 cannot be chiral/stereo
144*/
146 ROMol &mol, bool cleanIt, bool flagPossible = true);
147//! overload
149 const ROMol &mol);
150
151//! removes atoms without specified chirality from stereo groups
153
154//! calls the approximate legacy code for assigning CIP labels
156 ROMol &mol, bool flagPossibleStereoCenters = false);
157
158/// @cond
159namespace detail {
161 const Atom *atom);
168 const Atom *atom);
169RDKIT_GRAPHMOL_EXPORT unsigned int getAtomNonzeroDegree(const Atom *atom);
170
172 const Atom *atom);
173
174} // namespace detail
175/// @endcond
176
178
179//! \name Non-tetrahedral stereochemistry
180//! @{
183 const Bond *qry);
185 const Atom *qry);
187 const Bond *qry);
189 const Atom *qry);
190//! \param which: if this is -1 then the second axial bond will be returned,
191//! otherwise the first
193 int which = 0);
195 int which = 0);
196
197//! \returns 1 if it's the first axial atom, -1 if it's the second
199 const Bond *qry);
201 const Atom *qry);
202
204 const Atom *lig1,
205 const Atom *lig2);
206
208 const INT_LIST &probe);
209//! @}
210
211RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(std::ostream &oss,
212 const StereoSpecified &s);
213RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(std::ostream &oss,
214 const StereoType &s);
215
217 bool wedgeTwoBondsIfPossible =
218 false; //!< If this is enabled then two bonds will be wedged at chiral
219 //!< centers subject to the following constraints:
220 //!< 1. ring bonds will not be wedged
221 //!< 2. bonds to chiral centers will not be wedged
222 //!< 3. bonds separated by more than 120 degrees will not be
223 //!< wedged
224};
225
240
241//! picks the bonds which should be wedged
242/// \returns a map from bond idx -> controlling atom idx
244 const ROMol &mol, const BondWedgingParameters *params = nullptr);
245
247 ROMol &mol, const Conformer *conf = nullptr,
248 const BondWedgingParameters *params = nullptr);
250 const Conformer *conf);
251
252//! Returns whether or not a bond is a candidate for bond stereo
254
255//! Returns true for double bonds which should be shown as a crossed bonds.
256// It always returns false if any adjacent bond is a squiggle bond.
258
259//! Clears existing bond wedging and forces use of atom wedging from MolBlock.
260/*!
261 \param mol: molecule to have its wedges altered
262 */
264//! Remove MolBlock bond wedging information from molecule.
265/*!
266 \param mol: molecule to modify
267 */
269//! Invert bond wedging information read from a mol block (if present).
270/*!
271 \param mol: molecule to modify
272 */
274
275} // namespace Chirality
276} // namespace RDKit
277#endif
The class for representing atoms.
Definition Atom.h:68
class for representing a bond
Definition Bond.h:47
BondDir
the bond's direction (for chirality)
Definition Bond.h:83
BondStereo
the nature of the bond's stereochem (for cis/trans)
Definition Bond.h:95
@ STEREOANY
Definition Bond.h:97
The class for representing 2D or 3D conformation of a molecule.
Definition Conformer.h:46
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:233
RDKIT_GRAPHMOL_EXPORT int pickBondToWedge(const Atom *atom, const ROMol &mol, const INT_VECT &nChiralNbrs, const INT_MAP_INT &resSoFar, int noNbrs)
RDKIT_GRAPHMOL_EXPORT std::pair< bool, INT_VECT > countChiralNbrs(const ROMol &mol, int noNbrs)
RDKIT_GRAPHMOL_EXPORT void setStereoanyFromSquiggleBond(ROMol &mol, Bond *bond, Bond::BondStereo stereo=Bond::STEREOANY)
RDKIT_GRAPHMOL_EXPORT Bond::BondDir determineBondWedgeState(const Bond *bond, unsigned int fromAtomIdx, const Conformer *conf)
RDKIT_GRAPHMOL_EXPORT bool getUseLegacyStereoPerception()
RDKIT_GRAPHMOL_EXPORT int isTrigonalBipyramidalAxialAtom(const Atom *center, const Atom *qry)
RDKIT_GRAPHMOL_EXPORT bool getAllowNontetrahedralChirality()
RDKIT_GRAPHMOL_EXPORT void wedgeMolBonds(ROMol &mol, const Conformer *conf=nullptr, const BondWedgingParameters *params=nullptr)
RDKIT_GRAPHMOL_EXPORT void reapplyMolBlockWedging(ROMol &mol)
Clears existing bond wedging and forces use of atom wedging from MolBlock.
RDKIT_GRAPHMOL_EXPORT Atom * getTrigonalBipyramidalAxialAtom(const Atom *center, int which=0)
RDKIT_GRAPHMOL_EXPORT void invertMolBlockWedgingInfo(ROMol &mol)
Invert bond wedging information read from a mol block (if present).
RDKIT_GRAPHMOL_EXPORT void setUseLegacyStereoPerception(bool val)
RDKIT_GRAPHMOL_EXPORT bool shouldBeACrossedBond(const Bond *bond)
Returns true for double bonds which should be shown as a crossed bonds.
constexpr unsigned int minRingSizeForDoubleBondStereo
double bond stereo will be ignored/removed for rings smaller than this:
Definition Chirality.h:30
constexpr bool useLegacyStereoDefaultVal
Definition Chirality.h:36
RDKIT_GRAPHMOL_EXPORT Atom * getChiralAcrossAtom(const Atom *center, const Bond *qry)
RDKIT_GRAPHMOL_EXPORT void setAllowNontetrahedralChirality(bool val)
RDKIT_GRAPHMOL_EXPORT Bond * getTrigonalBipyramidalAxialBond(const Atom *center, int which=0)
RDKIT_GRAPHMOL_EXPORT bool canBeStereoBond(const Bond *bond)
Returns whether or not a bond is a candidate for bond stereo.
constexpr auto nonTetrahedralStereoEnvVar
Definition Chirality.h:32
constexpr auto useLegacyStereoEnvVar
Definition Chirality.h:33
RDKIT_GRAPHMOL_EXPORT bool useLegacyStereoPerception
Definition Chirality.h:51
RDKIT_GRAPHMOL_EXPORT std::ostream & operator<<(std::ostream &oss, const StereoSpecified &s)
RDKIT_GRAPHMOL_EXPORT void wedgeBond(Bond *bond, unsigned int fromAtomIdx, const Conformer *conf)
RDKIT_GRAPHMOL_EXPORT std::vector< StereoInfo > findPotentialStereo(ROMol &mol, bool cleanIt, bool flagPossible=true)
identifies potential stereoatoms and stereobonds in a molecule
RDKIT_GRAPHMOL_EXPORT unsigned int getChiralPermutation(const Atom *center, const INT_LIST &probe)
RDKIT_GRAPHMOL_EXPORT bool hasNonTetrahedralStereo(const Atom *center)
RDKIT_GRAPHMOL_EXPORT int isTrigonalBipyramidalAxialBond(const Atom *center, const Bond *qry)
RDKIT_GRAPHMOL_EXPORT double getIdealAngleBetweenLigands(const Atom *center, const Atom *lig1, const Atom *lig2)
RDKIT_GRAPHMOL_EXPORT void cleanupStereoGroups(ROMol &mol)
removes atoms without specified chirality from stereo groups
RDKIT_GRAPHMOL_EXPORT Bond * getChiralAcrossBond(const Atom *center, const Bond *qry)
constexpr bool nonTetrahedralStereoDefaultVal
whether or not nontetrahedral stereo is perceived by default
Definition Chirality.h:34
RDKIT_GRAPHMOL_EXPORT void clearMolBlockWedgingInfo(ROMol &mol)
Remove MolBlock bond wedging information from molecule.
RDKIT_GRAPHMOL_EXPORT INT_VECT findStereoAtoms(const Bond *bond)
RDKIT_GRAPHMOL_EXPORT INT_MAP_INT pickBondsToWedge(const ROMol &mol, const BondWedgingParameters *params=nullptr)
RDKIT_GRAPHMOL_EXPORT void assignLegacyCIPLabels(ROMol &mol, bool flagPossibleStereoCenters=false)
calls the approximate legacy code for assigning CIP labels
Std stuff.
std::list< int > INT_LIST
Definition types.h:287
std::vector< int > INT_VECT
Definition types.h:281
bool rdvalue_is(const RDValue_cast_t)
std::map< int, int > INT_MAP_INT
Definition types.h:319
std::vector< UINT > UINT_VECT
Definition types.h:300
static const unsigned NOATOM
Definition Chirality.h:118
std::vector< unsigned > controllingAtoms
Definition Chirality.h:125
StereoSpecified specified
Definition Chirality.h:121
StereoDescriptor descriptor
Definition Chirality.h:123
bool operator!=(const StereoInfo &other) const
Definition Chirality.h:133
bool operator==(const StereoInfo &other) const
Definition Chirality.h:127