OpenMS  2.4.0
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-2018.
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 #pragma once
36 
38 #include <boost/unordered_map.hpp>
40 
41 #include <set>
42 
43 namespace OpenMS
44 {
45  // forward declarations
46  class ResidueModification;
47  class Residue;
48 
60  class OPENMS_DLLAPI ResidueDB
61  {
62 public:
63 
67  typedef std::set<Residue*>::iterator ResidueIterator;
68  typedef std::set<const Residue*>::const_iterator ResidueConstIterator;
70 
72  inline static ResidueDB* getInstance()
73  {
74  static ResidueDB* db_ = nullptr;
75  if (db_ == nullptr)
76  {
77  db_ = new ResidueDB;
78  }
79  return db_;
80  }
81 
85  virtual ~ResidueDB();
88 
92  Size getNumberOfResidues() const;
94 
96  Size getNumberOfModifiedResidues() const;
97 
99  const Residue* getResidue(const String& name) const;
100 
102  const Residue* getResidue(const unsigned char& one_letter_code) const;
103 
110  const Residue* getModifiedResidue(const String& name);
111 
120  const Residue* getModifiedResidue(const Residue* residue, const String& name);
121 
138  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
139 
141  const std::set<String>& getResidueSets() const;
142 
144  void setResidues(const String& filename);
145 
147  void addResidue(const Residue& residue);
149 
153  bool hasResidue(const String& name) const;
155 
157  bool hasResidue(const Residue* residue) const;
159 
163  inline ResidueIterator beginResidue() { return residues_.begin(); }
164 
165  inline ResidueIterator endResidue() { return residues_.end(); }
166 
167  inline ResidueConstIterator beginResidue() const { return const_residues_.begin(); }
168 
169  inline ResidueConstIterator endResidue() const { return const_residues_.end(); }
171 
172 protected:
173 
177  ResidueDB();
179 
181  ResidueDB(const ResidueDB& residue_db);
183 
187  ResidueDB& operator=(const ResidueDB& aa);
190 
196  void readResiduesFromFile_(const String& filename);
197 
199  Residue* parseResidue_(Map<String, String>& values);
200 
202  void clear_();
203 
205  void clearResidues_();
206 
208  void buildResidueNames_();
209 
210  void addResidue_(Residue* residue);
211 
212  boost::unordered_map<String, Residue*> residue_names_;
213 
214  // fast lookup table for residues
215  Residue* residue_by_one_letter_code_[256];
216 
218 
219  std::set<Residue*> residues_;
220 
221  std::set<const Residue*> const_residues_;
222 
223  std::set<Residue*> modified_residues_;
224 
225  std::set<const Residue*> const_modified_residues_;
226 
228 
229  std::set<String> residue_sets_;
230  };
231 }
boost::unordered_map< String, Residue * > residue_names_
Definition: ResidueDB.h:212
A more convenient string class.
Definition: String.h:57
std::set< Residue * > residues_
Definition: ResidueDB.h:219
std::set< Residue * >::iterator ResidueIterator
Definition: ResidueDB.h:67
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
ResidueConstIterator beginResidue() const
Definition: ResidueDB.h:167
Representation of a residue.
Definition: Residue.h:61
static ResidueDB * getInstance()
this member function serves as a replacement of the constructor
Definition: ResidueDB.h:72
ResidueConstIterator endResidue() const
Definition: ResidueDB.h:169
Map< String, Map< String, Residue * > > residue_mod_names_
Definition: ResidueDB.h:217
Map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:227
std::set< const Residue * >::const_iterator ResidueConstIterator
Definition: ResidueDB.h:68
ResidueIterator endResidue()
Definition: ResidueDB.h:165
residue data base which holds residues
Definition: ResidueDB.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::set< String > residue_sets_
Definition: ResidueDB.h:229
std::set< Residue * > modified_residues_
Definition: ResidueDB.h:223
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:50
std::set< const Residue * > const_residues_
Definition: ResidueDB.h:221
ResidueIterator beginResidue()
Definition: ResidueDB.h:163
std::set< const Residue * > const_modified_residues_
Definition: ResidueDB.h:225