OpenMS  2.7.0
MRMDecoy.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-2021.
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, Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 
42 #include <boost/algorithm/string.hpp>
43 #include <boost/lexical_cast.hpp>
44 #include <boost/assign.hpp>
45 #include <boost/random/mersenne_twister.hpp>
46 #include <boost/random/uniform_int.hpp>
47 #include <boost/random/variate_generator.hpp>
48 #include <boost/unordered_map.hpp>
49 
50 #include <string>
51 #include <vector>
52 #include <map>
53 #include <utility> // for pair
54 
55 // #define DEBUG_MRMDECOY
56 
57 namespace OpenMS
58 {
88  class OPENMS_DLLAPI MRMDecoy :
89  public DefaultParamHandler,
90  public ProgressLogger
91  {
92 
93 public:
94 
95  typedef std::vector<size_t> IndexType;
96 
98 
123  const String& method,
124  const double aim_decoy_fraction,
125  const bool switchKR,
126  const String& decoy_tag,
127  const int max_attempts,
128  const double identity_threshold,
129  const double precursor_mz_shift,
130  const double product_mz_shift,
131  const double product_mz_threshold,
132  const std::vector<String>& fragment_types,
133  const std::vector<size_t>& fragment_charges,
134  const bool enable_specific_losses,
135  const bool enable_unspecific_losses,
136  const int round_decPow = -4) const;
137 
138  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
139  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
140  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
141 
142  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
143 
148  float AASequenceIdentity(const String& sequence, const String& decoy) const;
149 
159  const double identity_threshold,
160  int seed = -1,
161  const int max_attempts = 100) const;
162 
173  const bool keepN,
174  const bool keepC,
175  const String& const_pattern = String());
176 
185  static IndexType findFixedResidues(const std::string& sequence,
186  bool keepN, bool keepC, const OpenMS::String& keep_const_pattern);
187 
188 protected:
189 
193  bool hasCNterminalMods_(const OpenMS::TargetedExperiment::Peptide& peptide, bool checkCterminalAA) const;
194 
200  IndexType findFixedResidues_(const std::string& sequence) const;
201 
207  IndexType findFixedAndTermResidues_(const std::string& sequence) const;
208 
216  const OpenMS::TargetedExperiment::Peptide& peptide) const;
217 
224  const OpenMS::TargetedExperiment::Peptide& peptide) const;
225 
227  void updateMembers_() override;
228 
230  bool keepN_;
231  bool keepC_;
232  };
233 }
234 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
This class generates a TargetedExperiment object with decoys based on a TargetedExperiment object.
Definition: MRMDecoy.h:91
std::vector< size_t > IndexType
Definition: MRMDecoy.h:95
IndexType findFixedResidues_(const std::string &sequence) const
Find all K, R, P sites in a sequence to be set as fixed.
bool keepC_
Definition: MRMDecoy.h:231
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMDecoy.h:142
static IndexType findFixedResidues(const std::string &sequence, bool keepN, bool keepC, const OpenMS::String &keep_const_pattern)
Find all residues in a sequence that should not be reversed / shuffled.
std::vector< OpenMS::ReactionMonitoringTransition > TransitionVectorType
Definition: MRMDecoy.h:140
static OpenMS::TargetedExperiment::Peptide reversePeptide(const OpenMS::TargetedExperiment::Peptide &peptide, const bool keepN, const bool keepC, const String &const_pattern=String())
Reverse a peptide sequence (with its modifications)
IndexType findFixedAndTermResidues_(const std::string &sequence) const
Find all K, R, P and C-/N-terminal sites in a sequence to be set as fixed.
std::vector< OpenMS::TargetedExperiment::Peptide > PeptideVectorType
Definition: MRMDecoy.h:139
String keep_const_pattern_
Definition: MRMDecoy.h:229
bool keepN_
Definition: MRMDecoy.h:230
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: MRMDecoy.h:138
void updateMembers_() override
Synchronize members with param class.
bool hasCNterminalMods_(const OpenMS::TargetedExperiment::Peptide &peptide, bool checkCterminalAA) const
Check if a peptide has C or N terminal modifications.
float AASequenceIdentity(const String &sequence, const String &decoy) const
Compute relative identity (relative number of matches of amino acids at the same position) between tw...
OpenMS::TargetedExperiment::Peptide reversePeptide_(const OpenMS::TargetedExperiment::Peptide &peptide) const
Reverse a peptide sequence (with its modifications)
void generateDecoys(const OpenMS::TargetedExperiment &exp, OpenMS::TargetedExperiment &dec, const String &method, const double aim_decoy_fraction, const bool switchKR, const String &decoy_tag, const int max_attempts, const double identity_threshold, const double precursor_mz_shift, const double product_mz_shift, const double product_mz_threshold, const std::vector< String > &fragment_types, const std::vector< size_t > &fragment_charges, const bool enable_specific_losses, const bool enable_unspecific_losses, const int round_decPow=-4) const
Generate decoys from a TargetedExperiment.
OpenMS::TargetedExperiment::Peptide pseudoreversePeptide_(const OpenMS::TargetedExperiment::Peptide &peptide) const
Pseudo-reverse a peptide sequence (with its modifications)
OpenMS::TargetedExperiment::Peptide shufflePeptide(OpenMS::TargetedExperiment::Peptide peptide, const double identity_threshold, int seed=-1, const int max_attempts=100) const
Shuffle a peptide (with its modifications) sequence.
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A more convenient string class.
Definition: String.h:61
Represents a peptide (amino acid sequence)
Definition: TargetedExperimentHelper.h:360
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:65
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47