OpenMS
Ms2IdentificationRate.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow$
6 // $Authors: Patricia Scheil, Swenja Wagner$
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/QC/QCBase.h>
12 
13 #include <OpenMS/CONCEPT/Types.h>
14 #include <string>
15 #include <vector>
16 
17 namespace OpenMS
18 {
19  class FeatureMap;
20  class MSExperiment;
21  class MzTabMetaData;
22  class PeptideIdentification;
23 
31  class OPENMS_DLLAPI Ms2IdentificationRate : public QCBase
32  {
33  public:
36  Size num_peptide_identification = 0;
37  Size num_ms2_spectra = 0;
38  double identification_rate = 0.;
39  };
40 
41  private:
43  const String name_ = "Ms2IdentificationRate";
44 
46  std::vector<IdentificationRateData> rate_result_;
47 
50 
51  /*
52  * @brief Checks pepID for target/decoy
53  *
54  * Only checks the first (!) hit, all other hits are ignored
55  * Is static so that it can be used with MapUtilities::applyFunctionOnPeptideIDs() without creating a new object for each ID
56  *
57  * @param id pepID to be checked
58  * @param all_targets always returns true (if the hits aren't empty)
59  * @return true/false
60  * @throws MissingInformation if target/decoy annotation is missing
61  */
62  static bool isTargetPeptide_(const PeptideIdentification& id, bool all_targets);
63 
64  /*
65  * @brief Calculates id-rate and writes the result into a IdentificationRateData object which is appended to rate_result_
66  *
67  * @param ms2_spectra_count number of found ms2 spectra
68  * @param pep_ids_count number of found (target) peptide identifications
69  */
70  void writeResults_(Size pep_ids_count, Size ms2_spectra_count);
71 
72  public:
74  Ms2IdentificationRate() = default;
75 
77  virtual ~Ms2IdentificationRate() = default;
78 
92  void compute(const FeatureMap& feature_map, const MSExperiment& exp, bool assume_all_target = false);
93 
107  void compute(const std::vector<PeptideIdentification>& pep_ids, const MSExperiment& exp, bool assume_all_target = false);
108 
110  const String& getName() const override;
111 
113  const std::vector<IdentificationRateData>& getResults() const;
114 
119  QCBase::Status requirements() const override;
120 
122  };
123 
124 } // namespace OpenMS
A container for features.
Definition: FeatureMap.h:80
Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64.
Definition: FlagSet.h:28
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
This class is a metric for the QualityControl-ToppTool.
Definition: Ms2IdentificationRate.h:32
Ms2IdentificationRate()=default
Default constructor.
std::vector< IdentificationRateData > rate_result_
container that stores results
Definition: Ms2IdentificationRate.h:46
void compute(const FeatureMap &feature_map, const MSExperiment &exp, bool assume_all_target=false)
computes Ms2 Identification Rate with FeatureMap
void compute(const std::vector< PeptideIdentification > &pep_ids, const MSExperiment &exp, bool assume_all_target=false)
computes Ms2 Identification Rate with PeptideIdentifications
void addMetaDataMetricsToMzTab(MzTabMetaData &meta) const
const String & getName() const override
returns the name of the metric
QCBase::Status requirements() const override
Returns the input data requirements of the compute(...) function.
void writeResults_(Size pep_ids_count, Size ms2_spectra_count)
const std::vector< IdentificationRateData > & getResults() const
returns results
virtual ~Ms2IdentificationRate()=default
Destructor.
static bool isTargetPeptide_(const PeptideIdentification &id, bool all_targets)
Size getMS2Count_(const MSExperiment &exp)
returns number of all ms2 spectra in an MSExperiment
Structure for storing results.
Definition: Ms2IdentificationRate.h:35
all meta data of a mzTab file. Please refer to specification for documentation.
Definition: MzTab.h:115
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:39
This class serves as an abstract base class for all QC classes.
Definition: QCBase.h:29
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19