|
| 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 | + |
| 24 | +namespace RDKit { |
| 25 | + |
| 26 | +//! Classes of monomer that a macro atom can represent. |
| 27 | +/*! |
| 28 | + Supported monomer classes for macro atoms. |
| 29 | +
|
| 30 | + A regular enum is used here because MonomerClass appears in public MacroMol |
| 31 | + method signatures. RDKit's BETTER_ENUM macro can expand to different C++ |
| 32 | + types depending on per-source-file preprocessor settings, which can cause |
| 33 | + link errors in shared-library and unity builds. |
| 34 | +*/ |
| 35 | +enum MonomerClass : int { |
| 36 | + AminoAcid, |
| 37 | + NucleicAcid, |
| 38 | + Chemical, |
| 39 | + Other |
| 40 | +}; |
| 41 | + |
| 42 | +//! Converts a macro atom monomer class enum value to its recognized name. |
| 43 | +RDKIT_GRAPHMOL_EXPORT const char *monomerClassToString( |
| 44 | + MonomerClass monomerClass); |
| 45 | + |
| 46 | +//! Converts a recognized macro atom monomer class name to its enum value. |
| 47 | +RDKIT_GRAPHMOL_EXPORT MonomerClass |
| 48 | +monomerClassFromString(const std::string &monomerClass); |
| 49 | + |
| 50 | +//! Captures atom-level information for macro atoms. |
| 51 | +/*! |
| 52 | + Macro atom information is owned by an Atom and stores the macro atom's |
| 53 | + display symbol and monomer class. |
| 54 | +*/ |
| 55 | +class RDKIT_GRAPHMOL_EXPORT MacroAtomInfo { |
| 56 | + public: |
| 57 | + virtual ~MacroAtomInfo() = default; |
| 58 | + |
| 59 | + MacroAtomInfo() = default; |
| 60 | + |
| 61 | + //! Construct macro atom information. |
| 62 | + /*! |
| 63 | + \param symbol the symbol used to identify the monomer |
| 64 | + \param monomerClass the class of monomer the macro atom represents |
| 65 | + */ |
| 66 | + MacroAtomInfo(std::string symbol, |
| 67 | + MonomerClass monomerClass = MonomerClass::Other) |
| 68 | + : d_symbol(std::move(symbol)), d_monomerClass(monomerClass) {} |
| 69 | + MacroAtomInfo(const MacroAtomInfo &other) = default; |
| 70 | + |
| 71 | + //! Returns the macro atom symbol. |
| 72 | + const std::string &getSymbol() const { return d_symbol; } |
| 73 | + |
| 74 | + //! Sets the macro atom symbol. |
| 75 | + /*! |
| 76 | + \param symbol the symbol used to identify the monomer |
| 77 | + */ |
| 78 | + void setSymbol(const std::string &symbol) { d_symbol = symbol; } |
| 79 | + |
| 80 | + //! Returns the macro atom monomer class. |
| 81 | + MonomerClass getMonomerClass() const { return d_monomerClass; } |
| 82 | + |
| 83 | + //! Sets the macro atom monomer class. |
| 84 | + /*! |
| 85 | + \param monomerClass the class of monomer the macro atom represents |
| 86 | + */ |
| 87 | + void setMonomerClass(MonomerClass monomerClass) { |
| 88 | + d_monomerClass = monomerClass; |
| 89 | + } |
| 90 | + |
| 91 | + //! Returns a copy of this macro atom information. |
| 92 | + virtual std::unique_ptr<MacroAtomInfo> copy() const { |
| 93 | + return std::make_unique<MacroAtomInfo>(*this); |
| 94 | + } |
| 95 | + |
| 96 | + private: |
| 97 | + std::string d_symbol{""}; |
| 98 | + MonomerClass d_monomerClass{MonomerClass::Other}; |
| 99 | +}; |
| 100 | +} // namespace RDKit |
| 101 | + |
| 102 | +#endif |
0 commit comments