OpenMS
ResidueDB.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Andreas Bertsch, Jang Jang Jin$
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <unordered_map>
13 #include <OpenMS/CONCEPT/Macros.h> // for OPENMS_PRECONDITION
14 
15 #include <map>
16 #include <set>
17 #include <array>
18 
19 namespace OpenMS
20 {
21  // forward declarations
22  class ResidueModification;
23  class Residue;
24 
31  class OPENMS_DLLAPI ResidueDB
32  {
33 public:
36 
41  virtual ~ResidueDB();
43 
49 
52 
54  const Residue* getResidue(const String& name) const;
55 
57  const Residue* getResidue(const unsigned char& one_letter_code) const;
58 
65  const Residue* getModifiedResidue(const String& name);
66 
75  const Residue* getModifiedResidue(const Residue* residue, const String& name);
76 
85  const Residue* getModifiedResidue(const Residue* residue, const ResidueModification* mod);
86 
102  const std::set<const Residue*> getResidues(const String& residue_set = "All") const;
103 
105  const std::set<String> getResidueSets() const;
106 
108 
113  bool hasResidue(const String& name) const;
114 
116  bool hasResidue(const Residue* residue) const;
118 
119 protected:
122 
128 
130  ResidueDB(const ResidueDB& residue_db);
132 
137  ResidueDB& operator=(const ResidueDB& aa) = delete;
139 
140  // construct all residues
142 
144  void insertResidueAndAssociateWithResidueSet_(Residue* residue, const std::vector<String>& residue_sets);
145 
147  void addResidue_(Residue* residue);
148 
150  void addResidueNames_(const Residue*);
151 
154 
155  std::map<String, std::map<String, const Residue*> > residue_mod_names_;
156 
158  std::set<const Residue*> const_residues_;
159 
161  std::set<const Residue*> const_modified_residues_;
162 
163  std::set<String> residue_sets_;
164 
166  std::unordered_map<String, const Residue*> residue_names_;
167 
169  std::array<const Residue*, 256> residue_by_one_letter_code_ = {{nullptr}};
170 
171  std::map<String, std::set<const Residue*> > residues_by_set_;
172  };
173 }
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition: ResidueDB.h:32
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:166
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:171
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:158
std::set< const Residue * > const_modified_residues_
all modified residues
Definition: ResidueDB.h:161
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:155
const std::set< String > getResidueSets() const
returns all residue sets that are registered which this instance
std::set< String > residue_sets_
Definition: ResidueDB.h:163
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 on an amino acid residue.
Definition: ResidueModification.h:53
Representation of an amino acid residue.
Definition: Residue.h:37
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
sets the modification of AA at index by providing a pointer to a in the