OpenMS
Loading...
Searching...
No Matches
PeptDeepRescoring.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
16
17#include <map>
18#include <string>
19#include <vector>
20
21namespace OpenMS
22{
23 class PeptideIdentificationList;
24 class ProteinIdentification;
25 class PeptDeepMS2Inference;
26 class PeptDeepRTInference;
27
72 class OPENMS_DLLAPI PeptDeepRescoring :
74 public ProgressLogger
75 {
76 public:
79
82
85
89 static constexpr const char* NCE_META_VALUE = "peptdeep_nce";
90
129 void annotate(const PeakMap& spectra,
130 std::vector<ProteinIdentification>& protein_ids,
131 PeptideIdentificationList& peptide_ids);
132
150 void selectNCE(const PeakMap& spectra,
151 std::vector<ProteinIdentification>& protein_ids,
152 const PeptideIdentificationList& peptide_ids);
153
156 void selectNCE(const PeakMap& spectra,
157 std::vector<ProteinIdentification>& protein_ids,
158 const PeptideIdentificationList& peptide_ids,
159 PeptDeepMS2Inference& ms2_inference);
160
163 double getUsedNCE() const;
164
167 double getRTCalibrationError() const;
168
171
176
177 protected:
178 void updateMembers_() override;
179
190
193 struct PSMRows
194 {
195 std::vector<Row> rows;
196 std::vector<std::string> uniq_seq;
197 std::vector<float> uniq_charge;
198 std::map<std::string, std::vector<Size>> rows_by_run;
199 };
200
203 bool startCall_(const PeptideIdentificationList& peptide_ids, const StringList& models, const std::string& what);
204
206 void selectNCE_(const PeakMap& spectra,
207 std::vector<ProteinIdentification>& protein_ids,
208 const PeptideIdentificationList& peptide_ids,
209 PeptDeepMS2Inference& ms2_inference);
210
214
217 static std::map<std::string, double> collisionEnergies_(const PeakMap& spectra);
218
221 std::vector<Size> confidentRows_(const std::vector<Row>& rows, const std::vector<Size>& run_rows, bool higher_better) const;
222
225 double selectRunNCE_(const std::map<std::string, double>& collision_energies,
226 const PeptideIdentificationList& peptide_ids,
227 const PSMRows& psms,
228 const std::vector<Size>& run_rows,
229 const std::vector<Size>& confident,
230 PeptDeepMS2Inference& ms2_inference,
231 double& centre,
232 double& median_cosine);
233
236 static void storeNCE_(std::vector<ProteinIdentification>& protein_ids, const std::map<std::string, double>& nce_by_run);
237
241 void annotateRun_(const std::string& run_id,
242 const std::map<std::string, double>& collision_energies,
243 PeptideIdentificationList& peptide_ids,
244 const PSMRows& psms,
245 const std::vector<Size>& run_rows,
246 bool higher_better,
247 PeptDeepMS2Inference& ms2_inference,
248 PeptDeepRTInference& rt_inference);
249
250 std::string ms2_model_;
251 std::string rt_model_;
252 double nce_{-1.0};
253 double nce_grid_halfwidth_{6.0};
254 double nce_grid_step_{2.0};
255 double nce_fallback_{30.0};
256 Size nce_sample_size_{2000};
257 std::string instrument_;
258 double calibration_quantile_{0.5};
259 std::string rt_model_type_{"b_spline"};
260 Size rt_num_nodes_{5};
261 int ms2_min_ordinal_{1};
262 double ms2_strong_fraction_{0.05};
263 Size batch_size_{64};
264 Int threads_{4};
265
266 double used_nce_{-1.0};
267 double rt_calibration_error_{-1.0};
268 Size num_psms_{0};
269 Size num_predicted_psms_{0};
270 };
271
272} // namespace OpenMS
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
Inference engine for PeptDeep MS2 Fragment Intensity prediction.
Definition PeptDeepMS2Inference.h:23
Predicts peptide retention times with the PeptDeep RT model (peptdeep_rt_dynamic.onnx)
Definition PeptDeepRTInference.h:26
Annotates PSMs with rescoring features derived from PeptDeep predictions.
Definition PeptDeepRescoring.h:75
bool calibration_candidate
best hit of its spectrum and not a decoy
Definition PeptDeepRescoring.h:188
void annotate(const PeakMap &spectra, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids)
Annotates peptide_ids in place and registers the features for rescoring.
std::map< std::string, std::vector< Size > > rows_by_run
Definition PeptDeepRescoring.h:198
Size getNumPredictedPSMs() const
double getRTCalibrationError() const
static PSMRows gatherPSMs_(const PeptideIdentificationList &peptide_ids)
bool startCall_(const PeptideIdentificationList &peptide_ids, const StringList &models, const std::string &what)
Size key
index into the de-duplicated (sequence, charge) list
Definition PeptDeepRescoring.h:186
std::vector< std::string > uniq_seq
Definition PeptDeepRescoring.h:196
Size pi
index into the PeptideIdentificationList
Definition PeptDeepRescoring.h:183
double score
search score, used to pick the calibration set
Definition PeptDeepRescoring.h:187
~PeptDeepRescoring() override
Destructor.
PeptDeepRescoring()
Constructor. Sets the default parameters; the model paths start empty and must be set.
double getUsedNCE() const
std::string ms2_model_
Definition PeptDeepRescoring.h:250
Size len
peptide length
Definition PeptDeepRescoring.h:185
static StringList featureNames()
Names of the features this class adds to each PSM, in a stable order.
Size getNumPSMs() const
Number of PSMs (peptide hits) seen by the last annotate() call.
std::vector< Size > confidentRows_(const std::vector< Row > &rows, const std::vector< Size > &run_rows, bool higher_better) const
void selectNCE(const PeakMap &spectra, std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, PeptDeepMS2Inference &ms2_inference)
std::string instrument_
Definition PeptDeepRescoring.h:257
std::string rt_model_
Definition PeptDeepRescoring.h:251
Size hit
index into that identification's hits
Definition PeptDeepRescoring.h:184
static std::map< std::string, double > collisionEnergies_(const PeakMap &spectra)
std::vector< float > uniq_charge
Definition PeptDeepRescoring.h:197
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
void annotateRun_(const std::string &run_id, const std::map< std::string, double > &collision_energies, PeptideIdentificationList &peptide_ids, const PSMRows &psms, const std::vector< Size > &run_rows, bool higher_better, PeptDeepMS2Inference &ms2_inference, PeptDeepRTInference &rt_inference)
static void storeNCE_(std::vector< ProteinIdentification > &protein_ids, const std::map< std::string, double > &nce_by_run)
std::vector< Row > rows
Definition PeptDeepRescoring.h:195
void selectNCE(const PeakMap &spectra, std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids)
Selects the normalised collision energy of each run of peptide_ids as annotate() does,...
double selectRunNCE_(const std::map< std::string, double > &collision_energies, const PeptideIdentificationList &peptide_ids, const PSMRows &psms, const std::vector< Size > &run_rows, const std::vector< Size > &confident, PeptDeepMS2Inference &ms2_inference, double &centre, double &median_cosine)
void selectNCE_(const PeakMap &spectra, std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, PeptDeepMS2Inference &ms2_inference)
selectNCE() with the session ms2_inference
Definition PeptDeepRescoring.h:194
Row of the flat PSM work list built by annotate().
Definition PeptDeepRescoring.h:182
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:28
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< std::string > StringList
Vector of String.
Definition TypeAliases.h:39
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19