Chemical Data Processing Library C++ API - Version 1.1.1
ResidueDictionary.hpp
Go to the documentation of this file.
1 /*
2  * ResidueDictionary.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_RESIDUEDICTIONARY_HPP
30 #define CDPL_BIOMOL_RESIDUEDICTIONARY_HPP
31 
32 #include <string>
33 #include <unordered_map>
34 #include <memory>
35 #include <functional>
36 
37 #include <boost/iterator/transform_iterator.hpp>
38 
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Biomol
47  {
48 
54  {
55 
56  public:
58  {
59 
60  public:
61  typedef std::function<Chem::MolecularGraph::SharedPointer(const std::string&)> StructureRetrievalFunction;
62 
63  Entry(const std::string& code, const std::string& rep_code, const std::string& rep_by_code, bool obsolete,
64  const std::string& name, unsigned int type, const StructureRetrievalFunction& struc_ret_func);
65 
66  Entry();
67 
68  const std::string& getCode() const;
69 
70  const std::string& getReplacedCode() const;
71 
72  const std::string& getReplacedByCode() const;
73 
74  bool isObsolete() const;
75 
76  const std::string& getName() const;
77 
78  unsigned int getType() const;
79 
81 
82  private:
83  std::string code;
84  std::string replacesCode;
85  std::string replacedByCode;
86  bool obsolete;
87  std::string name;
88  unsigned int type;
89  StructureRetrievalFunction structRetrievalFunc;
90  };
91 
92  private:
93  typedef std::unordered_map<std::string, Entry> EntryLookupTable;
94 
95  public:
96  typedef std::shared_ptr<ResidueDictionary> SharedPointer;
97 
98  typedef boost::transform_iterator<std::function<const Entry&(const EntryLookupTable::value_type&)>,
99  EntryLookupTable::const_iterator>
101 
102  void addEntry(const Entry& entry);
103 
104  bool containsEntry(const std::string& code) const;
105 
106  void removeEntry(const std::string& code);
107 
108  const Entry& getEntry(const std::string& code) const;
109 
110  void clear();
111 
112  std::size_t getNumEntries() const;
113 
115 
117 
119 
121 
122  void loadDefaults();
123 
124  static void set(const SharedPointer& dict);
125 
126  static const SharedPointer& get();
127 
128  static const std::string& getReplacedCode(const std::string& code);
129 
130  static const std::string& getReplacedByCode(const std::string& code);
131 
132  static bool isObsolete(const std::string& code);
133 
134  static const std::string& getName(const std::string& code);
135 
136  static bool isStdResidue(const std::string& code);
137 
138  static unsigned int getType(const std::string& code);
139 
140  static Chem::MolecularGraph::SharedPointer getStructure(const std::string& code);
141 
142  private:
143  static SharedPointer defaultDict;
144  EntryLookupTable entries;
145  };
146  } // namespace Biomol
147 } // namespace CDPL
148 
149 #endif // CDPL_BIOMOL_RESIDUEDICTIONARY_HPP
CDPL::Chem::MolecularGraph::SharedPointer
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
CDPL::Biomol::ResidueDictionary::getEntriesEnd
ConstEntryIterator getEntriesEnd() const
CDPL::Biomol::ResidueDictionary::isObsolete
static bool isObsolete(const std::string &code)
CDPL::Biomol::ResidueDictionary::Entry::getReplacedByCode
const std::string & getReplacedByCode() const
CDPL::Biomol::ResidueDictionary::getReplacedCode
static const std::string & getReplacedCode(const std::string &code)
CDPL::Biomol::ResidueDictionary::isStdResidue
static bool isStdResidue(const std::string &code)
CDPL::Biomol::ResidueDictionary::set
static void set(const SharedPointer &dict)
CDPL::Biomol::ResidueDictionary::Entry::getName
const std::string & getName() const
CDPL::Biomol::ResidueDictionary::containsEntry
bool containsEntry(const std::string &code) const
CDPL::Biomol::ResidueDictionary::loadDefaults
void loadDefaults()
CDPL::Biomol::ResidueDictionary::Entry::getReplacedCode
const std::string & getReplacedCode() const
CDPL::Biomol::ResidueDictionary::Entry::Entry
Entry()
CDPL::Biomol::ResidueDictionary::getType
static unsigned int getType(const std::string &code)
CDPL::Biomol::ResidueDictionary::getStructure
static Chem::MolecularGraph::SharedPointer getStructure(const std::string &code)
CDPL::Biomol::ResidueDictionary::Entry::getType
unsigned int getType() const
CDPL::Biomol::ResidueDictionary::getReplacedByCode
static const std::string & getReplacedByCode(const std::string &code)
CDPL::Biomol::ResidueDictionary::Entry
Definition: ResidueDictionary.hpp:58
CDPL::Biomol::ResidueDictionary::removeEntry
void removeEntry(const std::string &code)
CDPL::Biomol::ResidueDictionary::getEntriesBegin
ConstEntryIterator getEntriesBegin() const
MolecularGraph.hpp
Definition of the class CDPL::Chem::MolecularGraph.
CDPL::Biomol::ResidueDictionary::Entry::Entry
Entry(const std::string &code, const std::string &rep_code, const std::string &rep_by_code, bool obsolete, const std::string &name, unsigned int type, const StructureRetrievalFunction &struc_ret_func)
CDPL::Biomol::ResidueDictionary::Entry::getCode
const std::string & getCode() const
CDPL::Biomol::ResidueDictionary::getNumEntries
std::size_t getNumEntries() const
CDPL::Biomol::ResidueDictionary
A global dictionary for the lookup of meta-data associated with the residues in biological macromolec...
Definition: ResidueDictionary.hpp:54
CDPL::Biomol::ResidueDictionary::Entry::getStructure
Chem::MolecularGraph::SharedPointer getStructure() const
CDPL::Biomol::ResidueDictionary::getEntry
const Entry & getEntry(const std::string &code) const
CDPL::Biomol::ResidueDictionary::getName
static const std::string & getName(const std::string &code)
CDPL::Biomol::ResidueDictionary::Entry::StructureRetrievalFunction
std::function< Chem::MolecularGraph::SharedPointer(const std::string &)> StructureRetrievalFunction
Definition: ResidueDictionary.hpp:61
APIPrefix.hpp
Definition of the preprocessor macro CDPL_BIOMOL_API.
CDPL::Biomol::ResidueDictionary::addEntry
void addEntry(const Entry &entry)
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Biomol::ResidueDictionary::Entry::isObsolete
bool isObsolete() const
CDPL::Biomol::ResidueDictionary::SharedPointer
std::shared_ptr< ResidueDictionary > SharedPointer
Definition: ResidueDictionary.hpp:96
CDPL::Biomol::ResidueDictionary::begin
ConstEntryIterator begin() const
CDPL::Biomol::ResidueDictionary::end
ConstEntryIterator end() const
CDPL::Biomol::ResidueDictionary::ConstEntryIterator
boost::transform_iterator< std::function< const Entry &(const EntryLookupTable::value_type &)>, EntryLookupTable::const_iterator > ConstEntryIterator
Definition: ResidueDictionary.hpp:100
CDPL_BIOMOL_API
#define CDPL_BIOMOL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Biomol::ResidueDictionary::get
static const SharedPointer & get()
CDPL::Biomol::ResidueDictionary::clear
void clear()