Chemical Data Processing Library C++ API - Version 1.4.0
RMSDConformerSelector.hpp
Go to the documentation of this file.
1 /*
2  * RMSDConformerSelector.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_CONFGEN_RMSDCONFORMERSELECTOR_HPP
30 #define CDPL_CONFGEN_RMSDCONFORMERSELECTOR_HPP
31 
32 #include <vector>
33 #include <cstddef>
34 #include <unordered_map>
35 
38 #include "CDPL/Chem/Fragment.hpp"
41 #include "CDPL/Util/BitSet.hpp"
43 #include "CDPL/Util/ObjectPool.hpp"
46 
47 
48 namespace CDPL
49 {
50 
51  namespace ConfGen
52  {
53 
62  {
63 
64  public:
66  static constexpr std::size_t DEF_MAX_NUM_SYMMETRY_MAPPINGS = 32768;
67 
72 
74 
76 
81  void setMinRMSD(double min_rmsd);
82 
87  double getMinRMSD() const;
88 
94 
100 
105  std::size_t getNumSymmetryMappings() const;
106 
111  void setMaxNumSymmetryMappings(std::size_t max_num);
112 
117  std::size_t getMaxNumSymmetryMappings() const;
118 
124  void setup(const Chem::MolecularGraph& molgraph, const Util::BitSet& atom_mask);
125 
135  void setup(const Chem::MolecularGraph& molgraph, const Util::BitSet& atom_mask,
136  const Util::BitSet& stable_config_atom_mask, const Math::Vector3DArray& coords);
137 
143  bool selected(const Math::Vector3DArray& conf_coords);
144 
145  private:
146  typedef std::vector<std::size_t> IndexArray;
148  typedef VectorArrayCache::SharedObjectPointer VectorArrayPtr;
149 
150  void buildSymMappingSearchMolGraph(const Util::BitSet& atom_mask);
151  void setupSymMappingValidationData(const Util::BitSet& stable_config_atom_mask,
152  const Math::Vector3DArray& conf_coords);
153 
154  bool processSymMapping(const Chem::MolecularGraph& molgraph,
155  const Chem::AtomBondMapping& mapping);
156  bool isValidSymMapping(const Chem::AtomBondMapping& mapping) const;
157 
158  VectorArrayPtr buildCoordsArrayForMapping(const IndexArray& mapping,
159  const Math::Vector3DArray& conf_coords);
160 
161  typedef std::unordered_map<const Chem::Atom*, Chem::StereoDescriptor> AtomStereoDescriptorMap;
162  typedef std::vector<const Chem::Atom*> AtomList;
164  typedef std::vector<IndexArray*> IndexArrayList;
165  typedef std::vector<VectorArrayPtr> VectorArrayList;
167 
168  IndexArrayCache idxArrayCache;
169  VectorArrayCache vecArrayCache;
170  const Chem::MolecularGraph* molGraph;
171  Chem::AutomorphismGroupSearch symMappingSearch;
172  Chem::Fragment symMappingSearchMolGraph;
173  IndexArrayList symMappings;
174  AtomStereoDescriptorMap atomStereoDescrs;
175  AlignmentCalculator alignmentCalc;
176  VectorArrayList confAlignCoords;
177  VectorArrayList selectedConfAlignCoords;
178  AtomList atomNeighbors;
179  double minRMSD;
180  std::size_t maxNumSymMappings;
181  CallbackFunction abortCallback;
182  };
183  } // namespace ConfGen
184 } // namespace CDPL
185 
186 #endif // CDPL_CONFGEN_RMSDCONFORMERSELECTOR_HPP
Definition of class CDPL::Chem::AutomorphismGroupSearch.
Declaration of type CDPL::Util::BitSet.
Type definition of a generic wrapper class for storing user-defined callback functions.
Definition of the preprocessor macro CDPL_CONFGEN_API.
#define CDPL_CONFGEN_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::Util::ObjectPool.
Definition of class CDPL::Util::ObjectStack.
Definition of the type CDPL::Chem::StereoDescriptor.
Implementation of the Kabsch algorithm.
Definition of class CDPL::Math::VectorArray.
Data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
Enumerates the atom/bond automorphisms of a molecular graph.
Definition: AutomorphismGroupSearch.hpp:58
Concrete Chem::MolecularGraph implementation that stores references to a selectable subset of atoms a...
Definition: Fragment.hpp:57
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Greedy RMSD-based conformer-diversity filter.
Definition: RMSDConformerSelector.hpp:62
RMSDConformerSelector & operator=(const RMSDConformerSelector &)=delete
double getMinRMSD() const
Returns the currently configured minimum RMSD threshold.
void setMinRMSD(double min_rmsd)
Sets the minimum RMSD that a candidate conformer must keep from every already-selected conformer to b...
const CallbackFunction & getAbortCallback() const
Returns the currently configured abort-check callback.
void setMaxNumSymmetryMappings(std::size_t max_num)
Sets the maximum number of symmetry mappings to enumerate per setup() call.
RMSDConformerSelector(const RMSDConformerSelector &)=delete
std::size_t getMaxNumSymmetryMappings() const
Returns the currently configured maximum number of symmetry mappings.
void setAbortCallback(const CallbackFunction &func)
Sets the callback invoked periodically to allow the selection to be aborted by the user.
void setup(const Chem::MolecularGraph &molgraph, const Util::BitSet &atom_mask)
Sets up the selector for the subgraph of molgraph defined by atom_mask.
void setup(const Chem::MolecularGraph &molgraph, const Util::BitSet &atom_mask, const Util::BitSet &stable_config_atom_mask, const Math::Vector3DArray &coords)
Sets up the selector for the subgraph of molgraph defined by atom_mask while restricting the enumerat...
std::size_t getNumSymmetryMappings() const
Returns the number of symmetry (automorphism) mappings enumerated during the last setup() call.
RMSDConformerSelector()
Constructs the RMSDConformerSelector instance.
bool selected(const Math::Vector3DArray &conf_coords)
Tests whether conf_coords is sufficiently different from already-selected conformers and,...
std::shared_ptr< ObjectType > SharedObjectPointer
A smart pointer to a borrowed object that returns the object to the pool on destruction.
Definition: ObjectPool.hpp:71
std::function< bool()> CallbackFunction
Generic wrapper for storing user-defined callback functions returning a bool status flag (see [FUNWRP...
Definition: CallbackFunction.hpp:47
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:85
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.