OpenMS
Loading...
Searching...
No Matches
MRMAssay.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: George Rosenberger $
6// $Authors: George Rosenberger $
7// --------------------------------------------------------------------------
8
9#pragma once
10
16
17#include <boost/random/mersenne_twister.hpp>
18#include <boost/random/uniform_int.hpp>
19#include <boost/random/variate_generator.hpp>
20
21// #define DEBUG_MRMASSAY
22
23namespace OpenMS
24{
40 class OPENMS_DLLAPI MRMAssay :
41 public ProgressLogger
42 {
43
44public:
46
47 MRMAssay(); // empty, no members
48
50 ~MRMAssay() override;
52
53 typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
54 typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
55 typedef std::vector<OpenMS::TargetedExperiment::Compound> CompoundVectorType;
56 typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
57
58 typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
59 typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > CompoundTransitionMapType;
60
61 typedef std::map<String, std::set<std::string> > ModifiedSequenceMap;
62 typedef std::map<size_t, ModifiedSequenceMap> SequenceMapT;
63
64 typedef std::vector<std::pair<double, std::string> > FragmentSeqMap;
65 typedef std::map<size_t, std::map<String, FragmentSeqMap > > IonMapT;
66
67 typedef std::vector<std::pair<std::string, double> > IonSeries;
68 typedef std::map<String, IonSeries > PeptideMapT;
69
70 typedef std::map<String, TargetedExperiment::Peptide> TargetDecoyMapT;
71
86 double precursor_mz_threshold,
87 double product_mz_threshold,
88 const std::vector<String>& fragment_types,
89 const std::vector<size_t>& fragment_charges,
90 bool enable_specific_losses,
91 bool enable_unspecific_losses,
92 int round_decPow = -4);
93
105 double lower_mz_limit, double upper_mz_limit,
106 const std::vector<std::pair<double, double> >& swathes);
107
116 void detectingTransitions(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
117
152 const std::vector<String>& fragment_types,
153 const std::vector<size_t>& fragment_charges,
154 bool enable_specific_losses,
155 bool enable_unspecific_losses,
156 bool enable_ms2_precursors,
157 double mz_threshold,
158 const std::vector<std::pair<double, double> >& swathes,
159 int round_decPow = -4,
160 size_t max_num_alternative_localizations = 20,
161 int shuffle_seed = -1,
162 bool disable_decoy_transitions = false);
163
172 void filterMinMaxTransitionsCompound(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
173
188
189 // =====================================================================
190 // Light (memory-efficient) versions of the above methods
191 // =====================================================================
192
209 double precursor_mz_threshold,
210 double product_mz_threshold,
211 const std::vector<String>& fragment_types,
212 const std::vector<size_t>& fragment_charges,
213 bool enable_specific_losses,
214 bool enable_unspecific_losses,
215 int round_decPow = -4);
216
229 double lower_mz_limit,
230 double upper_mz_limit,
231 const std::vector<std::pair<double, double> >& swathes);
232
244 int min_transitions,
245 int max_transitions);
246
267 const std::vector<String>& fragment_types,
268 const std::vector<size_t>& fragment_charges,
269 bool enable_specific_losses,
270 bool enable_unspecific_losses,
271 bool enable_ms2_precursors,
272 double mz_threshold,
273 const std::vector<std::pair<double, double> >& swathes,
274 int round_decPow = -4,
275 size_t max_num_alternative_localizations = 20,
276 int shuffle_seed = -1,
277 bool disable_decoy_transitions = false);
278
279protected:
280
291 std::vector<std::string> getMatchingPeptidoforms_(const double fragment_ion,
292 const FragmentSeqMap& ions,
293 const double mz_threshold);
294
303 int getSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz);
304
314 bool isInSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz, const double product_mz);
315
324 std::string getRandomSequence_(size_t sequence_size, boost::variate_generator<boost::mt19937&, boost::uniform_int<> > pseudoRNG);
325
334 std::vector<std::vector<size_t> > nchoosekcombinations_(const std::vector<size_t>& n, size_t k);
335
345 std::vector<OpenMS::AASequence> addModificationsSequences_(const std::vector<OpenMS::AASequence>& sequences,
346 const std::vector<std::vector<size_t> >& mods_combs,
347 const OpenMS::String& modification);
348
360 std::vector<OpenMS::AASequence> generateTheoreticalPeptidoforms_(const OpenMS::AASequence& sequence);
361
379 std::vector<OpenMS::AASequence> generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence& sequence, const OpenMS::AASequence& decoy_sequence);
380
395 const std::vector<String>& fragment_types,
396 const std::vector<size_t>& fragment_charges,
397 bool enable_specific_losses,
398 bool enable_unspecific_losses,
399 bool enable_ms2_precursors,
400 const std::vector<std::pair<double, double> >& swathes,
401 int round_decPow,
402 size_t max_num_alternative_localizations,
403 SequenceMapT& TargetSequenceMap,
404 IonMapT& TargetIonMap,
405 PeptideMapT& TargetPeptideMap);
406
416 void generateDecoySequences_(const SequenceMapT& TargetSequenceMap,
417 std::map<String, String>& DecoySequenceMap,
418 int shuffle_seed);
419
432 const std::vector<String>& fragment_types,
433 const std::vector<size_t>& fragment_charges,
434 bool enable_specific_losses,
435 bool enable_unspecific_losses,
436 bool enable_ms2_precursors,
437 const std::vector<std::pair<double, double> >& swathes,
438 int round_decPow,
439 TargetDecoyMapT& TargetDecoyMap,
440 PeptideMapT& TargetPeptideMap,
441 std::map<String, String>& DecoySequenceMap,
442 IonMapT& DecoyIonMap,
443 PeptideMapT& DecoyPeptideMap);
444
464 TransitionVectorType& transitions,
465 double mz_threshold,
466 const std::vector<std::pair<double, double> >& swathes,
467 int round_decPow,
468 const PeptideMapT& TargetPeptideMap,
469 const IonMapT& TargetIonMap);
470
478 TransitionVectorType& transitions,
479 double mz_threshold,
480 const std::vector<std::pair<double, double> >& swathes,
481 int round_decPow,
482 const PeptideMapT& DecoyPeptideMap,
483 TargetDecoyMapT& TargetDecoyMap,
484 const IonMapT& DecoyIonMap,
485 const IonMapT& TargetIonMap);
486
487 // =====================================================================
488 // Light (memory-efficient) versions of IPF helper methods
489 // =====================================================================
490
492 typedef std::map<String, OpenSwath::LightCompound> TargetDecoyMapLightT;
493
502 const std::vector<String>& fragment_types,
503 const std::vector<size_t>& fragment_charges,
504 bool enable_specific_losses,
505 bool enable_unspecific_losses,
506 bool enable_ms2_precursors,
507 const std::vector<std::pair<double, double> >& swathes,
508 int round_decPow,
509 size_t max_num_alternative_localizations,
510 SequenceMapT& TargetSequenceMap,
511 IonMapT& TargetIonMap,
512 PeptideMapT& TargetPeptideMap);
513
522 const std::vector<String>& fragment_types,
523 const std::vector<size_t>& fragment_charges,
524 bool enable_specific_losses,
525 bool enable_unspecific_losses,
526 bool enable_ms2_precursors,
527 const std::vector<std::pair<double, double> >& swathes,
528 int round_decPow,
529 TargetDecoyMapLightT& TargetDecoyMap,
530 const PeptideMapT& TargetPeptideMap,
531 const std::map<String, String>& DecoySequenceMap,
532 IonMapT& DecoyIonMap,
533 PeptideMapT& DecoyPeptideMap);
534
543 std::vector<OpenSwath::LightTransition>& transitions,
544 double mz_threshold,
545 const std::vector<std::pair<double, double> >& swathes,
546 int round_decPow,
547 const PeptideMapT& TargetPeptideMap,
548 const IonMapT& TargetIonMap);
549
558 std::vector<OpenSwath::LightTransition>& transitions,
559 double mz_threshold,
560 const std::vector<std::pair<double, double> >& swathes,
561 int round_decPow,
562 const PeptideMapT& DecoyPeptideMap,
563 const TargetDecoyMapLightT& TargetDecoyMap,
564 const IonMapT& DecoyIonMap,
565 const IonMapT& TargetIonMap);
566
567 };
568}
Representation of a peptide/protein sequence.
Definition AASequence.h:88
Generate assays from a TargetedExperiment.
Definition MRMAssay.h:42
void generateTargetAssays_(const OpenMS::TargetedExperiment &exp, TransitionVectorType &transitions, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow, const PeptideMapT &TargetPeptideMap, const IonMapT &TargetIonMap)
Generate target identification transitions.
void generateDecoyInSilicoMapLight_(const OpenSwath::LightTargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, const std::vector< std::pair< double, double > > &swathes, int round_decPow, TargetDecoyMapLightT &TargetDecoyMap, const PeptideMapT &TargetPeptideMap, const std::map< String, String > &DecoySequenceMap, IonMapT &DecoyIonMap, PeptideMapT &DecoyPeptideMap)
Generate decoy in silico map (light version)
void restrictTransitionsLight(OpenSwath::LightTargetedExperiment &exp, double lower_mz_limit, double upper_mz_limit, const std::vector< std::pair< double, double > > &swathes)
Restrict and filter transitions in a LightTargetedExperiment.
std::vector< OpenMS::AASequence > addModificationsSequences_(const std::vector< OpenMS::AASequence > &sequences, const std::vector< std::vector< size_t > > &mods_combs, const OpenMS::String &modification)
Generate modified peptide forms based on all possible combinations.
std::map< String, TargetedExperiment::Peptide > TargetDecoyMapT
Maps the peptide id (same for target and decoy) to the decoy peptide object.
Definition MRMAssay.h:70
std::vector< OpenMS::TargetedExperiment::Compound > CompoundVectorType
Definition MRMAssay.h:55
void detectingTransitions(OpenMS::TargetedExperiment &exp, int min_transitions, int max_transitions)
Select detecting fragment ions.
void generateDecoyAssaysLight_(const OpenSwath::LightTargetedExperiment &exp, std::vector< OpenSwath::LightTransition > &transitions, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow, const PeptideMapT &DecoyPeptideMap, const TargetDecoyMapLightT &TargetDecoyMap, const IonMapT &DecoyIonMap, const IonMapT &TargetIonMap)
Generate decoy assays (light version)
std::map< String, std::vector< const ReactionMonitoringTransition * > > CompoundTransitionMapType
Definition MRMAssay.h:59
void generateTargetAssaysLight_(const OpenSwath::LightTargetedExperiment &exp, std::vector< OpenSwath::LightTransition > &transitions, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow, const PeptideMapT &TargetPeptideMap, const IonMapT &TargetIonMap)
Generate target identification transitions (light version)
void restrictTransitions(OpenMS::TargetedExperiment &exp, double lower_mz_limit, double upper_mz_limit, const std::vector< std::pair< double, double > > &swathes)
Restrict and filter transitions in a TargetedExperiment.
void reannotateTransitionsLight(OpenSwath::LightTargetedExperiment &exp, double precursor_mz_threshold, double product_mz_threshold, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, int round_decPow=-4)
Annotates and filters transitions in a LightTargetedExperiment.
std::vector< std::vector< size_t > > nchoosekcombinations_(const std::vector< size_t > &n, size_t k)
Computes all N choose K combinations.
std::map< size_t, ModifiedSequenceMap > SequenceMapT
Stores the ModifiedSequenceMap for all SWATH windows (uses std::map for deterministic iteration order...
Definition MRMAssay.h:62
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition MRMAssay.h:58
void generateTargetInSilicoMapLight_(const OpenSwath::LightTargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, const std::vector< std::pair< double, double > > &swathes, int round_decPow, size_t max_num_alternative_localizations, SequenceMapT &TargetSequenceMap, IonMapT &TargetIonMap, PeptideMapT &TargetPeptideMap)
Generate target in silico map (light version)
int getSwath_(const std::vector< std::pair< double, double > > &swathes, const double precursor_mz)
Get swath index (precursor isolation window ordinal) for a particular precursor.
std::vector< OpenMS::AASequence > generateTheoreticalPeptidoforms_(const OpenMS::AASequence &sequence)
Generate alternative modified peptide forms according to ModificationsDB.
void generateDecoyAssays_(const OpenMS::TargetedExperiment &exp, TransitionVectorType &transitions, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow, const PeptideMapT &DecoyPeptideMap, TargetDecoyMapT &TargetDecoyMap, const IonMapT &DecoyIonMap, const IonMapT &TargetIonMap)
Generate decoy assays.
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition MRMAssay.h:56
std::vector< std::pair< double, std::string > > FragmentSeqMap
Describes a fragment sequence map of : "fragment m/z" -> "modified sequence".
Definition MRMAssay.h:64
void generateTargetInSilicoMap_(const OpenMS::TargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, const std::vector< std::pair< double, double > > &swathes, int round_decPow, size_t max_num_alternative_localizations, SequenceMapT &TargetSequenceMap, IonMapT &TargetIonMap, PeptideMapT &TargetPeptideMap)
Generate target in silico map.
std::string getRandomSequence_(size_t sequence_size, boost::variate_generator< boost::mt19937 &, boost::uniform_int<> > pseudoRNG)
Generates random peptide sequence.
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition MRMAssay.h:54
std::map< String, OpenSwath::LightCompound > TargetDecoyMapLightT
Light version of TargetDecoyMapT using LightCompound.
Definition MRMAssay.h:492
std::vector< std::pair< std::string, double > > IonSeries
Describes an ion series: "ion_type" -> "fragment m/z".
Definition MRMAssay.h:67
void filterMinMaxTransitionsCompound(OpenMS::TargetedExperiment &exp, int min_transitions, int max_transitions)
Filters target and decoy transitions by intensity, only keeping the top N transitions.
void detectingTransitionsLight(OpenSwath::LightTargetedExperiment &exp, int min_transitions, int max_transitions)
Select detecting fragment ions in a LightTargetedExperiment.
MRMAssay()
Constructor.
std::map< String, std::set< std::string > > ModifiedSequenceMap
Maps an unmodified sequence to all its modified sequences.
Definition MRMAssay.h:61
std::map< String, IonSeries > PeptideMapT
Maps a peptide sequence to an ion series: "ion_type" -> "fragment m/z".
Definition MRMAssay.h:68
void generateDecoySequences_(const SequenceMapT &TargetSequenceMap, std::map< String, String > &DecoySequenceMap, int shuffle_seed)
Generate decoy sequences.
void filterUnreferencedDecoysCompound(OpenMS::TargetedExperiment &exp)
Filters decoy transitions, which do not have respective target transition based on the transitionID.
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition MRMAssay.h:53
std::vector< OpenMS::AASequence > generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence &sequence, const OpenMS::AASequence &decoy_sequence)
Generate alternative modified peptide forms according to ModificationsDB.
std::map< size_t, std::map< String, FragmentSeqMap > > IonMapT
Stores a mapping : "unmodified sequence" -> FragmentSeqMap for all SWATH windows (uses std::map for d...
Definition MRMAssay.h:65
void uisTransitions(OpenMS::TargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow=-4, size_t max_num_alternative_localizations=20, int shuffle_seed=-1, bool disable_decoy_transitions=false)
Annotate UIS / site-specific transitions.
void reannotateTransitions(OpenMS::TargetedExperiment &exp, double precursor_mz_threshold, double product_mz_threshold, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, int round_decPow=-4)
Annotates and filters transitions in a TargetedExperiment.
void generateDecoyInSilicoMap_(const OpenMS::TargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, const std::vector< std::pair< double, double > > &swathes, int round_decPow, TargetDecoyMapT &TargetDecoyMap, PeptideMapT &TargetPeptideMap, std::map< String, String > &DecoySequenceMap, IonMapT &DecoyIonMap, PeptideMapT &DecoyPeptideMap)
Generate decoy in silico map.
bool isInSwath_(const std::vector< std::pair< double, double > > &swathes, const double precursor_mz, const double product_mz)
Check whether the product m/z of a transition falls into the precursor isolation window.
std::vector< std::string > getMatchingPeptidoforms_(const double fragment_ion, const FragmentSeqMap &ions, const double mz_threshold)
Check whether fragment ion are unique ion signatures in vector within threshold and return matching p...
~MRMAssay() override
Destructor.
void uisTransitionsLight(OpenSwath::LightTargetedExperiment &exp, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, bool enable_specific_losses, bool enable_unspecific_losses, bool enable_ms2_precursors, double mz_threshold, const std::vector< std::pair< double, double > > &swathes, int round_decPow=-4, size_t max_num_alternative_localizations=20, int shuffle_seed=-1, bool disable_decoy_transitions=false)
Annotate UIS / site-specific transitions (light version)
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
A more convenient string class.
Definition String.h:34
A description of a targeted experiment containing precursor and production ions.
Definition TargetedExperiment.h:39
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition TransitionExperiment.h:356