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> 21 #include <GraphMol/MolStandardize/AcidBaseCatalog/AcidBaseCatalogEntry.h> 22 #include <GraphMol/MolStandardize/AcidBaseCatalog/AcidBaseCatalogParams.h> 23 24 namespace RDKit { 25 class RWMol; 26 class ROMol; 27 28 namespace MolStandardize { 29 30 RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters 31 defaultCleanupParameters; 32 33 typedef RDCatalog::HierarchCatalog<AcidBaseCatalogEntry, AcidBaseCatalogParams, 34 int> 35 AcidBaseCatalog; 36 37 struct RDKIT_MOLSTANDARDIZE_EXPORT ChargeCorrection { 38 std::string Name; 39 std::string Smarts; 40 int Charge; 41 ChargeCorrectionChargeCorrection42 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> 48 CHARGE_CORRECTIONS; 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 58 class RDKIT_MOLSTANDARDIZE_EXPORT Reionizer { 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 105 class RDKIT_MOLSTANDARDIZE_EXPORT Uncharger { 106 public: 107 Uncharger(); Uncharger(bool canonicalOrdering)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 127