Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ResidueDB.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_CHEMISTRY_RESIDUEDB_H
36 #define OPENMS_CHEMISTRY_RESIDUEDB_H
37 
39 #include <boost/unordered_map.hpp>
41 
42 #include <set>
43 
44 namespace OpenMS
45 {
46  // forward declarations
47  class ResidueModification;
48  class Residue;
49 
61  class OPENMS_DLLAPI ResidueDB
62  {
63 public:
64 
68  typedef std::set<Residue*>::iterator ResidueIterator;
69  typedef std::set<const Residue*>::const_iterator ResidueConstIterator;
71 
73  inline static ResidueDB* getInstance()
74  {
75  static ResidueDB* db_ = 0;
76  if (db_ == 0)
77  {
78  db_ = new ResidueDB;
79  }
80  return db_;
81  }
82 
86  virtual ~ResidueDB();
89 
93  Size getNumberOfResidues() const;
95 
97  Size getNumberOfModifiedResidues() const;
98 
100  const Residue* getResidue(const String& name) const;
101 
103  const Residue* getResidue(const unsigned char& one_letter_code) const;
104 
111  const Residue* getModifiedResidue(const String& name);
112 
121  const Residue* getModifiedResidue(const Residue* residue, const String& name);
122 
139  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
140 
142  const std::set<String>& getResidueSets() const;
143 
145  void setResidues(const String& filename);
146 
148  void addResidue(const Residue& residue);
150 
154  bool hasResidue(const String& name) const;
156 
158  bool hasResidue(const Residue* residue) const;
160 
164  inline ResidueIterator beginResidue() { return residues_.begin(); }
165 
166  inline ResidueIterator endResidue() { return residues_.end(); }
167 
168  inline ResidueConstIterator beginResidue() const { return const_residues_.begin(); }
169 
170  inline ResidueConstIterator endResidue() const { return const_residues_.end(); }
172 
173 protected:
174 
178  ResidueDB();
180 
182  ResidueDB(const ResidueDB& residue_db);
184 
188  ResidueDB& operator=(const ResidueDB& aa);
191 
197  void readResiduesFromFile_(const String& filename);
198 
200  Residue* parseResidue_(Map<String, String>& values);
201 
203  void clear_();
204 
206  void clearResidues_();
207 
209  void buildResidueNames_();
210 
211  void addResidue_(Residue* residue);
212 
213  boost::unordered_map<String, Residue*> residue_names_;
214 
215  // fast lookup table for residues
216  Residue* residue_by_one_letter_code_[256];
217 
219 
220  std::set<Residue*> residues_;
221 
222  std::set<const Residue*> const_residues_;
223 
224  std::set<Residue*> modified_residues_;
225 
226  std::set<const Residue*> const_modified_residues_;
227 
229 
230  std::set<String> residue_sets_;
231  };
232 }
233 #endif
boost::unordered_map< String, Residue * > residue_names_
Definition: ResidueDB.h:213
A more convenient string class.
Definition: String.h:57
std::set< Residue * > residues_
Definition: ResidueDB.h:220
std::set< Residue * >::iterator ResidueIterator
Definition: ResidueDB.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ResidueConstIterator beginResidue() const
Definition: ResidueDB.h:168
Representation of a residue.
Definition: Residue.h:62
static ResidueDB * getInstance()
this member function serves as a replacement of the constructor
Definition: ResidueDB.h:73
ResidueConstIterator endResidue() const
Definition: ResidueDB.h:170
Map< String, Map< String, Residue * > > residue_mod_names_
Definition: ResidueDB.h:218
Map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:228
std::set< const Residue * >::const_iterator ResidueConstIterator
Definition: ResidueDB.h:69
ResidueIterator endResidue()
Definition: ResidueDB.h:166
residue data base which holds residues
Definition: ResidueDB.h:61
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
std::set< String > residue_sets_
Definition: ResidueDB.h:230
std::set< Residue * > modified_residues_
Definition: ResidueDB.h:224
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
std::set< const Residue * > const_residues_
Definition: ResidueDB.h:222
ResidueIterator beginResidue()
Definition: ResidueDB.h:164
std::set< const Residue * > const_modified_residues_
Definition: ResidueDB.h:226

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13