OpenMS  2.4.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-2018.
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 {
66  class OPENMS_DLLAPI MRMAssay :
67  public ProgressLogger
68  {
69 
70 public:
72  MRMAssay(); // empty, no members
74 
76  ~MRMAssay();
78 
79  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
80  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
81  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
82 
83  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
84 
85  typedef boost::unordered_map<size_t, boost::unordered_map<String, std::set<std::string> > > SequenceMapT;
86  typedef boost::unordered_map<size_t, boost::unordered_map<String, std::vector<std::pair<double, std::string> > > > IonMapT;
87  typedef std::map<String, std::vector<std::pair<std::string, double> > > PeptideMapT;
88  typedef boost::unordered_map<String, String> SequenceMap_T;
89 
90  typedef boost::unordered_map<String, TargetedExperiment::Peptide> TargetDecoyMapT;
91 
105  void reannotateTransitions(OpenMS::TargetedExperiment& exp,
106  double precursor_mz_threshold,
107  double product_mz_threshold,
108  const std::vector<String>& fragment_types,
109  const std::vector<size_t>& fragment_charges,
110  bool enable_specific_losses,
111  bool enable_unspecific_losses,
112  int round_decPow = -4);
113 
124  void restrictTransitions(OpenMS::TargetedExperiment& exp,
125  double lower_mz_limit, double upper_mz_limit,
126  const std::vector<std::pair<double, double> >& swathes);
127 
136  void detectingTransitions(OpenMS::TargetedExperiment& exp, int min_transitions, int max_transitions);
137 
154  void uisTransitions(OpenMS::TargetedExperiment& exp,
155  const std::vector<String>& fragment_types,
156  const std::vector<size_t>& fragment_charges,
157  bool enable_specific_losses,
158  bool enable_unspecific_losses,
159  bool enable_ms2_precursors,
160  double mz_threshold,
161  const std::vector<std::pair<double, double> >& swathes,
162  int round_decPow = -4,
163  size_t max_num_alternative_localizations = 20,
164  int shuffle_seed = -1,
165  bool disable_decoy_transitions = false);
166 
167 protected:
168 
178  std::vector<std::string> getMatchingPeptidoforms_(const double fragment_ion,
179  const std::vector<std::pair<double, std::string> >& ions,
180  const double mz_threshold);
181 
190  int getSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz);
191 
201  bool isInSwath_(const std::vector<std::pair<double, double> >& swathes, const double precursor_mz, const double product_mz);
202 
211  std::string getRandomSequence_(size_t sequence_size, boost::variate_generator<boost::mt19937&, boost::uniform_int<> > pseudoRNG);
212 
221  std::vector<std::vector<size_t> > nchoosekcombinations_(const std::vector<size_t>& n, size_t k);
222 
234  std::vector<OpenMS::AASequence> addModificationsSequences_(const std::vector<OpenMS::AASequence>& sequences,
235  const std::vector<std::vector<size_t> >& mods_combs,
236  const OpenMS::String& modification);
237 
249  std::vector<OpenMS::AASequence> combineModifications_(const OpenMS::AASequence& sequence);
250 
268  std::vector<OpenMS::AASequence> combineDecoyModifications_(const OpenMS::AASequence& sequence, const OpenMS::AASequence& decoy_sequence);
269 
276  void generateTargetInSilicoMap_(const OpenMS::TargetedExperiment& exp,
277  const std::vector<String>& fragment_types,
278  const std::vector<size_t>& fragment_charges,
279  bool enable_specific_losses,
280  bool enable_unspecific_losses,
281  bool enable_ms2_precursors,
282  const std::vector<std::pair<double, double> >& swathes,
283  int round_decPow,
284  size_t max_num_alternative_localizations,
285  SequenceMapT& TargetSequenceMap,
286  IonMapT& TargetIonMap,
287  PeptideMapT& TargetPeptideMap);
288 
295  void generateDecoySequences_(const SequenceMapT& TargetSequenceMap,
296  boost::unordered_map<String, String>& DecoySequenceMap,
297  int shuffle_seed);
298 
305  void generateDecoyInSilicoMap_(const OpenMS::TargetedExperiment& exp,
306  const std::vector<String>& fragment_types,
307  const std::vector<size_t>& fragment_charges,
308  bool enable_specific_losses,
309  bool enable_unspecific_losses,
310  bool enable_ms2_precursors,
311  const std::vector<std::pair<double, double> >& swathes,
312  int round_decPow,
313  TargetDecoyMapT& TargetDecoyMap,
314  PeptideMapT& TargetPeptideMap,
315  boost::unordered_map<String, String>& DecoySequenceMap,
316  IonMapT& DecoyIonMap,
317  PeptideMapT& DecoyPeptideMap);
318 
325  void generateTargetAssays_(const OpenMS::TargetedExperiment& exp,
326  TransitionVectorType& transitions,
327  double mz_threshold,
328  const std::vector<std::pair<double, double> >& swathes,
329  int round_decPow,
330  PeptideMapT& TargetPeptideMap,
331  IonMapT& TargetIonMap);
332 
339  void generateDecoyAssays_(const OpenMS::TargetedExperiment& exp,
340  TransitionVectorType& transitions,
341  double mz_threshold,
342  const std::vector<std::pair<double, double> >& swathes,
343  int round_decPow,
344  const PeptideMapT& DecoyPeptideMap,
345  TargetDecoyMapT& TargetDecoyMap,
346  const IonMapT& DecoyIonMap,
347  const IonMapT& TargetIonMap);
348 
349  };
350 }
351 
const double k
boost::unordered_map< size_t, boost::unordered_map< String, std::set< std::string > > > SequenceMapT
Definition: MRMAssay.h:85
Generate assays from a TargetedExperiment.
Definition: MRMAssay.h:66
A more convenient string class.
Definition: String.h:57
Representation of a peptide/protein sequence.
Definition: AASequence.h:107
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
boost::unordered_map< size_t, boost::unordered_map< String, std::vector< std::pair< double, std::string > > > > IonMapT
Definition: MRMAssay.h:86
std::map< String, std::vector< std::pair< std::string, double > > > PeptideMapT
Definition: MRMAssay.h:87
boost::unordered_map< String, TargetedExperiment::Peptide > TargetDecoyMapT
Definition: MRMAssay.h:90
boost::unordered_map< String, String > SequenceMap_T
Definition: MRMAssay.h:88
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: MRMAssay.h:80
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: MRMAssay.h:79
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: MRMAssay.h:81
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMAssay.h:83