RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
MacroMol.h
Go to the documentation of this file.
1//
2// Copyright (C) 2026 Tad Hurst, Schrödinger 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
11#ifndef RD_MACROMOL_H
12#define RD_MACROMOL_H
13
14#include <memory>
15#include <string>
16
17#include "MacroAtomInfo.h"
18#include "MacroMolTemplate.h"
19#include "RWMol.h"
20
21namespace RDKit {
22
24 public:
25 //! Constructs a MacroMol with an empty local template library.
27
28 //! Constructs a MacroMol that takes ownership of a local template library.
29 /*!
30 \param localTemplateLibrary the non-null library to take ownership of
31 */
32 explicit MacroMol(
33 std::unique_ptr<MacroMolTemplateLibrary> localTemplateLibrary);
34
35 MacroMol(const MacroMol &other);
36 MacroMol &operator=(const MacroMol &other);
37 MacroMol(MacroMol &&other) noexcept = default;
38 MacroMol &operator=(MacroMol &&other) noexcept = default;
39
40 //! Replaces the local template library and takes ownership of it.
41 /*!
42 \param newTemplateLibrary the non-null library to take ownership of
43 */
45 std::unique_ptr<MacroMolTemplateLibrary> newTemplateLibrary);
46
47 //! Returns this molecule's local template library.
49 //! Returns this molecule's local template library.
51
52 //! Checks that every macro atom resolves in the local template library.
53 /*!
54 Macro atoms are looked up by monomer class and symbol, then by monomer
55 class and template name. Ordinary atoms are ignored.
56 */
58
59 //! Adds a new macro atom to the molecule.
60 /*!
61 \param symbol the symbol (dummy label) used to identify the monomer
62 \param monomerClass the class of monomer the macro atom represents
63
64 \return the index of the newly added atom
65 */
66 unsigned int addMacroAtom(std::string symbol, MonomerClass monomerClass);
67
68 //! Adds a bond between two macro atoms.
69 /*!
70 Both atoms must be macro atoms.
71 The graph bond's bond type is unspecified; use MacroBondInfo for the
72 macro bond type.
73
74 \param beginAtomIdx index of the atom where the bond begins
75 \param endAtomIdx index of the atom where the bond ends
76 \param beginAttachPt the attachment point on the begin (macro) atom
77 \param endAttachPt the attachment point on the end (macro) atom
78 \param bondType the type of the bond
79
80 \return the new number of bonds
81 */
82 unsigned int addMacroBond(unsigned int beginAtomIdx, unsigned int endAtomIdx,
83 int beginAttachPt, int endAttachPt,
84 Bond::BondType bondType = Bond::SINGLE);
85
86 //! Adds a bond from a regular atom to a macro atom.
87 /*!
88 The graph bond's bond type is unspecified; use MacroBondInfo for the
89 macro bond type.
90
91 \param beginAtomIdx index of the regular atom where the bond begins
92 \param endMacroAtomIdx index of the macro atom where the bond ends
93 \param endAttachPt the attachment point on the end (macro) atom
94 \param bondType the type of the bond
95
96 \return the new number of bonds
97 */
99 unsigned int beginAtomIdx, unsigned int endMacroAtomIdx, int endAttachPt,
101
102 //! Adds a bond from a macro atom to a regular atom.
103 /*!
104 The graph bond's bond type is unspecified; use MacroBondInfo for the
105 macro bond type.
106
107 \param beginMacroAtomIdx index of the macro atom where the bond begins
108 \param endAtomIdx index of the regular atom where the bond ends
109 \param beginAttachPt the attachment point on the begin (macro) atom
110 \param bondType the type of the bond
111
112 \return the new number of bonds
113 */
115 unsigned int beginMacroAtomIdx, unsigned int endAtomIdx,
116 int beginAttachPt, Bond::BondType bondType = Bond::BondType::SINGLE);
117
118 //! Adds a bond between two regular atoms.
119 /*!
120 \b Note: neither atom may be a macro atom; use addMacroBond(),
121 addAtomToMacroAtomBond(), or addMacroAtomToAtomBond() for bonds involving
122 macro atoms.
123
124 \param beginAtomIdx index of the atom where the bond begins
125 \param endAtomIdx index of the atom where the bond ends
126 \param bondType the type of the bond
127
128 \return the new number of bonds
129 */
130 unsigned int addBond(unsigned int beginAtomIdx, unsigned int endAtomIdx,
131 Bond::BondType bondType = Bond::SINGLE);
132 //! \overload
133 unsigned int addBond(Atom *beginAtom, Atom *endAtom,
134 Bond::BondType bondType = Bond::SINGLE);
135 //! \overload
136 unsigned int addBond(Bond *bond, bool takeOwnership = false);
137
138 private:
139 unsigned int addMacroBondHelper(unsigned int beginAtomIdx,
140 unsigned int endAtomIdx, int beginAttachPt,
141 int endAttachPt,
142 Bond::BondType bondType = Bond::SINGLE);
143
144 std::unique_ptr<MacroMolTemplateLibrary> dp_localTemplateLibrary;
145};
146} // namespace RDKit
147
148#endif
Defines atom-level macro atom information.
Defines the editable molecule class RWMol.
The class for representing atoms.
Definition Atom.h:75
class for representing a bond
Definition Bond.h:48
BondType
the type of Bond
Definition Bond.h:57
@ SINGLE
Definition Bond.h:59
void setLocalTemplateLibrary(std::unique_ptr< MacroMolTemplateLibrary > newTemplateLibrary)
Replaces the local template library and takes ownership of it.
unsigned int addBond(Bond *bond, bool takeOwnership=false)
This is an overloaded member function, provided for convenience. It differs from the above function o...
unsigned int addAtomToMacroAtomBond(unsigned int beginAtomIdx, unsigned int endMacroAtomIdx, int endAttachPt, Bond::BondType bondType=Bond::BondType::SINGLE)
Adds a bond from a regular atom to a macro atom.
MacroMol(MacroMol &&other) noexcept=default
unsigned int addMacroAtom(std::string symbol, MonomerClass monomerClass)
Adds a new macro atom to the molecule.
const MacroMolTemplateLibrary & getLocalTemplateLibrary() const
Returns this molecule's local template library.
unsigned int addMacroAtomToAtomBond(unsigned int beginMacroAtomIdx, unsigned int endAtomIdx, int beginAttachPt, Bond::BondType bondType=Bond::BondType::SINGLE)
Adds a bond from a macro atom to a regular atom.
bool checkLocalTemplateReferences() const
Checks that every macro atom resolves in the local template library.
MacroMol & operator=(MacroMol &&other) noexcept=default
MacroMolTemplateLibrary & getLocalTemplateLibrary()
Returns this molecule's local template library.
MacroMol & operator=(const MacroMol &other)
unsigned int addBond(unsigned int beginAtomIdx, unsigned int endAtomIdx, Bond::BondType bondType=Bond::SINGLE)
Adds a bond between two regular atoms.
MacroMol(std::unique_ptr< MacroMolTemplateLibrary > localTemplateLibrary)
Constructs a MacroMol that takes ownership of a local template library.
unsigned int addMacroBond(unsigned int beginAtomIdx, unsigned int endAtomIdx, int beginAttachPt, int endAttachPt, Bond::BondType bondType=Bond::SINGLE)
Adds a bond between two macro atoms.
unsigned int addBond(Atom *beginAtom, Atom *endAtom, Bond::BondType bondType=Bond::SINGLE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
MacroMol()
Constructs a MacroMol with an empty local template library.
MacroMol(const MacroMol &other)
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:321
static const char * symbol[119]
Definition mf.h:257
Std stuff.
MonomerClass
Format-neutral classes of monomer that a macro atom can represent.