OpenMS  2.6.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-2020.
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 
42 
43 #include <boost/bind.hpp>
44 #include <boost/lexical_cast.hpp>
45 #include <boost/random/mersenne_twister.hpp>
46 #include <boost/random/uniform_int.hpp>
47 #include <boost/random/variate_generator.hpp>
48 
49 // #define DEBUG_MRMASSAY
50 
51 namespace OpenMS
52 {
68  class OPENMS_DLLAPI MRMAssay :
69  public ProgressLogger
70  {
71 
72 public:
74  MRMAssay(); // empty, no members
76 
78  ~MRMAssay();
80 
81  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
82  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
83  typedef std::vector<OpenMS::TargetedExperiment::Compound> CompoundVectorType;
84  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
85 
86  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
87  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > CompoundTransitionMapType;
88 
89  typedef boost::unordered_map<String, std::set<std::string> > ModifiedSequenceMap;
90  typedef boost::unordered_map<size_t, ModifiedSequenceMap> SequenceMapT;
91 
92  typedef std::vector<std::pair<double, std::string> > FragmentSeqMap;
93  typedef boost::unordered_map<size_t, boost::unordered_map<String, FragmentSeqMap > > IonMapT;
94 
95  typedef std::vector<std::pair<std::string, double> > IonSeries;
96  typedef std::map<String, IonSeries > PeptideMapT;
97 
98  typedef boost::unordered_map<String, TargetedExperiment::Peptide> TargetDecoyMapT;
99 
113  void reannotateTransitions(OpenMS::TargetedExperiment& exp,
114  double precursor_mz_threshold,
115  double product_mz_threshold,
116  const std::vector<String>& fragment_types,
117  const std::vector<size_t>& fragment_charges,
118  bool enable_specific_losses,
119  bool enable_unspecific_losses,
120  int round_decPow = -4);
121 
132  void restrictTransitions(OpenMS::TargetedExperiment& exp,
133  double lower_mz_limit, double upper_mz_limit,
134  const std::vector<std::pair<double, double> >& swathes);
135 
144  void detectingTransitions(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
145 
179  void uisTransitions(OpenMS::TargetedExperiment& exp,
180  const std::vector<String>& fragment_types,
181  const std::vector<size_t>& fragment_charges,
182  bool enable_specific_losses,
183  bool enable_unspecific_losses,
184  bool enable_ms2_precursors,
185  double mz_threshold,
186  const std::vector<std::pair<double, double> >& swathes,
187  int round_decPow = -4,
188  size_t max_num_alternative_localizations = 20,
189  int shuffle_seed = -1,
190  bool disable_decoy_transitions = false);
191 
200  void detectingTransitionsCompound(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
201 
208  void filterUnreferencedDecoysCompound(OpenMS::TargetedExperiment &exp);
209 
210 protected:
211 
221  std::vector<std::string> getMatchingPeptidoforms_(const double fragment_ion,
222  const FragmentSeqMap& ions,
223  const double mz_threshold);
224 
233  int getSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz);
234 
244  bool isInSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz, const double product_mz);
245 
254  std::string getRandomSequence_(size_t sequence_size, boost::variate_generator<boost::mt19937&, boost::uniform_int<> > pseudoRNG);
255 
264  std::vector<std::vector<size_t> > nchoosekcombinations_(const std::vector<size_t>& n, size_t k);
265 
275  std::vector<OpenMS::AASequence> addModificationsSequences_(const std::vector<OpenMS::AASequence>& sequences,
276  const std::vector<std::vector<size_t> >& mods_combs,
277  const OpenMS::String& modification);
278 
290  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoforms_(const OpenMS::AASequence& sequence);
291 
309  std::vector<OpenMS::AASequence> generateTheoreticalPeptidoformsDecoy_(const OpenMS::AASequence& sequence, const OpenMS::AASequence& decoy_sequence);
310 
324  void generateTargetInSilicoMap_(const OpenMS::TargetedExperiment& exp,
325  const std::vector<String>& fragment_types,
326  const std::vector<size_t>& fragment_charges,
327  bool enable_specific_losses,
328  bool enable_unspecific_losses,
329  bool enable_ms2_precursors,
330  const std::vector<std::pair<double, double> >& swathes,
331  int round_decPow,
332  size_t max_num_alternative_localizations,
333  SequenceMapT& TargetSequenceMap,
334  IonMapT& TargetIonMap,
335  PeptideMapT& TargetPeptideMap);
336 
346  void generateDecoySequences_(const SequenceMapT& TargetSequenceMap,
347  boost::unordered_map<String, String>& DecoySequenceMap,
348  int shuffle_seed);
349 
361  void generateDecoyInSilicoMap_(const OpenMS::TargetedExperiment& exp,
362  const std::vector<String>& fragment_types,
363  const std::vector<size_t>& fragment_charges,
364  bool enable_specific_losses,
365  bool enable_unspecific_losses,
366  bool enable_ms2_precursors,
367  const std::vector<std::pair<double, double> >& swathes,
368  int round_decPow,
369  TargetDecoyMapT& TargetDecoyMap,
370  PeptideMapT& TargetPeptideMap,
371  boost::unordered_map<String, String>& DecoySequenceMap,
372  IonMapT& DecoyIonMap,
373  PeptideMapT& DecoyPeptideMap);
374 
393  void generateTargetAssays_(const OpenMS::TargetedExperiment& exp,
394  TransitionVectorType& transitions,
395  double mz_threshold,
396  const std::vector<std::pair<double, double> >& swathes,
397  int round_decPow,
398  const PeptideMapT& TargetPeptideMap,
399  const IonMapT& TargetIonMap);
400 
407  void generateDecoyAssays_(const OpenMS::TargetedExperiment& exp,
408  TransitionVectorType& transitions,
409  double mz_threshold,
410  const std::vector<std::pair<double, double> >& swathes,
411  int round_decPow,
412  const PeptideMapT& DecoyPeptideMap,
413  TargetDecoyMapT& TargetDecoyMap,
414  const IonMapT& DecoyIonMap,
415  const IonMapT& TargetIonMap);
416 
417  };
418 }
419 
LogStream.h
TargetedExperiment.h
OpenMS::MRMAssay::PeptideTransitionMapType
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMAssay.h:86
OpenMS::MRMAssay::CompoundVectorType
std::vector< OpenMS::TargetedExperiment::Compound > CompoundVectorType
Definition: MRMAssay.h:83
OpenMS::Constants::k
const double k
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::MRMAssay::IonSeries
std::vector< std::pair< std::string, double > > IonSeries
Describes an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:95
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::MRMAssay::SequenceMapT
boost::unordered_map< size_t, ModifiedSequenceMap > SequenceMapT
Stores the ModifiedSequenceMap for all SWATH windows.
Definition: MRMAssay.h:90
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
ProgressLogger.h
OpenMS::MRMAssay::PeptideVectorType
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: MRMAssay.h:82
OpenMS::MRMAssay::ProteinVectorType
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: MRMAssay.h:81
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:92
OpenMS::MRMAssay::PeptideMapT
std::map< String, IonSeries > PeptideMapT
Maps a peptide sequence to an ion series: "ion_type" -> "fragment m/z".
Definition: MRMAssay.h:96
OpenMS::MRMAssay::CompoundTransitionMapType
std::map< String, std::vector< const ReactionMonitoringTransition * > > CompoundTransitionMapType
Definition: MRMAssay.h:87
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:93
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:68
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:98
OpenMS::MRMAssay::ModifiedSequenceMap
boost::unordered_map< String, std::set< std::string > > ModifiedSequenceMap
Maps an unmodified sequence to all its modified sequences.
Definition: MRMAssay.h:89
OpenMS::MRMAssay::TransitionVectorType
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: MRMAssay.h:84