OpenMS
Loading...
Searching...
No Matches
ModificationsDB.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 $
7// --------------------------------------------------------------------------
8
9#pragma once
10
15
16#include <set>
17#include <memory> // unique_ptr
18#include <unordered_map>
19
20namespace OpenMS
21{
22 // forward declarations
23 class ResidueModification;
24 class Residue;
25
50 class OPENMS_DLLAPI ModificationsDB
51 {
52public:
53
59
61 static const ModificationsDB* initializeModificationsDB(std::string unimod_file = "CHEMISTRY/unimod.xml", std::string custommod_file = "CHEMISTRY/custom_mods.xml", std::string psimod_file = "CHEMISTRY/PSI-MOD.obo", std::string xlmod_file = "CHEMISTRY/XLMOD.obo");
62
64 static bool isInstantiated();
65
74 explicit ModificationsDB(std::vector<std::unique_ptr<ModificationDataProvider>> providers);
75
78
79 friend class CrossLinksDB;
80 // for access to addNewModification_ (without checking presence)
81 friend class Residue;
82 friend class AASequence;
83
86
92
101 void searchModifications(std::set<const ResidueModification*>& mods,
102 const std::string& mod_name,
103 const std::string& residue = "",
104 ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
105
116
131 const ResidueModification* searchModificationsFast(const std::string& mod_name,
132 bool& multiple_matches,
133 const std::string& residue = "",
134 ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
135
149 const ResidueModification* getModification(const std::string& mod_name, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
150
152 bool has(const std::string& modification) const;
153
161 const ResidueModification* addModification(std::unique_ptr<ResidueModification> new_mod) const;
162
171
180 Size findModificationIndex(const std::string& mod_name) const;
181
189 void searchModificationsByDiffMonoMass(std::vector<std::string>& mods, double mass, double max_error, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
190 void searchModificationsByDiffMonoMass(std::vector<const ResidueModification*>& mods, double mass, double max_error, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
191
199 void searchModificationsByDiffMonoMassSorted(std::vector<std::string>& mods, double mass, double max_error, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
200 void searchModificationsByDiffMonoMassSorted(std::vector<const ResidueModification*>& mods, double mass, double max_error, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
201
202
223 const ResidueModification* getBestModificationByDiffMonoMass(double mass, double max_error, const std::string& residue = "", ResidueModification::TermSpecificity term_spec = ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const;
224
226 void getAllSearchModifications(std::vector<std::string>& modifications) const;
227
229 void writeTSV(const std::string& filename) const;
230
231 protected:
232
234 static bool is_instantiated_;
235
237 mutable std::vector<ResidueModification*> mods_;
238
240 mutable std::unordered_map<std::string, std::set<const ResidueModification*> > modification_names_;
241
256 bool residuesMatch_(const char residue, const ResidueModification* curr_mod) const;
257
258private:
259
262
269
276
278 void loadFromProviders_(std::vector<std::unique_ptr<ModificationDataProvider>>& providers);
279 };
280}
Representation of a peptide/protein sequence.
Definition AASequence.h:88
Process-wide singleton database of cross-linking modifications.
Definition CrossLinksDB.h:59
database which holds all residue modifications from UniMod
Definition ModificationsDB.h:51
Size getNumberOfModifications() const
Returns the number of modifications read from the unimod.xml file.
bool residuesMatch_(const char residue, const ResidueModification *curr_mod) const
Helper function to check if a residue matches the origin for a modification.
void searchModificationsByDiffMonoMass(std::vector< std::string > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Collects all modifications with delta mass inside a tolerance window.
void searchModificationsByDiffMonoMass(std::vector< const ResidueModification * > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
const ResidueModification * searchModification(const ResidueModification &mod_in) const
Returns a pointer to an exact match of the given modification if present in the DB.
void writeTSV(const std::string &filename) const
Writes tab separated entries: FullId,FullName,Origin,AA,TerminusSpecificity,DiffMonoMass (including h...
const ResidueModification * addModification(std::unique_ptr< ResidueModification > new_mod) const
Add a new modification to ModificationsDB. If the modification already exists (based on its fullID) i...
std::vector< ResidueModification * > mods_
Stores the modifications (mutable: the singleton interns runtime-encountered mods through a const API...
Definition ModificationsDB.h:237
const ResidueModification * getModification(Size index) const
Returns the modification with the given index. note: out-of-bounds check is only performed in debug m...
void searchModifications(std::set< const ResidueModification * > &mods, const std::string &mod_name, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Collects all modifications which have the given name as synonym.
void searchModificationsByDiffMonoMassSorted(std::vector< std::string > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Collects all modifications with delta mass inside a tolerance window and adds them sorted by mass dif...
void loadFromProviders_(std::vector< std::unique_ptr< ModificationDataProvider > > &providers)
Loads and indexes modifications from the given providers.
ModificationsDB(std::vector< std::unique_ptr< ModificationDataProvider > > providers)
Construct from data providers (no file I/O performed by this constructor).
static const ModificationsDB * getInstance()
const ResidueModification * getModification(const std::string &mod_name, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Returns the modification with the given name.
void searchModificationsByDiffMonoMassSorted(std::vector< const ResidueModification * > &mods, double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
std::unordered_map< std::string, std::set< const ResidueModification * > > modification_names_
Stores the mappings of (unique) names to the modifications (mutable; see mods_)
Definition ModificationsDB.h:240
virtual ~ModificationsDB()
Destructor (public so non-singleton instances created via provider constructor can be destroyed)
static bool isInstantiated()
Check whether ModificationsDB was instantiated before.
const ResidueModification * searchModificationsFast(const std::string &mod_name, bool &multiple_matches, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Returns the modification which has the given name as synonym (fast version)
Size findModificationIndex(const std::string &mod_name) const
Returns the index of the modification in the mods_ vector; a unique name must be given.
static bool is_instantiated_
Stores whether ModificationsDB was instantiated before.
Definition ModificationsDB.h:234
ModificationsDB & operator=(const ModificationsDB &aa)
Assignment operator.
ModificationsDB(const ModificationsDB &residue_db)
Copy constructor (disabled)
static const ModificationsDB * initializeModificationsDB(std::string unimod_file="CHEMISTRY/unimod.xml", std::string custommod_file="CHEMISTRY/custom_mods.xml", std::string psimod_file="CHEMISTRY/PSI-MOD.obo", std::string xlmod_file="CHEMISTRY/XLMOD.obo")
Initializes the modification DB with non-default modification files (can only be done once)
bool has(const std::string &modification) const
Returns true if the modification exists.
const ResidueModification * addModification(const ResidueModification &new_mod) const
Add a new modification to ModificationsDB. If the modification already exists (based on its fullID) i...
const ResidueModification * getBestModificationByDiffMonoMass(double mass, double max_error, const std::string &residue="", ResidueModification::TermSpecificity term_spec=ResidueModification::NUMBER_OF_TERM_SPECIFICITY) const
Returns the best matching modification for the given delta mass and residue.
const ResidueModification * addNewModification_(const ResidueModification &new_mod) const
Add a new modification to ModificationsDB without checking if it was inside already.
void getAllSearchModifications(std::vector< std::string > &modifications) const
Collects all modifications that can be used for identification searches.
Representation of a modification on an amino acid residue.
Definition ResidueModification.h:55
TermSpecificity
Position where the modification is allowed to occur.
Definition ResidueModification.h:74
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