OpenMS
XFDRAlgorithm.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: Eugen Netz $
6 // $Authors: Lukas Zimmermann, Eugen Netz $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
18 
19 namespace OpenMS
20 {
21 
22  //-------------------------------------------------------------
23  // Doxygen docu
24  //-------------------------------------------------------------
25 
37  class OPENMS_DLLAPI XFDRAlgorithm :
38  public DefaultParamHandler, public ProgressLogger
39  {
40 
41  public:
42 
44  enum ExitCodes
45  {
48  UNEXPECTED_RESULT
49  };
50 
53 
55  ~XFDRAlgorithm() override;
56 
64  ExitCodes run(std::vector<PeptideIdentification>& peptide_ids, ProteinIdentification& protein_id);
65 
71 
72 private:
73  void updateMembers_() override;
74 
84  void initDataStructures_(std::vector<PeptideIdentification>& peptide_ids, ProteinIdentification& protein_id);
85 
91  static void assignTypes_(PeptideHit& pep_id, StringList& types);
92 
104  void fdr_xprophet_(std::map< String, Math::Histogram<> >& cum_histograms,
105  const String& targetclass, const String& decoyclass, const String& fulldecoyclass,
106  std::vector< double >& fdr, bool mono) const;
107 
113  static void calc_qfdr_(const std::vector< double >& fdr, std::vector< double >& qfdr);
114 
115  void findTopUniqueHits_(std::vector<PeptideIdentification>& peptide_ids);
116 
117  void writeArgumentsLog_() const;
118 
119  String getId_(const PeptideHit& ph) const;
120 
122  {
123  Size alpha_ions = Size(ph.getMetaValue("matched_linear_alpha")) + Size(ph.getMetaValue("matched_xlink_alpha"));
124  Size beta_ions = Size(ph.getMetaValue("matched_linear_beta")) + Size(ph.getMetaValue("matched_xlink_beta"));
125  return std::min(alpha_ions, beta_ions);
126  }
127 
128  inline static void setIntraProtein_(PeptideHit& ph, const bool value)
129  {
130  ph.setMetaValue("XFDR:is_intraprotein", DataValue(value ? "true" : "false"));
131  }
132 
133  inline static void setInterProtein_(PeptideHit& ph, const bool value)
134  {
135  ph.setMetaValue("XFDR:is_interprotein", DataValue(value ? "true" : "false"));
136  }
137 
141  static bool isSameProtein_(
142  String prot1,
143  String prot2,
144  const String &decoy_string)
145  {
146  prot1.substitute(decoy_string, "");
147  prot2.substitute(decoy_string, "");
148  assert( ! prot1.hasSubstring(decoy_string));
149  assert( ! prot2.hasSubstring(decoy_string));
150  return prot1 == prot2;
151  }
152 
153  // Score range for this of the tool
156 
157  // unique top hits
158  std::vector<String> unique_ids_;
159  std::vector<double> unique_id_scores_;
160 
161  // maps index of peptide id all_pep_ids_ to vector of cross link class
162  std::map<String, std::vector<String>> cross_link_classes_;
163 
164  // Program arguments
173  double arg_binsize_;
174 
175  // Names of the class parameters
177  static const String param_minborder_;
178  static const String param_maxborder_;
179  static const String param_mindeltas_;
181  static const String param_uniquexl_;
182  static const String param_no_qvalues_;
183  static const String param_minscore_;
184  static const String param_binsize_;
185 
186  // Constants related to particular crosslink classes
199  };
200 }
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:33
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Representation of a histogram.
Definition: Histogram.h:38
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
const DataValue & getMetaValue(const String &name) const
Returns the value corresponding to a string, or DataValue::EMPTY if not found.
Representation of a peptide hit.
Definition: PeptideHit.h:31
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Representation of a protein identification run.
Definition: ProteinIdentification.h:50
A more convenient string class.
Definition: String.h:34
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
String & substitute(char from, char to)
Replaces all occurrences of the character from by the character to.
Calculates false discovery rate estimates on crosslink identifications.
Definition: XFDRAlgorithm.h:39
static const String crosslink_class_intralinks_
Definition: XFDRAlgorithm.h:192
ExitCodes validateClassArguments() const
Checks whether the parameters of the object are valid.
bool arg_no_qvalues_
Definition: XFDRAlgorithm.h:172
static const String param_binsize_
Definition: XFDRAlgorithm.h:184
static const String crosslink_class_intradecoys_
Definition: XFDRAlgorithm.h:187
static const String crosslink_class_decoys_
Definition: XFDRAlgorithm.h:195
ExitCodes run(std::vector< PeptideIdentification > &peptide_ids, ProteinIdentification &protein_id)
Performs the main function of this class, the FDR estimation for cross-linked peptide experiments.
std::map< String, std::vector< String > > cross_link_classes_
Definition: XFDRAlgorithm.h:162
static void setIntraProtein_(PeptideHit &ph, const bool value)
Definition: XFDRAlgorithm.h:128
static const String crosslink_class_interdecoys_
Definition: XFDRAlgorithm.h:189
static void calc_qfdr_(const std::vector< double > &fdr, std::vector< double > &qfdr)
Calculates the qFDR values for the provided FDR values, assuming that the FDRs are sorted by score in...
static const String param_no_qvalues_
Definition: XFDRAlgorithm.h:182
String decoy_string_
Definition: XFDRAlgorithm.h:165
static const String crosslink_class_targets_
Definition: XFDRAlgorithm.h:196
bool arg_uniquex_
Definition: XFDRAlgorithm.h:171
void fdr_xprophet_(std::map< String, Math::Histogram<> > &cum_histograms, const String &targetclass, const String &decoyclass, const String &fulldecoyclass, std::vector< double > &fdr, bool mono) const
xprophet method for target hits counting as implemented in xProphet
double arg_minscore_
Definition: XFDRAlgorithm.h:170
XFDRAlgorithm()
Default constructor.
static bool isSameProtein_(String prot1, String prot2, const String &decoy_string)
Determines whether the Peptide Evidences belong to the same protein, modulo decoy.
Definition: XFDRAlgorithm.h:141
double arg_mindeltas_
Definition: XFDRAlgorithm.h:166
static const String crosslink_class_fulldecoysinterlinks_
Definition: XFDRAlgorithm.h:190
static const String crosslink_class_hybriddecoysinterlinks_
Definition: XFDRAlgorithm.h:198
static const String param_mindeltas_
Definition: XFDRAlgorithm.h:179
String getId_(const PeptideHit &ph) const
void initDataStructures_(std::vector< PeptideIdentification > &peptide_ids, ProteinIdentification &protein_id)
Prepares vector of PeptideIdentification such that it can be processed downstream....
Int min_score_
Definition: XFDRAlgorithm.h:154
void findTopUniqueHits_(std::vector< PeptideIdentification > &peptide_ids)
static const String crosslink_class_monolinks_
Definition: XFDRAlgorithm.h:194
static const String crosslink_class_hybriddecoysintralinks_
Definition: XFDRAlgorithm.h:197
std::vector< double > unique_id_scores_
Definition: XFDRAlgorithm.h:159
void writeArgumentsLog_() const
std::vector< String > unique_ids_
Definition: XFDRAlgorithm.h:158
static const String param_decoy_string_
Definition: XFDRAlgorithm.h:176
static Size getMinIonsMatched_(const PeptideHit &ph)
Definition: XFDRAlgorithm.h:121
static const String param_maxborder_
Definition: XFDRAlgorithm.h:178
static const String param_uniquexl_
Definition: XFDRAlgorithm.h:181
Int max_score_
Definition: XFDRAlgorithm.h:155
static void setInterProtein_(PeptideHit &ph, const bool value)
Definition: XFDRAlgorithm.h:133
static const String param_minborder_
Definition: XFDRAlgorithm.h:177
static const String param_minscore_
Definition: XFDRAlgorithm.h:183
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
static const String crosslink_class_fulldecoysintralinks_
Definition: XFDRAlgorithm.h:188
ExitCodes
Exit codes.
Definition: XFDRAlgorithm.h:45
@ ILLEGAL_PARAMETERS
Definition: XFDRAlgorithm.h:47
@ EXECUTION_OK
Definition: XFDRAlgorithm.h:46
static void assignTypes_(PeptideHit &pep_id, StringList &types)
Inspects a PeptideIdentification and assigns all cross-link types that this identification belongs to...
static const String crosslink_class_monodecoys_
Definition: XFDRAlgorithm.h:191
double arg_minborder_
Definition: XFDRAlgorithm.h:167
double arg_maxborder_
Definition: XFDRAlgorithm.h:168
Int arg_minionsmatched_
Definition: XFDRAlgorithm.h:169
static const String crosslink_class_interlinks_
Definition: XFDRAlgorithm.h:193
double arg_binsize_
Definition: XFDRAlgorithm.h:173
~XFDRAlgorithm() override
Default destructor.
static const String param_minionsmatched_
Definition: XFDRAlgorithm.h:180
int Int
Signed integer type.
Definition: Types.h:72
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19