RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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
24namespace RDKit {
25class Atom;
26class ROMol;
27
28// OR means that it is known to be one or the other, but not both
29// AND means that it is known to be a mix.
30enum class StereoGroupType {
32 STEREO_OR = 1,
33 STEREO_AND = 2
34};
35
36//! StereoGroup is a collection of atoms with a known stereochemical
37//! relationship
38/*!
39 Used to help represent a sample with unknown stereochemistry, or that is a mix
40 of diastereomers.
41
42 */
44 private:
45 StereoGroupType d_grouptype{StereoGroupType::STEREO_ABSOLUTE};
46 std::vector<Atom*> d_atoms;
47
48 // The group ID for AND/OR groups (it has no meaning in ABS groups).
49 // 0 means no group ID is defined.
50 unsigned d_readId = 0u;
51 unsigned d_writeId = 0u;
52
53 public:
55 // Takes control of atoms if possible.
56 StereoGroup(StereoGroupType grouptype, std::vector<Atom*>&& atoms,
57 unsigned readId = 0);
58 StereoGroup(StereoGroupType grouptype, const std::vector<Atom*>& atoms,
59 unsigned readId = 0);
60 StereoGroup(const StereoGroup& other) = default;
61 StereoGroup& operator=(const StereoGroup& other) = default;
62 StereoGroup(StereoGroup&& other) = default;
63 StereoGroup& operator=(StereoGroup&& other) = default;
64
66 const std::vector<Atom*>& getAtoms() const;
67
68 unsigned getReadId() const { return d_readId; }
69 unsigned getWriteId() const { return d_writeId; }
70 void setWriteId(unsigned id) { d_writeId = id; }
71
72 // Seems odd to have to define these, but otherwise the SWIG wrappers
73 // won't build
74 bool operator==(const StereoGroup& other) const {
75 return (d_grouptype == other.d_grouptype) && (d_atoms == other.d_atoms);
76 }
77 bool operator!=(const StereoGroup& other) const {
78 return (d_grouptype != other.d_grouptype) || (d_atoms != other.d_atoms);
79 }
80};
82 const Atom* atom, std::vector<StereoGroup>& groups);
84 const std::vector<Atom*>& atoms, std::vector<StereoGroup>& groups);
85
86//! Assign Group output IDs to all AND and OR StereoGroups in the vector
87//! that don't already have one. The IDs are assigned based on the order
88//! of the groups.
90 std::vector<StereoGroup>& groups);
91
92//! Copy StereoGroup "read" IDs to "write" IDs so that they will be preserved
93//! when the mol is exported.
95
96} // namespace RDKit
97
98//! allows StereoGroup objects to be dumped to streams
99RDKIT_GRAPHMOL_EXPORT std::ostream& operator<<(std::ostream& target,
100 const RDKit::StereoGroup& stg);
101
102#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
StereoGroup & operator=(const StereoGroup &other)=default
StereoGroup & operator=(StereoGroup &&other)=default
unsigned getWriteId() const
Definition StereoGroup.h:69
StereoGroup(StereoGroupType grouptype, const std::vector< Atom * > &atoms, unsigned readId=0)
StereoGroup(const StereoGroup &other)=default
StereoGroup(StereoGroupType grouptype, std::vector< Atom * > &&atoms, unsigned readId=0)
StereoGroupType getGroupType() const
unsigned getReadId() const
Definition StereoGroup.h:68
StereoGroup(StereoGroup &&other)=default
bool operator==(const StereoGroup &other) const
Definition StereoGroup.h:74
void setWriteId(unsigned id)
Definition StereoGroup.h:70
bool operator!=(const StereoGroup &other) const
Definition StereoGroup.h:77
const std::vector< Atom * > & getAtoms() const
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:233
Std stuff.
RDKIT_GRAPHMOL_EXPORT void forwardStereoGroupIds(ROMol &mol)
StereoGroupType
Definition StereoGroup.h:30
bool rdvalue_is(const RDValue_cast_t)
RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtom(const Atom *atom, std::vector< StereoGroup > &groups)
RDKIT_GRAPHMOL_EXPORT void assignStereoGroupIds(std::vector< StereoGroup > &groups)
RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtoms(const std::vector< Atom * > &atoms, std::vector< StereoGroup > &groups)