OpenMS
Loading...
Searching...
No Matches
OpenSearchModificationAnalysis.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: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14#include <map>
15#include <vector>
16#include <unordered_map>
17#include <unordered_set>
18
19namespace OpenMS
20{
29 {
30 public:
31
34 {
35 double count = 0.0;
36 std::vector<double> masses;
37 int num_charge_states = 0;
38 };
39
42 {
43 int count;
46 std::vector<double> masses;
47 };
48
51 {
52 double epsilon;
53 FuzzyDoubleComparator(double eps = 1e-9) : epsilon(eps) {}
54 bool operator()(const double& a, const double& b) const
55 {
56 return std::fabs(a - b) >= epsilon && a < b;
57 }
58 };
59
61 using DeltaMassHistogram = std::map<double, double, FuzzyDoubleComparator>;
62 using DeltaMassToChargeCount = std::map<double, int, FuzzyDoubleComparator>;
63
66
69
78 std::pair<DeltaMassHistogram, DeltaMassToChargeCount>
80 bool use_smoothing = false,
81 bool debug = false) const;
82
94 std::vector<ModificationSummary>
96 const DeltaMassToChargeCount& charge_histogram,
97 PeptideIdentificationList& peptide_ids,
98 double precursor_mass_tolerance = 5.0,
99 bool precursor_mass_tolerance_unit_ppm = true,
100 const String& output_file = "") const;
101
112 std::vector<ModificationSummary>
114 double precursor_mass_tolerance = 5.0,
115 bool precursor_mass_tolerance_unit_ppm = true,
116 bool use_smoothing = false,
117 const String& output_file = "") const;
118
119 private:
120
122 static double gaussian_(double x, double sigma);
123
126 double sigma = 0.001);
127
130 double count_threshold = 0.0,
131 double snr = 2.0);
132
134 void writeModificationSummary_(const std::vector<ModificationSummary>& modifications,
135 const String& output_file) const;
136 };
137
138} // namespace OpenMS
Utility class for analyzing modification patterns in open search results.
Definition OpenSearchModificationAnalysis.h:29
std::vector< ModificationSummary > mapDeltaMassesToModifications(const DeltaMassHistogram &delta_mass_histogram, const DeltaMassToChargeCount &charge_histogram, PeptideIdentificationList &peptide_ids, double precursor_mass_tolerance=5.0, bool precursor_mass_tolerance_unit_ppm=true, const String &output_file="") const
Map delta masses to known modifications and annotate peptides.
static DeltaMassHistogram smoothDeltaMassHistogram_(const DeltaMassHistogram &histogram, double sigma=0.001)
Smooth delta mass histogram using Gaussian kernel density estimation.
~OpenSearchModificationAnalysis()=default
Destructor.
int num_charge_states
Number of charge states.
Definition OpenSearchModificationAnalysis.h:45
void writeModificationSummary_(const std::vector< ModificationSummary > &modifications, const String &output_file) const
Write modification summary table to file.
std::vector< ModificationSummary > analyzeModifications(PeptideIdentificationList &peptide_ids, double precursor_mass_tolerance=5.0, bool precursor_mass_tolerance_unit_ppm=true, bool use_smoothing=false, const String &output_file="") const
Complete analysis workflow: analyze patterns and map to modifications.
std::map< double, int, FuzzyDoubleComparator > DeltaMassToChargeCount
Definition OpenSearchModificationAnalysis.h:62
std::vector< double > masses
Masses associated with the modification.
Definition OpenSearchModificationAnalysis.h:36
OpenSearchModificationAnalysis()=default
Default constructor.
String name
Modification name.
Definition OpenSearchModificationAnalysis.h:44
std::map< double, double, FuzzyDoubleComparator > DeltaMassHistogram
Type definitions for delta mass analysis.
Definition OpenSearchModificationAnalysis.h:61
static double gaussian_(double x, double sigma)
Gaussian function for smoothing.
std::pair< DeltaMassHistogram, DeltaMassToChargeCount > analyzeDeltaMassPatterns(const PeptideIdentificationList &peptide_ids, bool use_smoothing=false, bool debug=false) const
Analyze delta mass patterns from peptide identifications.
int count
Modification rate (number of occurrences)
Definition OpenSearchModificationAnalysis.h:43
static DeltaMassHistogram findPeaksInHistogram_(const DeltaMassHistogram &histogram, double count_threshold=0.0, double snr=2.0)
Find peaks in delta mass histogram based on count threshold and signal-to-noise ratio.
Stores details of a modification pattern found in the data.
Definition OpenSearchModificationAnalysis.h:34
Data structure for modification summary output.
Definition OpenSearchModificationAnalysis.h:42
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Comparator for approximate comparison of double values.
Definition OpenSearchModificationAnalysis.h:51
double epsilon
Definition OpenSearchModificationAnalysis.h:52
FuzzyDoubleComparator(double eps=1e-9)
Definition OpenSearchModificationAnalysis.h:53
bool operator()(const double &a, const double &b) const
Definition OpenSearchModificationAnalysis.h:54