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-2015.
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: Andreas Bertsch $
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 
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 
105  const Residue * getModifiedResidue(const String & name);
106 
108  const Residue * getModifiedResidue(const Residue * residue, const String & name);
109 
126  const std::set<const Residue *> getResidues(const String & residue_set = "All") const;
127 
129  const std::set<String> & getResidueSets() const;
130 
132  void setResidues(const String & filename);
133 
135  void addResidue(const Residue & residue);
137 
141  bool hasResidue(const String & name) const;
143 
145  bool hasResidue(const Residue * residue) const;
147 
151  inline ResidueIterator beginResidue() { return residues_.begin(); }
152 
153  inline ResidueIterator endResidue() { return residues_.end(); }
154 
155  inline ResidueConstIterator beginResidue() const { return const_residues_.begin(); }
156 
157  inline ResidueConstIterator endResidue() const { return const_residues_.end(); }
159 
160 protected:
161 
165  ResidueDB();
167 
169  ResidueDB(const ResidueDB & residue_db);
171 
175  ResidueDB & operator=(const ResidueDB & aa);
178 
180  void readResiduesFromFile_(const String & filename);
181 
183  Residue * parseResidue_(Map<String, String> & values);
184 
186  void clear_();
187 
189  void clearResidues_();
190 
192  void buildResidueNames_();
193 
194  void addResidue_(Residue * residue);
195 
196  boost::unordered_map<String, Residue *> residue_names_;
197 
198  // fast lookup table for residues
199  Residue * residue_by_one_letter_code_[256];
200 
202 
203  std::set<Residue *> residues_;
204 
205  std::set<const Residue *> const_residues_;
206 
207  std::set<Residue *> modified_residues_;
208 
209  std::set<const Residue *> const_modified_residues_;
210 
212 
213  std::set<String> residue_sets_;
214  };
215 }
216 #endif
ResidueConstIterator beginResidue() const
Definition: ResidueDB.h:155
A more convenient string class.
Definition: String.h:57
Map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:211
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Representation of a residue.
Definition: Residue.h:62
std::set< const Residue * > const_residues_
Definition: ResidueDB.h:205
Map< String, Map< String, Residue * > > residue_mod_names_
Definition: ResidueDB.h:201
static ResidueDB * getInstance()
this member function serves as a replacement of the constructor
Definition: ResidueDB.h:73
std::set< Residue * > residues_
Definition: ResidueDB.h:203
std::set< const Residue * >::const_iterator ResidueConstIterator
Definition: ResidueDB.h:69
ResidueIterator endResidue()
Definition: ResidueDB.h:153
std::set< const Residue * > const_modified_residues_
Definition: ResidueDB.h:209
std::set< Residue * >::iterator ResidueIterator
Definition: ResidueDB.h:68
boost::unordered_map< String, Residue * > residue_names_
Definition: ResidueDB.h:196
residue data base which holds residues
Definition: ResidueDB.h:61
std::set< String > residue_sets_
Definition: ResidueDB.h:213
ResidueConstIterator endResidue() const
Definition: ResidueDB.h:157
std::set< Residue * > modified_residues_
Definition: ResidueDB.h:207
Map class based on the STL map (containing several convenience functions)
Definition: Map.h:51
ResidueIterator beginResidue()
Definition: ResidueDB.h:151

OpenMS / TOPP release 2.0.0 Documentation generated on Tue Aug 25 2015 05:53:52 using doxygen 1.8.9.1