OpenMS  2.8.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 <unordered_map>
39 #include <OpenMS/CONCEPT/Macros.h> // for OPENMS_PRECONDITION
40 
41 #include <map>
42 #include <set>
43 #include <array>
44 
45 namespace OpenMS
46 {
47  // forward declarations
48  class ResidueModification;
49  class Residue;
50 
57  class OPENMS_DLLAPI ResidueDB
58  {
59 public:
62 
67  virtual ~ResidueDB();
69 
75 
78 
80  const Residue* getResidue(const String& name) const;
81 
83  const Residue* getResidue(const unsigned char& one_letter_code) const;
84 
91  const Residue* getModifiedResidue(const String& name);
92 
101  const Residue* getModifiedResidue(const Residue* residue, const String& name);
102 
111  const Residue* getModifiedResidue(const Residue* residue, const ResidueModification* mod);
112 
128  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
129 
131  const std::set<String> getResidueSets() const;
132 
134 
139  bool hasResidue(const String& name) const;
140 
142  bool hasResidue(const Residue* residue) const;
144 
145 protected:
148 
154 
156  ResidueDB(const ResidueDB& residue_db);
158 
163  ResidueDB& operator=(const ResidueDB& aa) = delete;
165 
166  // construct all residues
168 
170  void insertResidueAndAssociateWithResidueSet_(Residue* residue, const std::vector<String>& residue_sets);
171 
173  void addResidue_(Residue* residue);
174 
176  void addResidueNames_(const Residue*);
177 
180 
181  std::map<String, std::map<String, const Residue*> > residue_mod_names_;
182 
184  std::set<const Residue*> const_residues_;
185 
187  std::set<const Residue*> const_modified_residues_;
188 
189  std::set<String> residue_sets_;
190 
192  std::unordered_map<String, const Residue*> residue_names_;
193 
195  std::array<const Residue*, 256> residue_by_one_letter_code_ = {{nullptr}};
196 
197  std::map<String, std::set<const Residue*> > residues_by_set_;
198  };
199 }
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:58
const Residue * getModifiedResidue(const String &name)
Returns a pointer to a modified residue given a modification name.
const Residue * getModifiedResidue(const Residue *residue, const ResidueModification *mod)
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
std::unordered_map< String, const Residue * > residue_names_
lookup from name to residue
Definition: ResidueDB.h:192
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:197
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:184
std::set< const Residue * > const_modified_residues_
all modified residues
Definition: ResidueDB.h:187
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:181
const std::set< String > getResidueSets() const
returns all residue sets that are registered which this instance
std::set< String > residue_sets_
Definition: ResidueDB.h:189
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 modification.
Definition: ResidueModification.h:77
Representation of a residue.
Definition: Residue.h:63
A more convenient string class.
Definition: String.h:60
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
sets the modification of AA at index by providing a pointer to a in the