OpenMS  3.0.0
MRMAssay.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: George Rosenberger $
32 // $Authors: George Rosenberger $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 
42 #include <boost/random/mersenne_twister.hpp>
43 #include <boost/random/uniform_int.hpp>
44 #include <boost/random/variate_generator.hpp>
45 #include <boost/unordered_map.hpp> // cannot remove this since tests fail otherwise
46 
47 // #define DEBUG_MRMASSAY
48 
49 namespace OpenMS
50 {
66  class OPENMS_DLLAPI MRMAssay :
67  public ProgressLogger
68  {
69 
70 public:
72  MRMAssay(); // empty, no members
74 
76  ~MRMAssay() override;
78 
79  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
80  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
81  typedef std::vector<OpenMS::TargetedExperiment::Compound> CompoundVectorType;
82  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
83 
84  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
85  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > CompoundTransitionMapType;
86 
87  typedef boost::unordered_map<String, std::set<std::string> > ModifiedSequenceMap;
88  typedef boost::unordered_map<size_t, ModifiedSequenceMap> SequenceMapT;
89 
90  typedef std::vector<std::pair<double, std::string> > FragmentSeqMap;
91  typedef boost::unordered_map<size_t, boost::unordered_map<String, FragmentSeqMap > > IonMapT;
92 
93  typedef std::vector<std::pair<std::string, double> > IonSeries;
94  typedef std::map<String, IonSeries > PeptideMapT;
95 
96  typedef boost::unordered_map<String, TargetedExperiment::Peptide> TargetDecoyMapT;
97 
111  void reannotateTransitions(OpenMS::TargetedExperiment& exp,
112  double precursor_mz_threshold,
113  double product_mz_threshold,
114  const std::vector<String>& fragment_types,
115  const std::vector<size_t>& fragment_charges,
116  bool enable_specific_losses,
117  bool enable_unspecific_losses,
118  int round_decPow = -4);
119 
130  void restrictTransitions(OpenMS::TargetedExperiment& exp,
131  double lower_mz_limit, double upper_mz_limit,
132  const std::vector<std::pair<double, double> >& swathes);
133 
142  void detectingTransitions(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
143 
177  void uisTransitions(OpenMS::TargetedExperiment& exp,
178  const std::vector<String>& fragment_types,
179  const std::vector<size_t>& fragment_charges,
180  bool enable_specific_losses,
181  bool enable_unspecific_losses,
182  bool enable_ms2_precursors,
183  double mz_threshold,
184  const std::vector<std::pair<double, double> >& swathes,
185  int round_decPow = -4,
186  size_t max_num_alternative_localizations = 20,
187  int shuffle_seed = -1,
188  bool disable_decoy_transitions = false);
189 
198  void filterMinMaxTransitionsCompound(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
199 
213  void filterUnreferencedDecoysCompound(OpenMS::TargetedExperiment &exp);
214 
215 protected:
216 
226  std::vector<std::string> getMatchingPeptidoforms_(const double fragment_ion,
227  const FragmentSeqMap& ions,
228  const double mz_threshold);
229 
238  int getSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz);
239 
249  bool isInSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz, const double product_mz);
250 
259  std::string getRandomSequence_(size_t sequence_size, boost::variate_generator<boost::mt19937&, boost::uniform_int<> > pseudoRNG);
260 
269  std::vector<std::vector<size_t> > nchoosekcombinations_(const std::vector<size_t>& n, size_t k);
270 
280  std::vector<OpenMS::AASequence> addModificationsSequences_(const std::vector<OpenMS::AASequence>& sequences,
281  const std::vector<std::vector<size_t> >& mods_combs,
282  const OpenMS::String& modification);
283 
295  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoforms_(const OpenMS::AASequence& sequence);
296 
314  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence& sequence, const OpenMS::AASequence& decoy_sequence);
315 
329  void generateTargetInSilicoMap_(const OpenMS::TargetedExperiment& exp,
330  const std::vector<String>& fragment_types,
331  const std::vector<size_t>& fragment_charges,
332  bool enable_specific_losses,
333  bool enable_unspecific_losses,
334  bool enable_ms2_precursors,
335  const std::vector<std::pair<double, double> >& swathes,
336  int round_decPow,
337  size_t max_num_alternative_localizations,
338  SequenceMapT& TargetSequenceMap,
339  IonMapT& TargetIonMap,
340  PeptideMapT& TargetPeptideMap);
341 
351  void generateDecoySequences_(const SequenceMapT& TargetSequenceMap,
352  boost::unordered_map<String, String>& DecoySequenceMap,
353  int shuffle_seed);
354 
366  void generateDecoyInSilicoMap_(const OpenMS::TargetedExperiment& exp,
367  const std::vector<String>& fragment_types,
368  const std::vector<size_t>& fragment_charges,
369  bool enable_specific_losses,
370  bool enable_unspecific_losses,
371  bool enable_ms2_precursors,
372  const std::vector<std::pair<double, double> >& swathes,
373  int round_decPow,
374  TargetDecoyMapT& TargetDecoyMap,
375  PeptideMapT& TargetPeptideMap,
376  boost::unordered_map<String, String>& DecoySequenceMap,
377  IonMapT& DecoyIonMap,
378  PeptideMapT& DecoyPeptideMap);
379 
398  void generateTargetAssays_(const OpenMS::TargetedExperiment& exp,
399  TransitionVectorType& transitions,
400  double mz_threshold,
401  const std::vector<std::pair<double, double> >& swathes,
402  int round_decPow,
403  const PeptideMapT& TargetPeptideMap,
404  const IonMapT& TargetIonMap);
405 
412  void generateDecoyAssays_(const OpenMS::TargetedExperiment& exp,
413  TransitionVectorType& transitions,
414  double mz_threshold,
415  const std::vector<std::pair<double, double> >& swathes,
416  int round_decPow,
417  const PeptideMapT& DecoyPeptideMap,
418  TargetDecoyMapT& TargetDecoyMap,
419  const IonMapT& DecoyIonMap,
420  const IonMapT& TargetIonMap);
421 
422  };
423 }
TargetedExperiment.h
OpenMS::MRMAssay::PeptideTransitionMapType
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMAssay.h:84
OpenMS::MRMAssay::CompoundVectorType
std::vector< OpenMS::TargetedExperiment::Compound > CompoundVectorType
Definition: MRMAssay.h:81
OpenMS::Constants::k
const double k
Definition: Constants.h:153
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MRMAssay::IonSeries
std::vector< std::pair< std::string, double > > IonSeries
Describes an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:93
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::MRMAssay::SequenceMapT
boost::unordered_map< size_t, ModifiedSequenceMap > SequenceMapT
Stores the ModifiedSequenceMap for all SWATH windows.
Definition: MRMAssay.h:88
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
ProgressLogger.h
OpenMS::MRMAssay::PeptideVectorType
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: MRMAssay.h:80
OpenMS::MRMAssay::ProteinVectorType
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: MRMAssay.h:79
MRMIonSeries.h
OpenMS::MRMAssay::FragmentSeqMap
std::vector< std::pair< double, std::string > > FragmentSeqMap
Describes a fragment sequence map of : "fragment m/z" -> "modified sequence".
Definition: MRMAssay.h:90
OpenMS::MRMAssay::PeptideMapT
std::map< String, IonSeries > PeptideMapT
Maps a peptide sequence to an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:94
OpenMS::MRMAssay::CompoundTransitionMapType
std::map< String, std::vector< const ReactionMonitoringTransition * > > CompoundTransitionMapType
Definition: MRMAssay.h:85
ModificationsDB.h
OpenMS::MRMAssay::IonMapT
boost::unordered_map< size_t, boost::unordered_map< String, FragmentSeqMap > > IonMapT
Stores a mapping : "unmodified sequence" -> FragmentSeqMap for all SWATH windows.
Definition: MRMAssay.h:91
OpenMS::AASequence
Representation of a peptide/protein sequence.
Definition: AASequence.h:111
OpenMS::TargetedExperiment
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
OpenMS::MRMAssay
Generate assays from a TargetedExperiment.
Definition: MRMAssay.h:66
OpenMS::MRMAssay::TargetDecoyMapT
boost::unordered_map< String, TargetedExperiment::Peptide > TargetDecoyMapT
Maps the peptide id (same for target and decoy) to the decoy peptide object.
Definition: MRMAssay.h:96
OpenMS::MRMAssay::ModifiedSequenceMap
boost::unordered_map< String, std::set< std::string > > ModifiedSequenceMap
Maps an unmodified sequence to all its modified sequences.
Definition: MRMAssay.h:87
OpenMS::MRMAssay::TransitionVectorType
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: MRMAssay.h:82