RDKit
Open-source cheminformatics and machine learning.
Charge.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2021 Susan H. Leung 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 Charge.h
11
12 \brief Defines the Reionizer class and Uncharger class.
13
14*/
15#include <RDGeneral/export.h>
16#ifndef RD_CHARGE_H
17#define RD_CHARGE_H
18#include <utility>
19
20#include "MolStandardize.h"
21#include <Catalogs/Catalog.h>
24
25namespace RDKit {
26class RWMol;
27class ROMol;
28
29namespace MolStandardize {
30
31RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
33
34typedef RDCatalog::HierarchCatalog<AcidBaseCatalogEntry, AcidBaseCatalogParams,
35 int>
37
39 std::string Name;
40 std::string Smarts;
41 int Charge;
42
43 ChargeCorrection(std::string name, std::string smarts, int charge)
44 : Name(std::move(name)), Smarts(std::move(smarts)), Charge(charge) {}
45};
46
47// The default list of ChargeCorrections.
48RDKIT_MOLSTANDARDIZE_EXPORT extern std::vector<ChargeCorrection>
50
51//! The reionizer class to fix charges and reionize a molecule such that the
52/// strongest acids ionize first.
53/*!
54
55 <b>Notes:</b>
56 -
57*/
58
60 public:
62 //! construct a Reionizer with a particular acidbaseFile
63 Reionizer(const std::string acidbaseFile);
64 //! construct a Reionizer with parameter data
65 Reionizer(const std::vector<std::tuple<std::string, std::string, std::string>>
66 &data);
67 //! construct a Reionizer with a particular acidbaseFile and charge
68 /// corrections
69 Reionizer(const std::string acidbaseFile,
70 const std::vector<ChargeCorrection> ccs);
71 //! construct a Reionizer with a particular acidbaseFile and charge
72 /// corrections
73 Reionizer(std::istream &acidbaseStream,
74 const std::vector<ChargeCorrection> ccs);
75
76 //! construct a Reionizer with parameter data and charge corrections
77 Reionizer(const std::vector<std::tuple<std::string, std::string, std::string>>
78 &data,
79 const std::vector<ChargeCorrection> ccs);
80
81 //! making Reionizer objects non-copyable
82 Reionizer(const Reionizer &other) = delete;
83 Reionizer &operator=(Reionizer const &) = delete;
85
86 //! Enforce charges on certain atoms, then perform competitive reionization.
87 ROMol *reionize(const ROMol &mol);
88
89 private:
90 AcidBaseCatalog *d_abcat;
91 std::vector<ChargeCorrection> d_ccs;
92
93 std::pair<unsigned int, std::vector<unsigned int>> *strongestProtonated(
94 const ROMol &mol,
95 const std::vector<std::pair<ROMOL_SPTR, ROMOL_SPTR>> &abpairs);
96 std::pair<unsigned int, std::vector<unsigned int>> *weakestIonized(
97 const ROMol &mol,
98 const std::vector<std::pair<ROMOL_SPTR, ROMOL_SPTR>> &abpairs);
99
100}; // Reionizer class
101
102// caller owns the returned pointer
104 if (params.acidbaseData.empty()) {
105 return new Reionizer(params.acidbaseFile);
106 } else {
107 return new Reionizer(params.acidbaseData);
108 }
109}
110
111//! The Uncharger class for neutralizing ionized acids and bases.
112/*!
113
114 <b>Notes:</b>
115 - This class uncharges molecules by adding and/or removing hydrogens.
116 - For zwitterions, hydrogens are moved to eliminate charges where
117 possible.
118 - In cases where there is a positive charge that is not neutralizable,
119 an attempt is made to also preserve the corresponding
120 negative charge.
121
122*/
123
125 public:
127 Uncharger(bool canonicalOrdering) : Uncharger() {
128 df_canonicalOrdering = canonicalOrdering;
129 }
130 Uncharger(const Uncharger &other);
132
133 ROMol *uncharge(const ROMol &mol);
134
135 private:
136 bool df_canonicalOrdering = true;
137 std::shared_ptr<ROMol> pos_h;
138 std::shared_ptr<ROMol> pos_noh;
139 std::shared_ptr<ROMol> neg;
140 std::shared_ptr<ROMol> neg_acid;
141}; // Uncharger class
142
143} // namespace MolStandardize
144} // namespace RDKit
145#endif
A Catalog with a hierarchical structure.
Definition: Catalog.h:135
Reionizer(const std::string acidbaseFile, const std::vector< ChargeCorrection > ccs)
Reionizer & operator=(Reionizer const &)=delete
ROMol * reionize(const ROMol &mol)
Enforce charges on certain atoms, then perform competitive reionization.
Reionizer(const std::vector< std::tuple< std::string, std::string, std::string > > &data, const std::vector< ChargeCorrection > ccs)
construct a Reionizer with parameter data and charge corrections
Reionizer(std::istream &acidbaseStream, const std::vector< ChargeCorrection > ccs)
Reionizer(const std::vector< std::tuple< std::string, std::string, std::string > > &data)
construct a Reionizer with parameter data
Reionizer(const std::string acidbaseFile)
construct a Reionizer with a particular acidbaseFile
Reionizer(const Reionizer &other)=delete
making Reionizer objects non-copyable
The Uncharger class for neutralizing ionized acids and bases.
Definition: Charge.h:124
ROMol * uncharge(const ROMol &mol)
Uncharger(const Uncharger &other)
Uncharger(bool canonicalOrdering)
Definition: Charge.h:127
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition: export.h:313
RDKIT_MOLSTANDARDIZE_EXPORT std::vector< ChargeCorrection > CHARGE_CORRECTIONS
Reionizer * reionizerFromParams(const CleanupParameters &params)
Definition: Charge.h:103
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition: Fragment.h:25
RDCatalog::HierarchCatalog< AcidBaseCatalogEntry, AcidBaseCatalogParams, int > AcidBaseCatalog
Definition: Charge.h:36
Std stuff.
Definition: Abbreviations.h:18
ChargeCorrection(std::string name, std::string smarts, int charge)
Definition: Charge.h:43
std::vector< std::tuple< std::string, std::string, std::string > > acidbaseData