OpenMS  2.7.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-2021.
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, Jang Jang Jin$
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <boost/unordered_map.hpp>
39 #include <OpenMS/CONCEPT/Macros.h> // for OPENMS_PRECONDITION
40 
41 #include <map>
42 #include <set>
43 
44 namespace OpenMS
45 {
46  // forward declarations
47  class ResidueModification;
48  class Residue;
49 
56  class OPENMS_DLLAPI ResidueDB
57  {
58 public:
61 
66  virtual ~ResidueDB();
68 
74 
77 
79  const Residue* getResidue(const String& name) const;
80 
82  const Residue* getResidue(const unsigned char& one_letter_code) const;
83 
90  const Residue* getModifiedResidue(const String& name);
91 
100  const Residue* getModifiedResidue(const Residue* residue, const String& name);
101 
117  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
118 
120  const std::set<String> getResidueSets() const;
121 
123 
128  bool hasResidue(const String& name) const;
129 
131  bool hasResidue(const Residue* residue) const;
133 
134 protected:
137 
143 
145  ResidueDB(const ResidueDB& residue_db);
147 
152  ResidueDB& operator=(const ResidueDB& aa) = delete;
154 
155  // construct all residues
157 
159  void insertResidueAndAssociateWithResidueSet_(Residue* residue, const std::vector<String>& residue_sets);
160 
162  void addResidue_(Residue* residue);
163 
165  void addResidueNames_(const Residue*);
166 
169 
170  std::map<String, std::map<String, const Residue*> > residue_mod_names_;
171 
173  std::set<const Residue*> const_residues_;
174 
176  std::set<const Residue*> const_modified_residues_;
177 
178  std::set<String> residue_sets_;
179 
181  boost::unordered_map<String, const Residue*> residue_names_;
182 
184  std::array<const Residue*, 256> residue_by_one_letter_code_ = {{nullptr}};
185 
186  std::map<String, std::set<const Residue*> > residues_by_set_;
187  };
188 }
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:57
boost::unordered_map< String, const Residue * > residue_names_
lookup from name to residue
Definition: ResidueDB.h:181
const Residue * getModifiedResidue(const String &name)
Returns a pointer to a modified residue given a modification name.
void addResidue_(Residue *residue)
add residue and add names to lookup
void insertResidueAndAssociateWithResidueSet_(Residue *residue, const std::vector< String > &residue_sets)
creates and adds residues to a lookup table including the residue set
void initResidues_()
initializes all residues by building
static ResidueDB * getInstance()
singleton
void addModifiedResidueNames_(const Residue *)
adds names of single modified residue to the index
bool hasResidue(const Residue *residue) const
returns true if the db contains the residue of the given pointer
ResidueDB & operator=(const ResidueDB &aa)=delete
assignment operator
Size getNumberOfModifiedResidues() const
returns the number of modified residues stored
ResidueDB()
default constructor
virtual ~ResidueDB()
destructor
Size getNumberOfResidues() const
returns the number of residues stored
std::map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:186
const Residue * getResidue(const String &name) const
returns a pointer to the residue with name, 3 letter code or 1 letter code name
const std::set< const Residue * > getResidues(const String &residue_set="All") const
returns a set of all residues stored in this residue db
std::set< const Residue * > const_residues_
all (unmodified) residues
Definition: ResidueDB.h:173
std::set< const Residue * > const_modified_residues_
all modified residues
Definition: ResidueDB.h:176
const Residue * getResidue(const unsigned char &one_letter_code) const
returns a pointer to the residue with 1 letter code name
bool hasResidue(const String &name) const
returns true if the db contains a residue with the given name
std::map< String, std::map< String, const Residue * > > residue_mod_names_
Definition: ResidueDB.h:170
const std::set< String > getResidueSets() const
returns all residue sets that are registered which this instance
std::set< String > residue_sets_
Definition: ResidueDB.h:178
void addResidueNames_(const Residue *)
adds names of single residue to the index
const Residue * getModifiedResidue(const Residue *residue, const String &name)
Returns a pointer to a modified residue given a residue and a modification name.
ResidueDB(const ResidueDB &residue_db)
copy constructor
Representation of a residue.
Definition: Residue.h:63
A more convenient string class.
Definition: String.h:61
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47