OpenMS  3.0.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-2022.
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:
61  static ResidueDB* getInstance();
62 
66  virtual ~ResidueDB();
69 
73  Size getNumberOfResidues() const;
75 
77  Size getNumberOfModifiedResidues() const;
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 
138  bool hasResidue(const String& name) const;
140 
142  bool hasResidue(const Residue* residue) const;
144 
145 protected:
147  void initResidues_();
148 
152  ResidueDB();
154 
156  ResidueDB(const ResidueDB& residue_db);
158 
162  ResidueDB& operator=(const ResidueDB& aa) = delete;
165 
166  // construct all residues
167  void buildResidues_();
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 
179  void addModifiedResidueNames_(const Residue*);
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::ResidueDB::residue_names_
std::unordered_map< String, const Residue * > residue_names_
lookup from name to residue
Definition: ResidueDB.h:192
OpenMS::ResidueDB
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:57
OpenMS::ResidueDB::const_residues_
std::set< const Residue * > const_residues_
all (unmodified) residues
Definition: ResidueDB.h:184
OpenMS::ResidueDB::residues_by_set_
std::map< String, std::set< const Residue * > > residues_by_set_
Definition: ResidueDB.h:197
OpenMS::ResidueModification
Representation of a modification on an amino acid residue.
Definition: ResidueModification.h:78
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
ResidueModification
sets the modification of AA at index by providing a pointer to a
OpenMS::ResidueDB::const_modified_residues_
std::set< const Residue * > const_modified_residues_
all modified residues
Definition: ResidueDB.h:187
OpenMS::ResidueDB::residue_sets_
std::set< String > residue_sets_
Definition: ResidueDB.h:189
Macros.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Residue
Representation of an amino acid residue.
Definition: Residue.h:62
OpenMS::ResidueDB::residue_mod_names_
std::map< String, std::map< String, const Residue * > > residue_mod_names_
Definition: ResidueDB.h:181
String.h