RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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 //! Enforce charges on certain atoms, then perform competitive reionization,
89 //! modifies molecule in place
91
92 private:
93 AcidBaseCatalog *d_abcat;
94 std::vector<ChargeCorrection> d_ccs;
95
96 std::pair<unsigned int, std::vector<unsigned int>> *strongestProtonated(
97 const ROMol &mol,
98 const std::vector<std::pair<ROMOL_SPTR, ROMOL_SPTR>> &abpairs);
99 std::pair<unsigned int, std::vector<unsigned int>> *weakestIonized(
100 const ROMol &mol,
101 const std::vector<std::pair<ROMOL_SPTR, ROMOL_SPTR>> &abpairs);
102
103}; // Reionizer class
104
105// caller owns the returned pointer
107 if (params.acidbaseData.empty()) {
108 return new Reionizer(params.acidbaseFile);
109 } else {
110 return new Reionizer(params.acidbaseData);
111 }
112}
113
114//! The Uncharger class for neutralizing ionized acids and bases.
115/*!
116
117 <b>Notes:</b>
118 - This class uncharges molecules by adding and/or removing hydrogens.
119 - For zwitterions, hydrogens are moved to eliminate charges where
120 possible.
121 - By default, in cases where there is a positive charge that is not
122 neutralizable, an attempt is made to also preserve the corresponding
123 negative charge.
124 - When the `force` option is set, all neutralizable sites are
125 uncharged, also when not-neutralizable positive charges are present
126 and the resulting overall charge is therefore not null.
127
128*/
129
131 public:
133 Uncharger(bool canonicalOrdering) : Uncharger() {
134 df_canonicalOrdering = canonicalOrdering;
135 }
136 Uncharger(bool canonicalOrdering, bool force) : Uncharger() {
137 df_canonicalOrdering = canonicalOrdering;
138 df_force = force;
139 }
140 Uncharger(const Uncharger &) = default;
141 ~Uncharger() = default;
142
143 ROMol *uncharge(const ROMol &mol);
145
146 private:
147 bool df_canonicalOrdering = true;
148 bool df_force = false;
149 std::shared_ptr<ROMol> pos_h;
150 std::shared_ptr<ROMol> pos_noh;
151 std::shared_ptr<ROMol> neg;
152 std::shared_ptr<ROMol> neg_acid;
153}; // Uncharger class
154
155} // namespace MolStandardize
156} // namespace RDKit
157#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:130
Uncharger(bool canonicalOrdering, bool force)
Definition Charge.h:136
ROMol * uncharge(const ROMol &mol)
Uncharger(const Uncharger &)=default
Uncharger(bool canonicalOrdering)
Definition Charge.h:133
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition export.h:337
RDKIT_MOLSTANDARDIZE_EXPORT std::vector< ChargeCorrection > CHARGE_CORRECTIONS
Reionizer * reionizerFromParams(const CleanupParameters &params)
Definition Charge.h:106
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition Fragment.h:25
RDCatalog::HierarchCatalog< AcidBaseCatalogEntry, AcidBaseCatalogParams, int > AcidBaseCatalog
Definition Charge.h:36
Std stuff.
ChargeCorrection(std::string name, std::string smarts, int charge)
Definition Charge.h:43
std::vector< std::tuple< std::string, std::string, std::string > > acidbaseData