RDKit
Open-source cheminformatics and machine learning.
StereoGroup.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2018-2021 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 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 <iostream>
22 #include <vector>
23 
24 namespace RDKit {
25 class Atom;
26 
27 // OR means that it is known to be one or the other, but not both
28 // AND means that it is known to be a mix.
29 enum class StereoGroupType {
30  STEREO_ABSOLUTE = 0,
31  STEREO_OR = 1,
32  STEREO_AND = 2
33 };
34 
35 //! StereoGroup is a collection of atoms with a known stereochemical
36 //! relationship
37 /*!
38  Used to help represent a sample with unknown stereochemistry, or that is a mix
39  of diastereomers.
40 
41  */
43  private:
45  std::vector<Atom*> d_atoms;
46 
47  public:
48  StereoGroup() : d_atoms(0u) {}
49  // Takes control of atoms if possible.
50  StereoGroup(StereoGroupType grouptype, std::vector<Atom*>&& atoms);
51  StereoGroup(StereoGroupType grouptype, const std::vector<Atom*>& atoms);
52  StereoGroup(const StereoGroup& other) = default;
53  StereoGroup& operator=(const StereoGroup& other) = default;
54  StereoGroup(StereoGroup&& other) = default;
55  StereoGroup& operator=(StereoGroup&& other) = default;
56 
58  const std::vector<Atom*>& getAtoms() const;
59  // Seems odd to have to define these, but otherwise the SWIG wrappers
60  // won't build
61  bool operator==(const StereoGroup& other) const {
62  return (d_grouptype == other.d_grouptype) && (d_atoms == other.d_atoms);
63  }
64  bool operator!=(const StereoGroup& other) const {
65  return (d_grouptype != other.d_grouptype) || (d_atoms != other.d_atoms);
66  }
67 };
69  const Atom* atom, std::vector<StereoGroup>& groups);
71  const std::vector<Atom*>& atoms, std::vector<StereoGroup>& groups);
72 
73 } // namespace RDKit
74 
75 //! allows StereoGroup objects to be dumped to streams
76 RDKIT_GRAPHMOL_EXPORT std::ostream& operator<<(std::ostream& target,
77  const RDKit::StereoGroup& stg);
78 
79 #endif
RDKIT_GRAPHMOL_EXPORT std::ostream & operator<<(std::ostream &target, const RDKit::StereoGroup &stg)
allows StereoGroup objects to be dumped to streams
The class for representing atoms.
Definition: Atom.h:68
const std::vector< Atom * > & getAtoms() const
StereoGroup(StereoGroupType grouptype, std::vector< Atom * > &&atoms)
StereoGroup & operator=(const StereoGroup &other)=default
StereoGroup(const StereoGroup &other)=default
StereoGroupType getGroupType() const
StereoGroup(StereoGroup &&other)=default
bool operator==(const StereoGroup &other) const
Definition: StereoGroup.h:61
StereoGroup & operator=(StereoGroup &&other)=default
StereoGroup(StereoGroupType grouptype, const std::vector< Atom * > &atoms)
bool operator!=(const StereoGroup &other) const
Definition: StereoGroup.h:64
#define RDKIT_GRAPHMOL_EXPORT
Definition: export.h:225
Std stuff.
Definition: Abbreviations.h:19
StereoGroupType
Definition: StereoGroup.h:29
RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtom(const Atom *atom, std::vector< StereoGroup > &groups)
RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtoms(const std::vector< Atom * > &atoms, std::vector< StereoGroup > &groups)