RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
MacroAtomInfo.h
Go to the documentation of this file.
1//
2// Copyright (C) 2026 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/*! \file MacroAtomInfo.h
11
12 \brief Defines atom-level macro atom information
13
14*/
15#ifndef RD_MACROATOMINFO_H
16#define RD_MACROATOMINFO_H
17
18#include <RDGeneral/export.h>
19
20#include <memory>
21#include <string>
22#include <utility>
23
24namespace RDKit {
25
26//! Format-neutral classes of monomer that a macro atom can represent.
27/*!
28 These are broad semantic categories, not the class vocabularies used by
29 SCSR, HELM, PDB, or another external format. Format parsers and writers are
30 responsible for mapping their own classifications to and from these values.
31 Such mappings may require additional format-specific context and should fail
32 rather than guess when the available information is ambiguous.
33
34 A regular enum is used here because MonomerClass appears in public MacroMol
35 method signatures. RDKit's BETTER_ENUM macro can expand to different C++
36 types depending on per-source-file preprocessor settings, which can cause
37 link errors in shared-library and unity builds.
38*/
39enum MonomerClass : int {
40 //! An amino-acid monomer, without encoding chirality, modification, or
41 //! crosslink status.
43 //! A nucleic-acid monomer, without distinguishing DNA, RNA, base, sugar, or
44 //! phosphate classifications.
46 //! A non-biopolymer chemical monomer.
48 //! A recognized monomer that does not belong to another neutral category.
50};
51
52//! Converts a monomer class to its canonical format-neutral RDKit name.
53/*!
54 The returned name is not a mapping to an external format's class vocabulary.
55*/
57 MonomerClass monomerClass);
58
59//! Converts a canonical format-neutral RDKit name to its monomer class.
60/*!
61 \throws ValueErrorException if monomerClass is not a canonical name. External
62 format adapters must validate and map their own class vocabulary
63 instead of passing arbitrary values to this function.
64*/
66monomerClassFromString(const std::string &monomerClass);
67
68//! Captures atom-level information for macro atoms.
69/*!
70 Macro atom information is owned by an Atom and stores the macro atom's
71 display symbol and monomer class.
72*/
74 public:
75 virtual ~MacroAtomInfo() = default;
76
77 MacroAtomInfo() = default;
78
79 //! Construct macro atom information.
80 /*!
81 \param symbol the symbol used to identify the monomer
82 \param monomerClass the class of monomer the macro atom represents
83 */
84 MacroAtomInfo(std::string symbol,
85 MonomerClass monomerClass = MonomerClass::Other)
86 : d_symbol(std::move(symbol)), d_monomerClass(monomerClass) {}
87 MacroAtomInfo(const MacroAtomInfo &other) = default;
88
89 //! Returns the macro atom symbol.
90 const std::string &getSymbol() const { return d_symbol; }
91
92 //! Sets the macro atom symbol.
93 /*!
94 \param symbol the symbol used to identify the monomer
95 */
96 void setSymbol(const std::string &symbol) { d_symbol = symbol; }
97
98 //! Returns the macro atom monomer class.
99 MonomerClass getMonomerClass() const { return d_monomerClass; }
100
101 //! Sets the macro atom monomer class.
102 /*!
103 \param monomerClass the class of monomer the macro atom represents
104 */
105 void setMonomerClass(MonomerClass monomerClass) {
106 d_monomerClass = monomerClass;
107 }
108
109 //! Returns a copy of this macro atom information.
110 virtual std::unique_ptr<MacroAtomInfo> copy() const {
111 return std::make_unique<MacroAtomInfo>(*this);
112 }
113
114 private:
115 std::string d_symbol{""};
116 MonomerClass d_monomerClass{MonomerClass::Other};
117};
118} // namespace RDKit
119
120#endif
virtual ~MacroAtomInfo()=default
const std::string & getSymbol() const
Returns the macro atom symbol.
MacroAtomInfo(const MacroAtomInfo &other)=default
MacroAtomInfo(std::string symbol, MonomerClass monomerClass=MonomerClass::Other)
Construct macro atom information.
void setSymbol(const std::string &symbol)
Sets the macro atom symbol.
virtual std::unique_ptr< MacroAtomInfo > copy() const
Returns a copy of this macro atom information.
MonomerClass getMonomerClass() const
Returns the macro atom monomer class.
void setMonomerClass(MonomerClass monomerClass)
Sets the macro atom monomer class.
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:321
static const char * symbol[119]
Definition mf.h:257
Std stuff.
RDKIT_GRAPHMOL_EXPORT const char * monomerClassToString(MonomerClass monomerClass)
Converts a monomer class to its canonical format-neutral RDKit name.
RDKIT_GRAPHMOL_EXPORT MonomerClass monomerClassFromString(const std::string &monomerClass)
Converts a canonical format-neutral RDKit name to its monomer class.
MonomerClass
Format-neutral classes of monomer that a macro atom can represent.
@ Other
A recognized monomer that does not belong to another neutral category.
@ NucleicAcid
@ Chemical
A non-biopolymer chemical monomer.