OpenMS
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 
15 
16 #include <boost/random/mersenne_twister.hpp>
17 #include <boost/random/uniform_int.hpp>
18 #include <boost/random/variate_generator.hpp>
19 
20 // #define DEBUG_MRMASSAY
21 
22 namespace OpenMS
23 {
39  class OPENMS_DLLAPI MRMAssay :
40  public ProgressLogger
41  {
42 
43 public:
45  MRMAssay(); // empty, no members
47 
49  ~MRMAssay() override;
51 
52  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
53  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
54  typedef std::vector<OpenMS::TargetedExperiment::Compound> CompoundVectorType;
55  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
56 
57  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
58  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > CompoundTransitionMapType;
59 
60  typedef std::map<String, std::set<std::string> > ModifiedSequenceMap;
61  typedef std::map<size_t, ModifiedSequenceMap> SequenceMapT;
62 
63  typedef std::vector<std::pair<double, std::string> > FragmentSeqMap;
64  typedef std::map<size_t, std::map<String, FragmentSeqMap > > IonMapT;
65 
66  typedef std::vector<std::pair<std::string, double> > IonSeries;
67  typedef std::map<String, IonSeries > PeptideMapT;
68 
69  typedef std::map<String, TargetedExperiment::Peptide> TargetDecoyMapT;
70 
85  double precursor_mz_threshold,
86  double product_mz_threshold,
87  const std::vector<String>& fragment_types,
88  const std::vector<size_t>& fragment_charges,
89  bool enable_specific_losses,
90  bool enable_unspecific_losses,
91  int round_decPow = -4);
92 
104  double lower_mz_limit, double upper_mz_limit,
105  const std::vector<std::pair<double, double> >& swathes);
106 
115  void detectingTransitions(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
116 
151  const std::vector<String>& fragment_types,
152  const std::vector<size_t>& fragment_charges,
153  bool enable_specific_losses,
154  bool enable_unspecific_losses,
155  bool enable_ms2_precursors,
156  double mz_threshold,
157  const std::vector<std::pair<double, double> >& swathes,
158  int round_decPow = -4,
159  size_t max_num_alternative_localizations = 20,
160  int shuffle_seed = -1,
161  bool disable_decoy_transitions = false);
162 
171  void filterMinMaxTransitionsCompound(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
172 
187 
188 protected:
189 
199  std::vector<std::string> getMatchingPeptidoforms_(const double fragment_ion,
200  const FragmentSeqMap& ions,
201  const double mz_threshold);
202 
211  int getSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz);
212 
222  bool isInSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz, const double product_mz);
223 
232  std::string getRandomSequence_(size_t sequence_size, boost::variate_generator<boost::mt19937&, boost::uniform_int<> > pseudoRNG);
233 
242  std::vector<std::vector<size_t> > nchoosekcombinations_(const std::vector<size_t>& n, size_t k);
243 
253  std::vector<OpenMS::AASequence> addModificationsSequences_(const std::vector<OpenMS::AASequence>& sequences,
254  const std::vector<std::vector<size_t> >& mods_combs,
255  const OpenMS::String& modification);
256 
268  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoforms_(const OpenMS::AASequence& sequence);
269 
287  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence& sequence, const OpenMS::AASequence& decoy_sequence);
288 
303  const std::vector<String>& fragment_types,
304  const std::vector<size_t>& fragment_charges,
305  bool enable_specific_losses,
306  bool enable_unspecific_losses,
307  bool enable_ms2_precursors,
308  const std::vector<std::pair<double, double> >& swathes,
309  int round_decPow,
310  size_t max_num_alternative_localizations,
311  SequenceMapT& TargetSequenceMap,
312  IonMapT& TargetIonMap,
313  PeptideMapT& TargetPeptideMap);
314 
324  void generateDecoySequences_(const SequenceMapT& TargetSequenceMap,
325  std::map<String, String>& DecoySequenceMap,
326  int shuffle_seed);
327 
340  const std::vector<String>& fragment_types,
341  const std::vector<size_t>& fragment_charges,
342  bool enable_specific_losses,
343  bool enable_unspecific_losses,
344  bool enable_ms2_precursors,
345  const std::vector<std::pair<double, double> >& swathes,
346  int round_decPow,
347  TargetDecoyMapT& TargetDecoyMap,
348  PeptideMapT& TargetPeptideMap,
349  std::map<String, String>& DecoySequenceMap,
350  IonMapT& DecoyIonMap,
351  PeptideMapT& DecoyPeptideMap);
352 
372  TransitionVectorType& transitions,
373  double mz_threshold,
374  const std::vector<std::pair<double, double> >& swathes,
375  int round_decPow,
376  const PeptideMapT& TargetPeptideMap,
377  const IonMapT& TargetIonMap);
378 
386  TransitionVectorType& transitions,
387  double mz_threshold,
388  const std::vector<std::pair<double, double> >& swathes,
389  int round_decPow,
390  const PeptideMapT& DecoyPeptideMap,
391  TargetDecoyMapT& TargetDecoyMap,
392  const IonMapT& DecoyIonMap,
393  const IonMapT& TargetIonMap);
394 
395  };
396 }
Representation of a peptide/protein sequence.
Definition: AASequence.h:86
Generate assays from a TargetedExperiment.
Definition: MRMAssay.h:41
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.
std::vector< OpenMS::AASequence > generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence &sequence, const OpenMS::AASequence &decoy_sequence)
Generate alternative modified peptide forms according to ModificationsDB.
std::map< String, TargetedExperiment::Peptide > TargetDecoyMapT
Maps the peptide id (same for target and decoy) to the decoy peptide object.
Definition: MRMAssay.h:69
std::vector< OpenMS::TargetedExperiment::Compound > CompoundVectorType
Definition: MRMAssay.h:54
std::vector< std::vector< size_t > > nchoosekcombinations_(const std::vector< size_t > &n, size_t k)
Computes all N choose K combinations.
void detectingTransitions(OpenMS::TargetedExperiment &exp, int min_transitions, int max_transitions)
Select detecting fragment ions.
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, std::vector< const ReactionMonitoringTransition * > > CompoundTransitionMapType
Definition: MRMAssay.h:58
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.
std::map< size_t, ModifiedSequenceMap > SequenceMapT
Stores the ModifiedSequenceMap for all SWATH windows (uses std::map for deterministic iteration order...
Definition: MRMAssay.h:61
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMAssay.h:57
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.
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:55
std::vector< std::pair< double, std::string > > FragmentSeqMap
Describes a fragment sequence map of : "fragment m/z" -> "modified sequence".
Definition: MRMAssay.h:63
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:53
std::vector< std::pair< std::string, double > > IonSeries
Describes an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:66
std::vector< OpenMS::AASequence > generateTheoreticalPeptidoforms_(const OpenMS::AASequence &sequence)
Generate alternative modified peptide forms according to ModificationsDB.
void filterMinMaxTransitionsCompound(OpenMS::TargetedExperiment &exp, int min_transitions, int max_transitions)
Filters target and decoy transitions by intensity, only keeping the top N transitions.
std::map< String, std::set< std::string > > ModifiedSequenceMap
Maps an unmodified sequence to all its modified sequences.
Definition: MRMAssay.h:60
std::map< String, IonSeries > PeptideMapT
Maps a peptide sequence to an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:67
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:52
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:64
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.
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...
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.
~MRMAssay() override
Destructor.
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
const double k
Definition: Constants.h:132
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19