Chemical Data Processing Library C++ API - Version 1.1.1
Biomol/UtilityFunctions.hpp
Go to the documentation of this file.
1 /*
2  * UtilityFunctions.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_BIOMOL_UTILITYFUNCTIONS_HPP
30 #define CDPL_BIOMOL_UTILITYFUNCTIONS_HPP
31 
32 #include <algorithm>
33 #include <functional>
34 
39 #include "CDPL/Chem/Atom.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Biomol
46  {
47 
48  template <typename Iter>
49  Iter findResidueAtom(Iter it, Iter end, const char* res_code = 0, const char* chain_id = 0, long res_seq_no = IGNORE_SEQUENCE_NO,
50  char ins_code = 0, std::size_t model_no = 0, const char* atom_name = 0, long serial_no = IGNORE_SERIAL_NO)
51  {
52  return std::find_if(it, end,
53  std::bind(static_cast<bool (*)(const Chem::Atom&, const char*, const char*, long, char, std::size_t, const char*, long)>(&matchesResidueInfo), std::placeholders::_1, res_code, chain_id, res_seq_no,
54  ins_code, model_no, atom_name, serial_no));
55  }
56 
57  template <typename Iter>
58  Iter findResidue(Iter it, Iter end, const char* res_code = 0, const char* chain_id = 0, long res_seq_no = IGNORE_SEQUENCE_NO,
59  char ins_code = 0, std::size_t model_no = 0, const char* atom_name = 0, long serial_no = IGNORE_SERIAL_NO)
60  {
61  for (; it != end; ++it) {
62  const Chem::MolecularGraph& res = *it;
63 
64  if (!matchesResidueInfo(res, res_code, chain_id, res_seq_no, ins_code, model_no))
65  continue;
66 
67  if (atom_name == 0 && serial_no == IGNORE_SERIAL_NO)
68  return it;
69 
70  if (std::find_if(res.getAtomsBegin(), res.getAtomsEnd(),
71  std::bind(static_cast<bool (*)(const Chem::Atom&, const char*, const char*, long, char, std::size_t, const char*, long)>(&matchesResidueInfo), std::placeholders::_1, res_code, chain_id, res_seq_no,
72  ins_code, model_no, atom_name, serial_no)) != res.getAtomsEnd())
73  return it;
74  }
75 
76  return end;
77  }
78  } // namespace Biomol
79 } // namespace CDPL
80 
81 #endif // CDPL_BIOMOL_UTILITYFUNCTIONS_HPP
CDPL::Biomol::matchesResidueInfo
CDPL_BIOMOL_API bool matchesResidueInfo(const Chem::Atom &atom, const char *res_code=0, const char *chain_id=0, long res_seq_no=IGNORE_SEQUENCE_NO, char ins_code=0, std::size_t model_no=0, const char *atom_name=0, long serial_no=IGNORE_SERIAL_NO)
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
AtomFunctions.hpp
Declaration of functions that operate on Chem::Atom instances.
ProcessingFlags.hpp
Definition of flags for serial and residue sequence number processing.
CDPL::Chem::AtomContainer::getAtomsBegin
ConstAtomIterator getAtomsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::Atom objects.
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Biomol::findResidue
Iter findResidue(Iter it, Iter end, const char *res_code=0, const char *chain_id=0, long res_seq_no=IGNORE_SEQUENCE_NO, char ins_code=0, std::size_t model_no=0, const char *atom_name=0, long serial_no=IGNORE_SERIAL_NO)
Definition: Biomol/UtilityFunctions.hpp:58
CDPL::Biomol::IGNORE_SEQUENCE_NO
const long IGNORE_SEQUENCE_NO
Definition: ProcessingFlags.hpp:41
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
Atom.hpp
Definition of the class CDPL::Chem::Atom.
MolecularGraphFunctions.hpp
Declaration of functions that operate on Chem::MolecularGraph instances.
CDPL::Biomol::IGNORE_SERIAL_NO
const long IGNORE_SERIAL_NO
Definition: ProcessingFlags.hpp:42
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Biomol::findResidueAtom
Iter findResidueAtom(Iter it, Iter end, const char *res_code=0, const char *chain_id=0, long res_seq_no=IGNORE_SEQUENCE_NO, char ins_code=0, std::size_t model_no=0, const char *atom_name=0, long serial_no=IGNORE_SERIAL_NO)
Definition: Biomol/UtilityFunctions.hpp:49
CDPL::Chem::AtomContainer::getAtomsEnd
ConstAtomIterator getAtomsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::Atom objects.