Chemical Data Processing Library C++ API - Version 1.4.0
ChEMBLStandardizer.hpp
Go to the documentation of this file.
1 /*
2  * ChEMBLStandardizer.hpp
3  *
4  * Implementation of the ChEMBL molecule standardization and parent compound extraction procedure
5  * (A. P. Bento et al., An open source chemical structure curation pipeline using RDKit, J. Cheminformatics 2020, 12, 51)
6  *
7  * This file is part of the Chemical Data Processing Toolkit
8  *
9  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this library; see the file COPYING. If not, write to
23  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  */
26 
32 #ifndef CDPL_CHEM_CHEMBLSTANDARDIZER_HPP
33 #define CDPL_CHEM_CHEMBLSTANDARDIZER_HPP
34 
35 #include <vector>
36 #include <cstdint>
37 #include <utility>
38 #include <unordered_set>
39 #include <memory>
40 
41 #include <boost/functional/hash.hpp>
42 
43 #include "CDPL/Chem/APIPrefix.hpp"
45 #include "CDPL/Chem/Fragment.hpp"
50 #include "CDPL/Util/BitSet.hpp"
52 
53 
54 namespace CDPL
55 {
56 
57  namespace Chem
58  {
59 
65  {
66 
67  public:
71  typedef std::shared_ptr<ChEMBLStandardizer> SharedPointer;
72 
77  {
78 
82  NONE = 0x0,
83 
87  EXCLUDED = 0x1,
88 
92  EXPLICIT_HYDROGENS_REMOVED = 0x2,
93 
97  UNKNOWN_STEREO_STANDARDIZED = 0x4,
98 
102  BONDS_KEKULIZED = 0x8,
103 
107  STRUCTURE_NORMALIZED = 0x10,
108 
112  CHARGES_REMOVED = 0x20,
113 
117  TARTRATE_STEREO_CLEARED = 0x40,
118 
122  STRUCTURE_2D_CORRECTED = 0x80,
123 
127  ISOTOPE_INFO_CLEARED = 0x100,
128 
132  SALT_COMPONENTS_REMOVED = 0x200,
133 
137  SOLVENT_COMPONENTS_REMOVED = 0x400,
138 
142  DUPLICATE_COMPONENTS_REMOVED = 0x800
143  };
144 
149 
155 
162  ChangeFlags standardize(Molecule& mol, bool proc_excld = false);
163 
171  ChangeFlags standardize(const MolecularGraph& molgraph, Molecule& std_mol, bool proc_excluded = false);
172 
180  ChangeFlags getParent(Molecule& mol, bool neutralize = true, bool check_exclusion = true);
181 
190  ChangeFlags getParent(const MolecularGraph& molgraph, Molecule& parent_mol, bool neutralize = true, bool check_exclusion = true);
191 
198 
199  private:
200  typedef std::vector<Atom*> AtomList;
201 
202  void copyMolecularGraph(const MolecularGraph& molgraph, Molecule& mol_copy) const;
203 
204  bool checkExclusionCriterions(const Molecule& mol) const;
205  bool checkExclusionCriterions(const MolecularGraph& molgraph, std::size_t& boron_cnt) const;
206 
207  bool standardizeUnknownStereochemistry(Molecule& mol) const;
208 
209  bool kekulizeBonds(Molecule& mol);
210 
211  bool removeExplicitHydrogens(Molecule& mol) const;
212  bool isRemovableHydrogen(const Atom& atom) const;
213 
214  bool normalizeStructure(Molecule& mol);
215  const Chem::Atom* getAtomWithMappingID(const Molecule& ptn, std::size_t id) const;
216 
217  bool removeCharges(Molecule& mol);
218 
219  bool removeTartrateStereochemistry(Molecule& mol);
220 
221  bool cleanup2DStructure(Molecule& mol);
222  double calc2DBondAngle(const Molecule& mol, const Atom& ctr_atom, const Atom& nbr_atom1, const Atom& nbr_atom2);
223  void rotateSubstituent(const Molecule& mol, const Atom& ctr_atom, const Atom& subst_atom, double rot_ang);
224 
225  void clearMatchConstraints(Molecule& mol) const;
226 
227  typedef std::pair<std::uint64_t, std::uint64_t> StructureID;
228  typedef std::pair<const Fragment*, StructureID> MoleculeComponent;
229  typedef std::vector<MoleculeComponent> MoleculeComponentList;
230  typedef std::unordered_set<StructureID, boost::hash<StructureID> > StructureIDSet;
231 
232  HashCodeCalculator hashCodeCalc;
233  KekuleStructureCalculator kekuleStructureCalc;
234  Util::STArray kekulizedBondOrders;
235  SubstructureSearch substructSearch;
236  ProtonationStateStandardizer chargeStandardizer;
237  Math::Vector2DArray atom2DCoords;
238  Util::BitSet markedAtomSet;
239  Fragment tmpFragment;
240  BasicMolecule tmpMolecule;
241  MoleculeComponentList molCompList1;
242  MoleculeComponentList molCompList2;
243  StructureIDSet uniqueMolComps;
244  };
245  } // namespace Chem
246 } // namespace CDPL
247 
248 #endif // CDPL_CHEM_CHEMBLSTANDARDIZER_HPP
Definition of class CDPL::Chem::BasicMolecule.
Declaration of type CDPL::Util::BitSet.
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::Fragment.
Definition of class CDPL::Chem::HashCodeCalculator.
Definition of class CDPL::Chem::KekuleStructureCalculator.
Definition of class CDPL::Chem::ProtonationStateStandardizer.
Definition of class CDPL::Chem::SubstructureSearch.
Definition of class CDPL::Math::VectorArray.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Concrete Chem::Molecule implementation that owns Chem::BasicAtom and Chem::BasicBond instances.
Definition: BasicMolecule.hpp:60
Implementation of the ChEMBL structure preprocessing pipeline.
Definition: ChEMBLStandardizer.hpp:65
ChangeFlags getParent(const MolecularGraph &molgraph, Molecule &parent_mol, bool neutralize=true, bool check_exclusion=true)
Extracts the parent compound of molgraph into parent_mol.
ChangeFlags standardize(Molecule &mol, bool proc_excld=false)
Standardizes mol in place.
ChangeFlags
Bitwise-OR-combined flags reporting which standardization steps modified the input molecule.
Definition: ChEMBLStandardizer.hpp:77
ChangeFlags standardize(const MolecularGraph &molgraph, Molecule &std_mol, bool proc_excluded=false)
Writes a standardized copy of molgraph to std_mol.
ChEMBLStandardizer()
Constructs the ChEMBLStandardizer instance.
std::shared_ptr< ChEMBLStandardizer > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated ChEMBLStandardizer instances.
Definition: ChEMBLStandardizer.hpp:71
ChEMBLStandardizer & operator=(const ChEMBLStandardizer &standardizer)
Replaces the state of this standardizer by a copy of the state of standardizer.
ChEMBLStandardizer(const ChEMBLStandardizer &standardizer)
Constructs a copy of the ChEMBLStandardizer instance standardizer.
ChangeFlags getParent(Molecule &mol, bool neutralize=true, bool check_exclusion=true)
Extracts the parent compound of mol in place (removing salt/solvent components).
Concrete Chem::MolecularGraph implementation that stores references to a selectable subset of atoms a...
Definition: Fragment.hpp:57
Computes a 64-bit hash code that identifies a molecular graph up to a configurable set of atom and bo...
Definition: HashCodeCalculator.hpp:67
Assigns an alternating single/double bond pattern (Kekulé structure) to the previously undefined bond...
Definition: KekuleStructureCalculator.hpp:55
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
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
Subgraph-isomorphism search of a query molecular graph against a target molecular graph,...
Definition: SubstructureSearch.hpp:74
constexpr unsigned int NONE
Represents an empty set of atom properties.
Definition: Biomol/AtomPropertyFlag.hpp:48
CDPL_CHEM_API void kekulizeBonds(MolecularGraph &molgraph)
Assigns Kekulé bond orders to the aromatic bonds of the molecular graph molgraph.
CDPL_CHEM_API void clearMatchConstraints(Atom &atom)
Clears the value of the Chem::AtomProperty::MATCH_CONSTRAINTS property of the atom atom.
VectorArray< Vector2D > Vector2DArray
Array storing vectors of type Math::Vector2D.
Definition: VectorArray.hpp:82
Array< std::size_t > STArray
Array storing unsigned integers of type std::size_t.
Definition: Array.hpp:578
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.