OpenMS
BayesianProteinInferenceAlgorithm.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-2023.
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: Julianus Pfeuffer $
32 // $Authors: Julianus Pfeuffer $
33 // --------------------------------------------------------------------------
34 #pragma once
35 
36 //#define INFERENCE_BENCH
37 
42 
43 #include <vector>
44 #include <functional>
45 #include <optional>
46 
47 namespace OpenMS
48 {
49  class ConsensusMap;
50  namespace Internal
51  {
52  class IDBoostGraph;
53  }
54  class PeptideIdentification;
55  class ProteinIdentification;
56 
75  class OPENMS_DLLAPI BayesianProteinInferenceAlgorithm :
76  public DefaultParamHandler,
77  public ProgressLogger
78  {
79  public:
81  explicit BayesianProteinInferenceAlgorithm(unsigned int debug_lvl = 0);
82 
84  ~BayesianProteinInferenceAlgorithm() override = default;
85 
86  void updateMembers_() override;
87 
90  class GraphInferenceFunctor;
91 
95  class ExtendedGraphInferenceFunctor;
96 
98  struct GridSearchEvaluator;
99 
100 
117  std::vector<ProteinIdentification>& proteinIDs,
118  std::vector<PeptideIdentification>& peptideIDs,
119  bool greedy_group_resolution,
120  std::optional<const ExperimentalDesign> exp_des = std::optional<const ExperimentalDesign>());
121 
134  ConsensusMap& cmap,
135  bool greedy_group_resolution,
136  std::optional<const ExperimentalDesign> exp_des = std::optional<const ExperimentalDesign>());
137 
138  private:
139 
143 
146  std::vector<double>& alpha_search,
147  std::vector<double>& beta_search,
148  std::vector<double>& gamma_search
149  );
150 
153 
155  // TODO double-check if -1 is maybe the better option
156  // to distinguish between "untouched/unused/unreferenced" (e.g. if somehow
157  // not removed/filtered) and an inferred probability of 0.0. But it might give
158  // problems in FDR algorithms if not ignored/removed correctly
159  void resetProteinScores_(ProteinIdentification& protein_id, bool keep_old_as_prior);
160 
163  std::function<void(PeptideIdentification&/*, const String& run_id*/)> checkConvertAndFilterPepHits_;
164 
165  unsigned int debug_lvl_;
166 
167  #ifdef INFERENCE_BENCH
168  std::vector<std::pair<double,Size>> debug_times_;
169  #endif
170 
171  };
172 }
Performs a Bayesian protein inference on Protein/Peptide identifications or ConsensusMap (experimenta...
Definition: BayesianProteinInferenceAlgorithm.h:78
void setScoreTypeAndSettings_(ProteinIdentification &proteinIDs)
set score type and settings for every ProteinID run processed
std::function< void(PeptideIdentification &)> checkConvertAndFilterPepHits_
Definition: BayesianProteinInferenceAlgorithm.h:163
void resetProteinScores_(ProteinIdentification &protein_id, bool keep_old_as_prior)
reset all protein scores to 0.0, save old ones as Prior MetaValue if requested
~BayesianProteinInferenceAlgorithm() override=default
Destructor.
GridSearch< double, double, double > initGridSearchFromParams_(std::vector< double > &alpha_search, std::vector< double > &beta_search, std::vector< double > &gamma_search)
read Param object and set the grid
void inferPosteriorProbabilities_(Internal::IDBoostGraph &ibg)
void inferPosteriorProbabilities(std::vector< ProteinIdentification > &proteinIDs, std::vector< PeptideIdentification > &peptideIDs, bool greedy_group_resolution, std::optional< const ExperimentalDesign > exp_des=std::optional< const ExperimentalDesign >())
Perform inference. Filter, build graph, run the private inferPosteriorProbabilities_ function....
BayesianProteinInferenceAlgorithm(unsigned int debug_lvl=0)
Constructor.
void inferPosteriorProbabilities(ConsensusMap &cmap, bool greedy_group_resolution, std::optional< const ExperimentalDesign > exp_des=std::optional< const ExperimentalDesign >())
Perform inference. Filter, build graph, run the private inferPosteriorProbabilities_ function....
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
unsigned int debug_lvl_
Definition: BayesianProteinInferenceAlgorithm.h:165
A container for consensus elements.
Definition: ConsensusMap.h:92
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Definition: GridSearch.h:99
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:83
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:65
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
Representation of a protein identification run.
Definition: ProteinIdentification.h:76
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48