| OpenMS 2.5.0

IDDecoyProbability.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-2020.
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$
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/METADATA/PeptideIdentification.h>
38 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
39 #include <OpenMS/MATH/STATISTICS/GammaDistributionFitter.h>
40 #include <OpenMS/MATH/STATISTICS/GaussFitter.h>
41
42 #include <vector>
43
44 namespace OpenMS
45 {
57 class OPENMS_DLLAPI IDDecoyProbability :
58 public DefaultParamHandler
59 {
60 public:
61
63 IDDecoyProbability();
64
66 IDDecoyProbability(const IDDecoyProbability & rhs);
67
69 ~IDDecoyProbability() override;
70
72 IDDecoyProbability & operator=(const IDDecoyProbability & rhs);
73
80 void apply(std::vector<PeptideIdentification> & prob_ids,
81 const std::vector<PeptideIdentification> & fwd_ids,
82 const std::vector<PeptideIdentification> & rev_ids);
83
84 void apply(std::vector<PeptideIdentification> & ids);
85
86 protected:
87
92 struct Transformation_
93 {
94 Transformation_() :
95 max_intensity(0),
96 diff_score(0),
97 min_score(0),
98 max_score(0),
99 max_intensity_bin(0)
100 {
101 }
102
103 Transformation_(const Transformation_ & rhs) :
104 max_intensity(rhs.max_intensity),
105 diff_score(rhs.diff_score),
106 min_score(rhs.min_score),
107 max_score(rhs.max_score),
108 max_intensity_bin(rhs.max_intensity_bin)
109 {
110 }
111
112 Transformation_ & operator=(const Transformation_ & rhs)
113 {
114 if (this != &rhs)
115 {
116 max_intensity = rhs.max_intensity;
117 diff_score = rhs.diff_score;
118 min_score = rhs.min_score;
119 max_score = rhs.max_score;
120 max_intensity_bin = rhs.max_intensity_bin;
121 }
122 return *this;
123 }
124
125 double max_intensity;
126 double diff_score;
127 double min_score;
128 double max_score;
129 Size max_intensity_bin;
130 };
131
132 // normalizes histograms
133 void normalizeBins_(const std::vector<double> & scores, std::vector<double> & binned, Transformation_ & trafo);
134
135 // returns the probability of given score with the transformations of reverse and forward searches and the results of the fits
136 double getProbability_(const Math::GammaDistributionFitter::GammaDistributionFitResult & result_gamma,
137 const Transformation_ & gamma_trafo,
138 const Math::GaussFitter::GaussFitResult & result_gauss,
139 const Transformation_ & gauss_trafo,
140 double score);
141
142
143 void generateDistributionImage_(const std::vector<double> & ids, const String & formula, const String & filename);
144
145 void generateDistributionImage_(const std::vector<double> & all_ids, const Transformation_ & all_trans, const String & fwd_formula, const String & rev_formula, const String & filename);
146
147
148 void apply_(std::vector<PeptideIdentification> & ids, const std::vector<double> & rev_scores, const std::vector<double> & fwd_scores, const std::vector<double> & all_scores);
149
150 };
151
152 } // namespace OpenMS
153
GammaDistributionFitter.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
GaussFitter.h
OpenMS::IDDecoyProbability::Transformation_::max_intensity
double max_intensity
Definition: IDDecoyProbability.h:125
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::IDDecoyProbability::Transformation_::operator=
Transformation_ & operator=(const Transformation_ &rhs)
Definition: IDDecoyProbability.h:112
OpenMS::IDDecoyProbability::Transformation_::max_score
double max_score
Definition: IDDecoyProbability.h:128
OpenMS::Math::GammaDistributionFitter::GammaDistributionFitResult
struct to represent the parameters of a gamma distribution
Definition: GammaDistributionFitter.h:65
OpenMS::IDDecoyProbability::Transformation_::Transformation_
Transformation_()
Definition: IDDecoyProbability.h:94
OpenMS::Math::GaussFitter::GaussFitResult
struct of parameters of a Gaussian distribution
Definition: GaussFitter.h:65
PeptideIdentification.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::IDDecoyProbability::Transformation_::Transformation_
Transformation_(const Transformation_ &rhs)
Definition: IDDecoyProbability.h:103
OpenMS::IDDecoyProbability
IDDecoyProbability calculates probabilities using decoy approach.
Definition: IDDecoyProbability.h:57
OpenMS::IDDecoyProbability::Transformation_::min_score
double min_score
Definition: IDDecoyProbability.h:127
DefaultParamHandler.h
OpenMS::IDDecoyProbability::Transformation_
struct to be used to store a transformation (used for fitting)
Definition: IDDecoyProbability.h:92
OpenMS::IDDecoyProbability::Transformation_::max_intensity_bin
Size max_intensity_bin
Definition: IDDecoyProbability.h:129
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::IDDecoyProbability::Transformation_::diff_score
double diff_score
Definition: IDDecoyProbability.h:126