OpenMS
BasicProteinInferenceAlgorithm.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 
41 
42 namespace OpenMS
43 {
44 
60  class OPENMS_DLLAPI BasicProteinInferenceAlgorithm :
61  public DefaultParamHandler,
62  public ProgressLogger
63  {
64  public:
65 
66  typedef std::unordered_map<std::string, std::map<Int, PeptideHit*>> SequenceToChargeToPSM;
67 
71  enum class AggregationMethod
72  {
73  PROD,
74  SUM,
75  BEST
76  };
77 
80 
86  void run(std::vector<PeptideIdentification>& pep_ids, std::vector<ProteinIdentification>& prot_ids) const;
87 
93  void run(std::vector<PeptideIdentification>& pep_ids, ProteinIdentification& prot_id) const;
94 
102  void run(ConsensusMap& cmap, ProteinIdentification& prot_id, bool include_unassigned) const;
103 
104  private:
105 
116  std::unordered_map<std::string, std::pair<ProteinHit*, Size>>& acc_to_protein_hitP_and_count,
117  SequenceToChargeToPSM& best_pep,
118  ProteinIdentification& prot_run,
119  std::vector<PeptideIdentification>& pep_ids) const;
120 
130  SequenceToChargeToPSM& best_pep,
131  std::vector<PeptideIdentification>& pep_ids,
132  const String& overall_score_type,
133  bool higher_better,
134  const std::string& run_id) const;
135 
145  std::unordered_map<std::string, std::pair<ProteinHit*, Size>>& acc_to_protein_hitP_and_count,
146  const SequenceToChargeToPSM& best_pep,
147  bool pep_scores,
148  bool higher_better) const;
149 
151  AggregationMethod aggFromString_(const std::string& method_string) const;
152 
156  const String& score_type,
157  const AggregationMethod& aggregation_method
158  ) const;
159 
161  double getInitScoreForAggMethod_(const AggregationMethod& aggregation_method, bool higher_better) const;
162 
164  typedef double (*fptr)(double, double);
165  fptr aggFunFromEnum_(const BasicProteinInferenceAlgorithm::AggregationMethod& agg_method, bool higher_better) const;
166  };
167 } //namespace OpenMS
Algorithm class that implements simple protein inference by aggregation of peptide scores....
Definition: BasicProteinInferenceAlgorithm.h:63
void run(std::vector< PeptideIdentification > &pep_ids, ProteinIdentification &prot_id) const
BasicProteinInferenceAlgorithm()
Default constructor.
void updateProteinScores_(std::unordered_map< std::string, std::pair< ProteinHit *, Size >> &acc_to_protein_hitP_and_count, const SequenceToChargeToPSM &best_pep, bool pep_scores, bool higher_better) const
aggregates and updates protein scores based on aggregation settings and aggregated peptide level resu...
std::unordered_map< std::string, std::map< Int, PeptideHit * > > SequenceToChargeToPSM
Definition: BasicProteinInferenceAlgorithm.h:66
void processRun_(std::unordered_map< std::string, std::pair< ProteinHit *, Size >> &acc_to_protein_hitP_and_count, SequenceToChargeToPSM &best_pep, ProteinIdentification &prot_run, std::vector< PeptideIdentification > &pep_ids) const
Performs simple aggregation-based inference on one protein run.
void checkCompat_(const String &score_type, const AggregationMethod &aggregation_method) const
void run(ConsensusMap &cmap, ProteinIdentification &prot_id, bool include_unassigned) const
double getInitScoreForAggMethod_(const AggregationMethod &aggregation_method, bool higher_better) const
get the initial score value based on the chosen aggregation_method, higher_better is needed for "best...
void aggregatePeptideScores_(SequenceToChargeToPSM &best_pep, std::vector< PeptideIdentification > &pep_ids, const String &overall_score_type, bool higher_better, const std::string &run_id) const
fills and updates the map of best peptide scores best_pep (by sequence or modified sequence,...
void run(std::vector< PeptideIdentification > &pep_ids, std::vector< ProteinIdentification > &prot_ids) const
AggregationMethod
The aggregation method.
Definition: BasicProteinInferenceAlgorithm.h:72
AggregationMethod aggFromString_(const std::string &method_string) const
get the AggregationMethod enum from a method_string
fptr aggFunFromEnum_(const BasicProteinInferenceAlgorithm::AggregationMethod &agg_method, bool higher_better) const
A container for consensus elements.
Definition: ConsensusMap.h:92
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
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
A more convenient string class.
Definition: String.h:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48