1 //
2 //  Copyright (C) 2018 T5 Informatics GmbH
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 StereoGroup.h
11 
12   \brief Defines the class StereoGroup which stores relationships between
13   the absolute configurations of atoms within a structure.
14 
15 */
16 
17 #include <RDGeneral/export.h>
18 #ifndef RD_StereoGroup_092018
19 #define RD_StereoGroup_092018
20 
21 #include <vector>
22 
23 namespace RDKit {
24 class Atom;
25 
26 // OR means that it is known to be one or the other, but not both
27 // AND means that it is known to be a mix.
28 enum class StereoGroupType {
29   STEREO_ABSOLUTE = 0,
30   STEREO_OR = 1,
31   STEREO_AND = 2
32 };
33 
34 //! StereoGroup is a collection of atoms with a known stereochemical
35 //! relationship
36 /*!
37   Used to help represent a sample with unknown stereochemistry, or that is a mix
38   of diastereomers.
39 
40  */
41 class RDKIT_GRAPHMOL_EXPORT StereoGroup {
42  private:
43   StereoGroupType d_grouptype{StereoGroupType::STEREO_ABSOLUTE};
44   std::vector<Atom*> d_atoms;
45 
46  public:
StereoGroup()47   StereoGroup() :  d_atoms(0u){};
48   // Takes control of atoms if possible.
49   StereoGroup(StereoGroupType grouptype, std::vector<Atom*>&& atoms);
50   StereoGroup(StereoGroupType grouptype, const std::vector<Atom*>& atoms);
51   StereoGroupType getGroupType() const;
52   const std::vector<Atom*>& getAtoms() const;
53   // Seems odd to have to define these, but otherwise the SWIG wrappers
54   // won't build
55   bool operator==(const StereoGroup& other) const {
56     return (d_grouptype == other.d_grouptype) && (d_atoms == other.d_atoms);
57   };
58   bool operator!=(const StereoGroup& other) const {
59     return (d_grouptype != other.d_grouptype) || (d_atoms != other.d_atoms);
60   };
61 };
62 RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtom(
63     const Atom* atom, std::vector<StereoGroup>& groups);
64 RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtoms(
65     const std::vector<Atom*>& atoms, std::vector<StereoGroup>& groups);
66 
67 }  // namespace RDKit
68 
69 #endif
70