Chemical Data Processing Library C++ API - Version 1.4.0
AtomSSSRRingSizeMatchExpression.hpp
Go to the documentation of this file.
1 /*
2  * AtomSSSRRingSizeMatchExpression.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_ATOMSSSRRINGSIZEMATCHEXPRESSION_HPP
30 #define CDPL_CHEM_ATOMSSSRRINGSIZEMATCHEXPRESSION_HPP
31 
32 #include <memory>
33 
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Chem
42  {
43 
57  template <typename MatchFunc>
58  class AtomSSSRRingSizeMatchExpression : public MatchExpression<Atom, MolecularGraph>
59  {
60 
61  public:
65  typedef std::shared_ptr<AtomSSSRRingSizeMatchExpression> SharedPointer;
66 
72  AtomSSSRRingSizeMatchExpression(std::size_t ring_size):
73  ringSize(ring_size) {}
74 
91  bool operator()(const Atom& query_atom, const MolecularGraph& query_molgraph, const Atom& target_atom,
92  const MolecularGraph& target_molgraph, const Base::Any& aux_data) const;
93 
94  private:
95  std::size_t ringSize;
96  MatchFunc matchFunc;
97  };
98  } // namespace Chem
99 } // namespace CDPL
100 
101 
102 // Implementation
103 
104 template <typename MatchFunc>
106  const Atom& target_atom, const MolecularGraph& target_molgraph,
107  const Base::Any&) const
108 {
109  const FragmentList& sssr = *getSSSR(target_molgraph);
110 
111  for (FragmentList::ConstElementIterator it = sssr.getElementsBegin(), end = sssr.getElementsEnd(); it != end; ++it) {
112  const Fragment& ring = *it;
113 
114  if (!ring.containsAtom(target_atom))
115  continue;
116 
117  if (matchFunc(ring.getNumAtoms(), ringSize))
118  return true;
119  }
120 
121  return false;
122 }
123 
124 #endif // CDPL_CHEM_ATOMSSSRRINGSIZEMATCHEXPRESSION_HPP
Declaration of functions that operate on Chem::MolecularGraph instances.
Definition of class CDPL::Chem::MatchExpression.
Safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:60
Chem::MatchExpression that constrains target atoms by the size of the SSSR ring(s) containing them.
Definition: AtomSSSRRingSizeMatchExpression.hpp:59
AtomSSSRRingSizeMatchExpression(std::size_t ring_size)
Constructs an AtomSSSRRingSizeMatchExpression instance for the specified query ring size.
Definition: AtomSSSRRingSizeMatchExpression.hpp:72
std::shared_ptr< AtomSSSRRingSizeMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated AtomSSSRRingSizeMatchExpression i...
Definition: AtomSSSRRingSizeMatchExpression.hpp:65
bool operator()(const Atom &query_atom, const MolecularGraph &query_molgraph, const Atom &target_atom, const MolecularGraph &target_molgraph, const Base::Any &aux_data) const
Checks whether a ring in the SSSR of target_molgraph that contains target_atom matches the query ring...
Definition: AtomSSSRRingSizeMatchExpression.hpp:105
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Data type for the storage of Chem::Fragment objects.
Definition: FragmentList.hpp:49
Concrete Chem::MolecularGraph implementation that stores references to a selectable subset of atoms a...
Definition: Fragment.hpp:57
bool containsAtom(const Atom &atom) const
Tells whether the specified atom is part of this fragment.
std::size_t getNumAtoms() const
Returns the number of atoms.
Generic boolean expression interface for the implementation of query/target object equivalence tests ...
Definition: MatchExpression.hpp:75
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
StorageType::const_iterator ConstElementIterator
A constant random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:125
ConstElementIterator getElementsBegin() const
Returns a constant iterator over the pointed-to objects that points to the beginning of the array.
Definition: IndirectArray.hpp:448
ConstElementIterator getElementsEnd() const
Returns a constant iterator over the pointed-to objects that points to the end of the array.
Definition: IndirectArray.hpp:462
CDPL_CHEM_API const FragmentList::SharedPointer & getSSSR(const MolecularGraph &molgraph)
Returns the Chem::MolecularGraphProperty::SSSR property of molgraph.
The namespace of the Chemical Data Processing Library.