OpenMS  2.8.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-2021.
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 
41 
42 #include <vector>
43 
44 namespace OpenMS
45 {
57  class OPENMS_DLLAPI IDDecoyProbability :
58  public DefaultParamHandler
59  {
60 public:
61 
64 
67 
69  ~IDDecoyProbability() override;
70 
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 
93  {
95  max_intensity(0),
96  diff_score(0),
97  min_score(0),
98  max_score(0),
99  max_intensity_bin(0)
100  {
101  }
102 
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 
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 
126  double diff_score;
127  double min_score;
128  double max_score;
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
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 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
IDDecoyProbability calculates probabilities using decoy approach.
Definition: IDDecoyProbability.h:59
IDDecoyProbability()
Default constructor.
void generateDistributionImage_(const std::vector< double > &all_ids, const Transformation_ &all_trans, const String &fwd_formula, const String &rev_formula, const String &filename)
IDDecoyProbability(const IDDecoyProbability &rhs)
Copy constructor.
void apply(std::vector< PeptideIdentification > &ids)
void apply_(std::vector< PeptideIdentification > &ids, const std::vector< double > &rev_scores, const std::vector< double > &fwd_scores, const std::vector< double > &all_scores)
void normalizeBins_(const std::vector< double > &scores, std::vector< double > &binned, Transformation_ &trafo)
~IDDecoyProbability() override
Destructor.
void apply(std::vector< PeptideIdentification > &prob_ids, const std::vector< PeptideIdentification > &fwd_ids, const std::vector< PeptideIdentification > &rev_ids)
Converts the forward and reverse identification into probabilities.
void generateDistributionImage_(const std::vector< double > &ids, const String &formula, const String &filename)
double getProbability_(const Math::GammaDistributionFitter::GammaDistributionFitResult &result_gamma, const Transformation_ &gamma_trafo, const Math::GaussFitter::GaussFitResult &result_gauss, const Transformation_ &gauss_trafo, double score)
IDDecoyProbability & operator=(const IDDecoyProbability &rhs)
assignment operator
A more convenient string class.
Definition: String.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
struct to be used to store a transformation (used for fitting)
Definition: IDDecoyProbability.h:93
Transformation_()
Definition: IDDecoyProbability.h:94
double diff_score
Definition: IDDecoyProbability.h:126
double max_intensity
Definition: IDDecoyProbability.h:125
Transformation_ & operator=(const Transformation_ &rhs)
Definition: IDDecoyProbability.h:112
double min_score
Definition: IDDecoyProbability.h:127
Size max_intensity_bin
Definition: IDDecoyProbability.h:129
Transformation_(const Transformation_ &rhs)
Definition: IDDecoyProbability.h:103
double max_score
Definition: IDDecoyProbability.h:128
struct to represent the parameters of a gamma distribution
Definition: GammaDistributionFitter.h:66
struct of parameters of a Gaussian distribution
Definition: GaussFitter.h:66