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 <vector>
22
23namespace RDKit {
24class Atom;
25class Bond;
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.
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:
46 std::vector<Atom *> d_atoms;
47 std::vector<Bond *> d_bonds;
48
49 // The group ID for AND/OR groups (it has no meaning in ABS groups).
50 // 0 means no group ID is defined.
51 unsigned d_readId = 0u;
52 unsigned d_writeId = 0u;
53
54 public:
56 // Takes control of atoms if possible.
57 StereoGroup(StereoGroupType grouptype, std::vector<Atom *> &&atoms,
58 std::vector<Bond *> &&bonds, unsigned readId = 0);
59 StereoGroup(StereoGroupType grouptype, const std::vector<Atom *> &atoms,
60 const std::vector<Bond *> &bonds, unsigned readId = 0);
61
62 StereoGroup(const StereoGroup &other) = default;
63 StereoGroup &operator=(const StereoGroup &other) = default;
64 StereoGroup(StereoGroup &&other) = default;
65 StereoGroup &operator=(StereoGroup &&other) = default;
66
68 const std::vector<Atom *> &getAtoms() const;
69 const std::vector<Bond *> &getBonds() const;
70
71 unsigned getReadId() const { return d_readId; }
72 unsigned getWriteId() const { return d_writeId; }
73 void setWriteId(unsigned id) { d_writeId = id; }
74
75 // Seems odd to have to define these, but otherwise the SWIG wrappers
76 // won't build
77 bool operator==(const StereoGroup &other) const {
78 return (d_grouptype == other.d_grouptype) && (d_atoms == other.d_atoms) &&
79 (d_bonds == other.d_bonds);
80 }
81 bool operator!=(const StereoGroup &other) const {
82 return (d_grouptype != other.d_grouptype) || (d_atoms != other.d_atoms) ||
83 (d_bonds != other.d_bonds);
84 }
86 const Atom *atom, std::vector<StereoGroup> &groups);
88 const Bond *bond, std::vector<StereoGroup> &groups);
89};
91 const Atom *atom, std::vector<StereoGroup> &groups);
93 const Bond *bond, std::vector<StereoGroup> &groups);
95 const Atom *atom, std::vector<StereoGroup> &groups);
97 const std::vector<Atom *> &atoms, std::vector<StereoGroup> &groups);
98
99//! Assign Group output IDs to all AND and OR StereoGroups in the vector
100//! that don't already have one. The IDs are assigned based on the order
101//! of the groups.
103 std::vector<StereoGroup> &groups);
104
105//! Copy StereoGroup "read" IDs to "write" IDs so that they will be preserved
106//! when the mol is exported.
108
109} // namespace RDKit
110
111//! allows StereoGroup objects to be dumped to streams
112RDKIT_GRAPHMOL_EXPORT std::ostream &operator<<(std::ostream &target,
113 const RDKit::StereoGroup &stg);
114
115#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:74
class for representing a bond
Definition Bond.h:46
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:72
StereoGroup(const StereoGroup &other)=default
StereoGroupType getGroupType() const
unsigned getReadId() const
Definition StereoGroup.h:71
StereoGroup(StereoGroup &&other)=default
bool operator==(const StereoGroup &other) const
Definition StereoGroup.h:77
void setWriteId(unsigned id)
Definition StereoGroup.h:73
StereoGroup(StereoGroupType grouptype, const std::vector< Atom * > &atoms, const std::vector< Bond * > &bonds, unsigned readId=0)
friend RDKIT_GRAPHMOL_EXPORT void removeAtomFromGroups(const Atom *atom, std::vector< StereoGroup > &groups)
friend RDKIT_GRAPHMOL_EXPORT void removeBondFromGroups(const Bond *bond, std::vector< StereoGroup > &groups)
bool operator!=(const StereoGroup &other) const
Definition StereoGroup.h:81
const std::vector< Atom * > & getAtoms() const
const std::vector< Bond * > & getBonds() const
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:249
Std stuff.
RDKIT_GRAPHMOL_EXPORT void forwardStereoGroupIds(ROMol &mol)
StereoGroupType
Definition StereoGroup.h:30
RDKIT_GRAPHMOL_EXPORT void removeGroupsWithAtom(const Atom *atom, std::vector< StereoGroup > &groups)
RDKIT_GRAPHMOL_EXPORT void removeBondFromGroups(const Bond *bond, 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)