OpenMS
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-2023.
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 
43 #include <string>
44 #include <utility> // for pair
45 #include <vector>
46 #include <map>
47 
48 // #define DEBUG_MRMDECOY
49 
50 namespace OpenMS
51 {
81  class OPENMS_DLLAPI MRMDecoy :
82  public DefaultParamHandler,
83  public ProgressLogger
84  {
85 
86 public:
87 
88  typedef std::vector<size_t> IndexType;
89 
91 
116  const String& method,
117  const double aim_decoy_fraction,
118  const bool switchKR,
119  const String& decoy_tag,
120  const int max_attempts,
121  const double identity_threshold,
122  const double precursor_mz_shift,
123  const double product_mz_shift,
124  const double product_mz_threshold,
125  const std::vector<String>& fragment_types,
126  const std::vector<size_t>& fragment_charges,
127  const bool enable_specific_losses,
128  const bool enable_unspecific_losses,
129  const int round_decPow = -4) const;
130 
138 
139  typedef std::vector<OpenMS::TargetedExperiment::Protein> ProteinVectorType;
140  typedef std::vector<OpenMS::TargetedExperiment::Peptide> PeptideVectorType;
141  typedef std::vector<OpenMS::ReactionMonitoringTransition> TransitionVectorType;
142 
143  typedef std::map<String, std::vector<const ReactionMonitoringTransition*> > PeptideTransitionMapType;
144 
149  float AASequenceIdentity(const String& sequence, const String& decoy) const;
150 
160  const double identity_threshold,
161  int seed = -1,
162  const int max_attempts = 100) const;
163 
174  const bool keepN,
175  const bool keepC,
176  const String& const_pattern = String());
177 
186  static IndexType findFixedResidues(const std::string& sequence,
187  bool keepN, bool keepC, const OpenMS::String& keep_const_pattern);
188 
189 protected:
190 
194  bool hasCNterminalMods_(const OpenMS::TargetedExperiment::Peptide& peptide, bool checkCterminalAA) const;
195 
201  IndexType findFixedResidues_(const std::string& sequence) const;
202 
208  IndexType findFixedAndTermResidues_(const std::string& sequence) const;
209 
217  const OpenMS::TargetedExperiment::Peptide& peptide) const;
218 
225  const OpenMS::TargetedExperiment::Peptide& peptide) const;
226 
231 
233  void updateMembers_() override;
234 
236  bool keepN_;
237  bool keepC_;
238  };
239 }
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
This class generates a TargetedExperiment object with decoys based on a TargetedExperiment object.
Definition: MRMDecoy.h:84
std::vector< size_t > IndexType
Definition: MRMDecoy.h:88
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:237
std::map< String, std::vector< const ReactionMonitoringTransition * > > PeptideTransitionMapType
Definition: MRMDecoy.h:143
String getModifiedPeptideSequence_(const OpenMS::TargetedExperiment::Peptide &pep) const
Convert a peptide to a string which contains the peptide sequence and modifications.
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:141
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:140
String keep_const_pattern_
Definition: MRMDecoy.h:235
void switchKR(OpenMS::TargetedExperiment::Peptide &peptide) const
Switch the final Amino Acid of a tryptic peptide. E.g. If the last Amino Acid is "K" switch to "R" (a...
bool keepN_
Definition: MRMDecoy.h:236
std::vector< OpenMS::TargetedExperiment::Protein > ProteinVectorType
Definition: MRMDecoy.h:139
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:53
A more convenient string class.
Definition: String.h:60
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:48