OpenMS
Loading...
Searching...
No Matches
ResidueDB.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
19namespace OpenMS
20{
21 // forward declarations
22 class ResidueModification;
23 class Residue;
24
39 class OPENMS_DLLAPI ResidueDB
40 {
41public:
43 static const ResidueDB* getInstance();
44
49 virtual ~ResidueDB();
51
57
60
62 const Residue* getResidue(const std::string& name) const;
63
65 const Residue* getResidue(const unsigned char& one_letter_code) const;
66
76 const Residue* getModifiedResidue(const std::string& name) const;
77
86 const Residue* getModifiedResidue(const Residue* residue, const std::string& name) const;
87
96 const Residue* getModifiedResidue(const Residue* residue, const ResidueModification* mod) const;
97
113 const std::set<const Residue*> getResidues(const std::string& residue_set = "All") const;
114
116 const std::set<std::string> getResidueSets() const;
117
119
124 bool hasResidue(const std::string& name) const;
125
127 bool hasResidue(const Residue* residue) const;
129
130protected:
133
139
141 ResidueDB(const ResidueDB& residue_db);
143
148 ResidueDB& operator=(const ResidueDB& aa) = delete;
150
151 // construct all residues
153
155 void insertResidueAndAssociateWithResidueSet_(Residue* residue, const std::vector<std::string>& residue_sets);
156
159 void addModifiedResidue_(Residue* residue) const;
160
163
166
168 mutable std::map<std::string, std::map<std::string, const Residue*> > residue_mod_names_;
169
171 std::set<const Residue*> const_residues_;
172
174 mutable std::set<const Residue*> const_modified_residues_;
175
176 std::set<std::string> residue_sets_;
177
179 std::unordered_map<std::string, const Residue*> residue_names_;
180
182 std::array<const Residue*, 256> residue_by_one_letter_code_ = {{nullptr}};
183
184 std::map<std::string, std::set<const Residue*> > residues_by_set_;
185 };
186}
OpenMS stores a central database of all residues in the ResidueDB. All (unmodified) residues are adde...
Definition ResidueDB.h:40
void insertResidueAndAssociateWithResidueSet_(Residue *residue, const std::vector< std::string > &residue_sets)
creates and adds residues to a lookup table including the residue set
ResidueDB & operator=(const ResidueDB &aa)=delete
assignment operator
void addModifiedResidueNames_(const Residue *) const
adds names of single modified residue to the index
const Residue * getResidue(const unsigned char &one_letter_code) const
returns a pointer to the residue with 1 letter code name
std::map< std::string, std::map< std::string, const Residue * > > residue_mod_names_
cache of name -> modification-name -> modified residue (lazily filled by getModifiedResidue)
Definition ResidueDB.h:168
const Residue * getModifiedResidue(const Residue *residue, const std::string &name) const
Returns a pointer to a modified residue given a residue and a modification name.
std::unordered_map< std::string, const Residue * > residue_names_
lookup from name to residue
Definition ResidueDB.h:179
void initResidues_()
initializes all residues by building
bool hasResidue(const Residue *residue) const
returns true if the db contains the residue of the given pointer
std::map< std::string, std::set< const Residue * > > residues_by_set_
Definition ResidueDB.h:184
const Residue * getResidue(const std::string &name) const
returns a pointer to the residue with name, 3 letter code or 1 letter code name
void addModifiedResidue_(Residue *residue) const
static const ResidueDB * getInstance()
singleton
Size getNumberOfModifiedResidues() const
returns the number of modified residues stored
const Residue * getModifiedResidue(const std::string &name) const
Returns a pointer to a modified residue given a modification name.
ResidueDB()
default constructor
const Residue * getModifiedResidue(const Residue *residue, const ResidueModification *mod) const
Returns a pointer to a modified residue given a residue and a pointer to a modification from the Modi...
virtual ~ResidueDB()
destructor
Size getNumberOfResidues() const
returns the number of residues stored
bool hasResidue(const std::string &name) const
returns true if the db contains a residue with the given name
const std::set< const Residue * > getResidues(const std::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:171
std::set< const Residue * > const_modified_residues_
all modified residues (lazily filled by getModifiedResidue)
Definition ResidueDB.h:174
const std::set< std::string > getResidueSets() const
returns all residue sets that are registered which this instance
std::set< std::string > residue_sets_
Definition ResidueDB.h:176
void addResidueNames_(const Residue *)
adds names of single residue to the index
ResidueDB(const ResidueDB &residue_db)
copy constructor
Representation of a modification on an amino acid residue.
Definition ResidueModification.h:55
Representation of an amino acid residue.
Definition Residue.h:41
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19