Chemical Data Processing Library C++ API - Version 1.2.0
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 
75  Entry(const std::string& code, const std::string& rep_code, const std::string& rep_by_code, const std::string& parent_code,
76  const std::string& one_letter_code,bool obsolete, const std::string& name, unsigned int type,
77  const StructureRetrievalFunction& struc_ret_func);
78 
79  Entry();
80 
81  const std::string& getCode() const;
82 
83  const std::string& getReplacedCode() const;
84 
85  const std::string& getReplacedByCode() const;
86 
90  const std::string& getParentCode() const;
91 
95  const std::string& getOneLetterCode() const;
96 
97  bool isObsolete() const;
98 
99  const std::string& getName() const;
100 
101  unsigned int getType() const;
102 
104 
105  private:
106  std::string code;
107  std::string replacesCode;
108  std::string replacedByCode;
109  std::string parentCode;
110  std::string oneLetterCode;
111  bool obsolete;
112  std::string name;
113  unsigned int type;
114  StructureRetrievalFunction structRetrievalFunc;
115  };
116 
117  private:
118  struct CIStringHashFunc
119  {
120 
121  std::size_t operator()(const std::string& str) const;
122  };
123 
124  struct CIStringCmpFunc
125  {
126 
127  bool operator()(const std::string& str1, const std::string& str2) const;
128  };
129 
130  typedef std::unordered_map<std::string, Entry, CIStringHashFunc, CIStringCmpFunc> EntryLookupTable;
131 
132  public:
133  typedef std::shared_ptr<ResidueDictionary> SharedPointer;
134 
135  typedef boost::transform_iterator<std::function<const Entry&(const EntryLookupTable::value_type&)>,
136  EntryLookupTable::const_iterator> ConstEntryIterator;
137 
138  static bool isStdResidue(const std::string& code);
139 
140  void addEntry(const Entry& entry);
141 
145  void addEntry(Entry&& entry);
146 
147  bool containsEntry(const std::string& code) const;
148 
149  void removeEntry(const std::string& code);
150 
151  const Entry& getEntry(const std::string& code) const;
152 
153  void clear();
154 
155  std::size_t getNumEntries() const;
156 
158 
160 
162 
164 
165  const std::string& getReplacedCode(const std::string& code) const;
166 
167  const std::string& getReplacedByCode(const std::string& code) const;
168 
172  const std::string& getParentCode(const std::string& code) const;
173 
177  const std::string& getOneLetterCode(const std::string& code) const;
178 
179  bool isObsolete(const std::string& code) const;
180 
181  const std::string& getName(const std::string& code) const;
182 
183  unsigned int getType(const std::string& code) const;
184 
185  Chem::MolecularGraph::SharedPointer getStructure(const std::string& code) const;
186 
187  void loadDefaults();
188 
189  static void set(const SharedPointer& dict);
190 
191  static const SharedPointer& get();
192 
193  private:
194  static SharedPointer defaultDict;
195  EntryLookupTable entries;
196  };
197  } // namespace Biomol
198 } // namespace CDPL
199 
200 #endif // CDPL_BIOMOL_RESIDUEDICTIONARY_HPP
Definition of the preprocessor macro CDPL_BIOMOL_API.
#define CDPL_BIOMOL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Chem::MolecularGraph.
Definition: ResidueDictionary.hpp:58
const std::string & getOneLetterCode() const
const std::string & getName() const
const std::string & getReplacedByCode() const
const std::string & getReplacedCode() const
Chem::MolecularGraph::SharedPointer getStructure() const
Entry(const std::string &code, const std::string &rep_code, const std::string &rep_by_code, const std::string &parent_code, const std::string &one_letter_code, bool obsolete, const std::string &name, unsigned int type, const StructureRetrievalFunction &struc_ret_func)
Constructs and initializes a Entry instance with the given data.
const std::string & getParentCode() const
const std::string & getCode() const
std::function< Chem::MolecularGraph::SharedPointer(const std::string &)> StructureRetrievalFunction
Definition: ResidueDictionary.hpp:61
A global dictionary for the lookup of meta-data associated with the residues in biological macromolec...
Definition: ResidueDictionary.hpp:54
static void set(const SharedPointer &dict)
const std::string & getReplacedCode(const std::string &code) const
const std::string & getReplacedByCode(const std::string &code) const
std::shared_ptr< ResidueDictionary > SharedPointer
Definition: ResidueDictionary.hpp:133
ConstEntryIterator getEntriesBegin() const
boost::transform_iterator< std::function< const Entry &(const EntryLookupTable::value_type &)>, EntryLookupTable::const_iterator > ConstEntryIterator
Definition: ResidueDictionary.hpp:136
const std::string & getOneLetterCode(const std::string &code) const
Chem::MolecularGraph::SharedPointer getStructure(const std::string &code) const
void addEntry(const Entry &entry)
const std::string & getParentCode(const std::string &code) const
unsigned int getType(const std::string &code) const
const Entry & getEntry(const std::string &code) const
static bool isStdResidue(const std::string &code)
bool containsEntry(const std::string &code) const
const std::string & getName(const std::string &code) const
void removeEntry(const std::string &code)
void addEntry(Entry &&entry)
ConstEntryIterator begin() const
static const SharedPointer & get()
ConstEntryIterator getEntriesEnd() const
bool isObsolete(const std::string &code) const
ConstEntryIterator end() const
std::size_t getNumEntries() const
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
The namespace of the Chemical Data Processing Library.