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