OpenMS  2.6.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-2020.
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  static ResidueDB* getInstance();
73 
77  virtual ~ResidueDB();
80 
84  Size getNumberOfResidues() const;
86 
88  Size getNumberOfModifiedResidues() const;
89 
91  const Residue* getResidue(const String& name) const;
92 
94  const Residue* getResidue(const unsigned char& one_letter_code) const;
95 
102  const Residue* getModifiedResidue(const String& name);
103 
112  const Residue* getModifiedResidue(const Residue* residue, const String& name);
113 
130  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
131 
133  const std::set<String> getResidueSets() const;
134 
136 
140  bool hasResidue(const String& name) const;
142 
144  bool hasResidue(const Residue* residue) const;
146 
150  inline ResidueIterator beginResidue() { return residues_.begin(); }
151 
152  inline ResidueIterator endResidue() { return residues_.end(); }
153 
154  inline ResidueConstIterator beginResidue() const { return const_residues_.begin(); }
155 
156  inline ResidueConstIterator endResidue() const { return const_residues_.end(); }
158 
159 protected:
161  void setResidues_(const String& filename);
162 
166  ResidueDB();
168 
170  ResidueDB(const ResidueDB& residue_db);
172 
176  ResidueDB& operator=(const ResidueDB& aa);
179 
185  void readResiduesFromFile_(const String& filename);
186 
188  Residue* parseResidue_(Map<String, String>& values);
189 
191  void clear_();
192 
194  void clearResidues_();
195 
197  void clearResidueModifications_();
198 
200  void buildResidueNames_();
201 
202  void addResidue_(Residue* residue);
203 
204  boost::unordered_map<String, Residue*> residue_names_;
205 
206  // fast lookup table for residues
207  Residue* residue_by_one_letter_code_[256];
208 
210 
211  std::set<Residue*> residues_;
212 
213  std::set<const Residue*> const_residues_;
214 
215  std::set<Residue*> modified_residues_;
216 
217  std::set<const Residue*> const_modified_residues_;
218 
220 
221  std::set<String> residue_sets_;
222  };
223 }
OpenMS::ResidueDB
residue data base which holds residues
Definition: ResidueDB.h:60
OpenMS::ResidueDB::const_residues_
std::set< const Residue * > const_residues_
Definition: ResidueDB.h:213
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::ResidueDB::const_modified_residues_
std::set< const Residue * > const_modified_residues_
Definition: ResidueDB.h:217
OpenMS::ResidueDB::residue_sets_
std::set< String > residue_sets_
Definition: ResidueDB.h:221
Map.h
OpenMS::ResidueDB::residue_mod_names_
Map< String, Map< String, Residue * > > residue_mod_names_
Definition: ResidueDB.h:209
OpenMS::ResidueDB::beginResidue
ResidueConstIterator beginResidue() const
Definition: ResidueDB.h:154
OpenMS::ResidueDB::ResidueIterator
std::set< Residue * >::iterator ResidueIterator
Definition: ResidueDB.h:67
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Residue
Representation of a residue.
Definition: Residue.h:62
OpenMS::ResidueDB::residues_by_set_
Map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:219
OpenMS::ResidueDB::residues_
std::set< Residue * > residues_
Definition: ResidueDB.h:211
OpenMS::ResidueDB::ResidueConstIterator
std::set< const Residue * >::const_iterator ResidueConstIterator
Definition: ResidueDB.h:68
OpenMS::ResidueDB::endResidue
ResidueIterator endResidue()
Definition: ResidueDB.h:152
String.h
OpenMS::Map
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:50
OpenMS::ResidueDB::beginResidue
ResidueIterator beginResidue()
Definition: ResidueDB.h:150
OpenMS::ResidueDB::endResidue
ResidueConstIterator endResidue() const
Definition: ResidueDB.h:156
OpenMS::ResidueDB::modified_residues_
std::set< Residue * > modified_residues_
Definition: ResidueDB.h:215
OpenMS::ResidueDB::residue_names_
boost::unordered_map< String, Residue * > residue_names_
Definition: ResidueDB.h:204