Chemical Data Processing Library C++ API - Version 1.4.0
ProtonationStateStandardizer.hpp
Go to the documentation of this file.
1 /*
2  * ProtonationStateStandardizer.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_PROTONATIONSTATESTANDARDIZER_HPP
30 #define CDPL_CHEM_PROTONATIONSTATESTANDARDIZER_HPP
31 
32 #include <cstddef>
33 #include <vector>
34 #include <unordered_set>
35 #include <memory>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
40 #include "CDPL/Util/BitSet.hpp"
41 #include "CDPL/Util/Array.hpp"
42 
43 
44 namespace CDPL
45 {
46 
47  namespace Chem
48  {
49 
50  class Molecule;
51  class ChEMBLStandardizer;
52 
58  {
59 
60  public:
62  typedef std::shared_ptr<ProtonationStateStandardizer> SharedPointer;
63 
67  enum Flavor
68  {
69 
75  MAX_CHARGE_COMPENSATION
76  };
77 
82 
88 
95  bool standardize(Molecule& mol, Flavor flavor);
96 
104  bool standardize(const Molecule& mol, Molecule& std_mol, Flavor flavor);
105 
112 
113  private:
114  friend class ChEMBLStandardizer;
115 
116  typedef std::vector<Chem::Atom*> AtomList;
117 
118  void copyMolecule(const Molecule& mol, Molecule& mol_copy) const;
119 
120  bool minChargedAtomCount(Molecule& mol);
121  bool protForPhysCond(Molecule& mol);
122  bool maxChargeComp(Molecule& mol);
123 
124  const Chem::Atom* getAtomWithMappingID(const Molecule& ptn, std::size_t id) const;
125 
126  std::size_t adaptHydrogenCount(Atom& atom, Molecule& mol, long h_delta) const;
127 
128  std::size_t calcFreeValence(const Atom& atom) const;
129 
130  long calcNetCharge(const Atom& atom) const;
131 
132  std::size_t calcValenceExcess(const Atom& atom) const;
133 
134  std::size_t getMatches(const Molecule& ptn, const Molecule& mol, AtomList& matches);
135 
136  bool incrementCharge(Atom& atom, bool checked) const;
137 
138  bool isRemovableHydrogen(const Atom& atom) const;
139 
140  bool cmpCanonicalNumber(const Atom* atom1, const Atom* atom2) const;
141 
142  bool removeConnectedHydrogens(const AtomList& atoms, Molecule& mol) const;
143 
144  typedef std::unordered_set<const Atom*> AtomSet;
145 
146  SubstructureSearch substructSearch;
147  CanonicalNumberingCalculator canonNumberingCalc;
148  AtomList atomList;
149  AtomList posChargedAtoms;
150  AtomList posChargedNoHAtoms;
151  AtomList negChargedAtoms;
152  AtomList negChargedAcidAtoms;
153  Util::STArray canonAtomNumbering;
154  Util::BitSet atomMask;
155  AtomSet atomSet;
156  };
157  } // namespace Chem
158 } // namespace CDPL
159 
160 #endif // CDPL_CHEM_PROTONATIONSTATESTANDARDIZER_HPP
Definition of class CDPL::Util::Array.
Declaration of type CDPL::Util::BitSet.
Definition of class CDPL::Chem::CanonicalNumberingCalculator.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Chem::SubstructureSearch.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Calculation of canonical atom numberings for molecular graphs using McKay's algorithm.
Definition: CanonicalNumberingCalculator.hpp:72
Implementation of the ChEMBL structure preprocessing pipeline.
Definition: ChEMBLStandardizer.hpp:65
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
Adjusts the protonation state of a molecule (atom formal charges and bonded hydrogen counts) accordin...
Definition: ProtonationStateStandardizer.hpp:58
Flavor
Selects the objective driving the protonation-state adjustment.
Definition: ProtonationStateStandardizer.hpp:68
@ MIN_CHARGED_ATOM_COUNT
Minimize the total number of formally charged atoms (neutralize where possible).
Definition: ProtonationStateStandardizer.hpp:71
@ PHYSIOLOGICAL_CONDITION_STATE
Set the protonation state expected under physiological conditions (pH ~7.4).
Definition: ProtonationStateStandardizer.hpp:73
bool standardize(const Molecule &mol, Molecule &std_mol, Flavor flavor)
Writes a standardized copy of mol to std_mol without modifying mol.
ProtonationStateStandardizer & operator=(const ProtonationStateStandardizer &standardizer)
Replaces the state of this standardizer by a copy of the state of standardizer.
ProtonationStateStandardizer(const ProtonationStateStandardizer &standardizer)
Constructs a copy of the ProtonationStateStandardizer instance standardizer.
bool standardize(Molecule &mol, Flavor flavor)
Adjusts the protonation state of mol in place according to the selected flavor.
std::shared_ptr< ProtonationStateStandardizer > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated ProtonationStateStandardizer inst...
Definition: ProtonationStateStandardizer.hpp:62
ProtonationStateStandardizer()
Constructs the ProtonationStateStandardizer instance.
Subgraph-isomorphism search of a query molecular graph against a target molecular graph,...
Definition: SubstructureSearch.hpp:74
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:575
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.