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