RDKit
Open-source cheminformatics and machine learning.
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;
25
26namespace Chirality {
27
28//! double bond stereo will be ignored/removed for rings smaller than this:
29constexpr unsigned int minRingSizeForDoubleBondStereo = 8;
30
31constexpr auto nonTetrahedralStereoEnvVar = "RDK_ENABLE_NONTETRAHEDRAL_STEREO";
32constexpr auto useLegacyStereoEnvVar = "RDK_USE_LEGACY_STEREO_PERCEPTION";
34 true; //!< whether or not nontetrahedral stereo is perceived by default
36 true; //!< whether or not the legacy stereo perception code is used by
37 //!< default
38
41
44
45RDKIT_GRAPHMOL_EXPORT extern bool
46 useLegacyStereoPerception; //!< Toggle usage of the legacy stereo
47 //!< perception code
48
49RDKIT_GRAPHMOL_EXPORT extern bool
50 useLegacyStereoPerception; //!< Toggle usage of the legacy stereo
51 //!< perception code
52
53/// @cond
54/*!
55 \param mol the molecule to be altered
56 \param ranks used to return the set of ranks.
57 Should be at least mol.getNumAtoms() long.
58
59 <b>Notes:</b>
60 - All atoms gain a property common_properties::_CIPRank with their overall
61 CIP ranking.
62
63*/
64RDKIT_GRAPHMOL_EXPORT void assignAtomCIPRanks(const ROMol &mol,
65 UINT_VECT &ranks);
66
67RDKIT_GRAPHMOL_EXPORT bool hasStereoBondDir(const Bond *bond);
68
69/**
70 * Returns the first neighboring bond that can be found which has a stereo
71 * bond direction set. If no such bond can be found, it returns null. No
72 * checks are made to ensure there aren't any other conflicting directed bonds.
73 */
74RDKIT_GRAPHMOL_EXPORT const Bond *getNeighboringDirectedBond(const ROMol &mol,
75 const Atom *atom);
76
77/**
78 * This just translates the labels, setting/translating StereoAtoms or the
79 * label is not the responsibility of this function. If the passed label is not
80 * E/Z, it will be returned unchanged.
81 */
82RDKIT_GRAPHMOL_EXPORT Bond::BondStereo translateEZLabelToCisTrans(
83 Bond::BondStereo label);
84/// @endcond
85
86enum class StereoType {
92 Bond_Double, // single double bond and odd-numbered cumulenes
93 Bond_Cumulene_Even, // even-numbered cumulenes
95};
96
98
99enum class StereoSpecified {
100 Unspecified, // no information provided
101 Specified,
102 Unknown // deliberately marked as unknown
103};
104
106 // REVIEW: absolute stereo data member?
107#ifdef _MSC_VER
108 static const unsigned NOATOM =
109 std::numeric_limits<unsigned>::max(); // used to mark missing atoms
110#else
111 static const unsigned NOATOM; // used to mark missing atoms
112#endif
115 unsigned centeredOn = NOATOM;
117 unsigned permutation = 0; // for the non-tetrahedral stereo cases
118 std::vector<unsigned> controllingAtoms; // all atoms around the atom or bond.
119 // Order is important
120 bool operator==(const StereoInfo &other) const {
121 return type == other.type && specified == other.specified &&
122 centeredOn == other.centeredOn && descriptor == other.descriptor &&
123 permutation == other.permutation &&
124 controllingAtoms == other.controllingAtoms;
125 }
126 bool operator!=(const StereoInfo &other) const { return !(*this == other); }
127};
128
129//! identifies potential stereoatoms and stereobonds in a molecule
130/*!
131 Note that this function is still somewhat experimental and the API
132 and results may change in a future release.
133
134 \param mol the molecule to look for stereo in
135 \param cleanIt remove chirality/stereo specifications from atoms/bonds that
136 cannot be chiral/stereo
137*/
139 ROMol &mol, bool cleanIt, bool flagPossible = true);
140//! overload
142 const ROMol &mol);
143
144//! removes atoms without specified chirality from stereo groups
146
147//! calls the approximate legacy code for assigning CIP labels
149 ROMol &mol, bool flagPossibleStereoCenters = false);
150
151/// @cond
152namespace detail {
153RDKIT_GRAPHMOL_EXPORT bool isAtomPotentialNontetrahedralCenter(
154 const Atom *atom);
155RDKIT_GRAPHMOL_EXPORT bool isAtomPotentialTetrahedralCenter(const Atom *atom);
156RDKIT_GRAPHMOL_EXPORT bool isAtomPotentialStereoAtom(const Atom *atom);
157RDKIT_GRAPHMOL_EXPORT bool isBondPotentialStereoBond(const Bond *bond);
158RDKIT_GRAPHMOL_EXPORT StereoInfo getStereoInfo(const Bond *bond);
159RDKIT_GRAPHMOL_EXPORT StereoInfo getStereoInfo(const Atom *atom);
160RDKIT_GRAPHMOL_EXPORT bool bondAffectsAtomChirality(const Bond *bond,
161 const Atom *atom);
162RDKIT_GRAPHMOL_EXPORT unsigned int getAtomNonzeroDegree(const Atom *atom);
163} // namespace detail
164/// @endcond
165
167
168//! \name Non-tetrahedral stereochemistry
169//! @{
172 const Bond *qry);
174 const Atom *qry);
176 const Bond *qry);
178 const Atom *qry);
179//! \param which: if this is -1 then the second axial bond will be returned,
180//! otherwise the first
182 int which = 0);
184 int which = 0);
185
186//! \returns 1 if it's the first axial atom, -1 if it's the second
188 const Bond *qry);
190 const Atom *qry);
191
193 const Atom *lig1,
194 const Atom *lig2);
195
197 const INT_LIST &probe);
198//! @}
199
200RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(std::ostream &oss,
201 const StereoSpecified &s);
202RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(std::ostream &oss,
203 const StereoType &s);
204
205} // namespace Chirality
206} // namespace RDKit
207#endif
The class for representing atoms.
Definition: Atom.h:68
class for representing a bond
Definition: Bond.h:47
BondStereo
the nature of the bond's stereochem (for cis/trans)
Definition: Bond.h:95
#define RDKIT_GRAPHMOL_EXPORT
Definition: export.h:225
RDKIT_GRAPHMOL_EXPORT bool getUseLegacyStereoPerception()
RDKIT_GRAPHMOL_EXPORT int isTrigonalBipyramidalAxialAtom(const Atom *center, const Atom *qry)
RDKIT_GRAPHMOL_EXPORT bool getAllowNontetrahedralChirality()
RDKIT_GRAPHMOL_EXPORT Atom * getTrigonalBipyramidalAxialAtom(const Atom *center, int which=0)
RDKIT_GRAPHMOL_EXPORT void setUseLegacyStereoPerception(bool val)
constexpr unsigned int minRingSizeForDoubleBondStereo
double bond stereo will be ignored/removed for rings smaller than this:
Definition: Chirality.h:29
constexpr bool useLegacyStereoDefaultVal
Definition: Chirality.h:35
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)
constexpr auto nonTetrahedralStereoEnvVar
Definition: Chirality.h:31
constexpr auto useLegacyStereoEnvVar
Definition: Chirality.h:32
RDKIT_GRAPHMOL_EXPORT bool useLegacyStereoPerception
Definition: Chirality.h:50
RDKIT_GRAPHMOL_EXPORT std::ostream & operator<<(std::ostream &oss, const StereoSpecified &s)
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:33
RDKIT_GRAPHMOL_EXPORT INT_VECT findStereoAtoms(const Bond *bond)
RDKIT_GRAPHMOL_EXPORT void assignLegacyCIPLabels(ROMol &mol, bool flagPossibleStereoCenters=false)
calls the approximate legacy code for assigning CIP labels
Std stuff.
Definition: Abbreviations.h:19
std::list< int > INT_LIST
Definition: types.h:284
std::vector< int > INT_VECT
Definition: types.h:278
std::vector< UINT > UINT_VECT
Definition: types.h:297
static const unsigned NOATOM
Definition: Chirality.h:111
std::vector< unsigned > controllingAtoms
Definition: Chirality.h:118
StereoSpecified specified
Definition: Chirality.h:114
StereoDescriptor descriptor
Definition: Chirality.h:116
bool operator!=(const StereoInfo &other) const
Definition: Chirality.h:126
bool operator==(const StereoInfo &other) const
Definition: Chirality.h:120