Chemical Data Processing Library C++ API - Version 1.1.1
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 
52  template <typename MatchFunc>
53  class AtomSSSRRingSizeMatchExpression : public MatchExpression<Atom, MolecularGraph>
54  {
55 
56  public:
60  typedef std::shared_ptr<AtomSSSRRingSizeMatchExpression> SharedPointer;
61 
67  AtomSSSRRingSizeMatchExpression(std::size_t ring_size):
68  ringSize(ring_size) {}
69 
86  bool operator()(const Atom& query_atom, const MolecularGraph& query_molgraph, const Atom& target_atom,
87  const MolecularGraph& target_molgraph, const Base::Any& aux_data) const;
88 
89  private:
90  std::size_t ringSize;
91  MatchFunc matchFunc;
92  };
93  } // namespace Chem
94 } // namespace CDPL
95 
96 
97 // Implementation
98 
99 template <typename MatchFunc>
101  const Atom& target_atom, const MolecularGraph& target_molgraph,
102  const Base::Any&) const
103 {
104  const FragmentList& sssr = *getSSSR(target_molgraph);
105 
106  for (FragmentList::ConstElementIterator it = sssr.getElementsBegin(), end = sssr.getElementsEnd(); it != end; ++it) {
107  const Fragment& ring = *it;
108 
109  if (!ring.containsAtom(target_atom))
110  continue;
111 
112  if (matchFunc(ring.getNumAtoms(), ringSize))
113  return true;
114  }
115 
116  return false;
117 }
118 
119 #endif // CDPL_CHEM_ATOMSSSRRINGSIZEMATCHEXPRESSION_HPP
CDPL::Chem::AtomSSSRRingSizeMatchExpression::SharedPointer
std::shared_ptr< AtomSSSRRingSizeMatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated AtomSSSRRingSizeMatchExpression i...
Definition: AtomSSSRRingSizeMatchExpression.hpp:60
MolecularGraphFunctions.hpp
Declaration of functions that operate on Chem::MolecularGraph instances.
CDPL::Util::IndirectArray::getElementsBegin
ConstElementIterator getElementsBegin() const
Returns a constant iterator over the pointed-to objects that points to the beginning of the array.
Definition: IndirectArray.hpp:448
CDPL::Chem::getSSSR
CDPL_CHEM_API const FragmentList::SharedPointer & getSSSR(const MolecularGraph &molgraph)
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::Fragment
Fragment.
Definition: Fragment.hpp:52
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Base::Any
A safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:59
CDPL::Util::IndirectArray::getElementsEnd
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::Util::Array< typename ValueType::SharedPointer >::ConstElementIterator
StorageType::const_iterator ConstElementIterator
A constant random access iterator used to iterate over the elements of the array.
Definition: Array.hpp:125
CDPL::Chem::AtomSSSRRingSizeMatchExpression::operator()
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:100
CDPL::Chem::FragmentList
A data type for the storage of Chem::Fragment objects.
Definition: FragmentList.hpp:49
CDPL::Chem::MatchExpression
A generic boolean expression interface for the implementation of query/target object equivalence test...
Definition: MatchExpression.hpp:75
MatchExpression.hpp
Definition of the class CDPL::Chem::MatchExpression.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::AtomSSSRRingSizeMatchExpression::AtomSSSRRingSizeMatchExpression
AtomSSSRRingSizeMatchExpression(std::size_t ring_size)
Constructs an AtomSSSRRingSizeMatchExpression instance for the specified query ring size.
Definition: AtomSSSRRingSizeMatchExpression.hpp:67
CDPL::Chem::Fragment::getNumAtoms
std::size_t getNumAtoms() const
Returns the number of atoms.
CDPL::Chem::Fragment::containsAtom
bool containsAtom(const Atom &atom) const
Tells whether the specified atom is part of this fragment.
CDPL::Chem::AtomSSSRRingSizeMatchExpression
AtomSSSRRingSizeMatchExpression.
Definition: AtomSSSRRingSizeMatchExpression.hpp:54