OpenMS
ModifiedPeptideGenerator.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
16 #include <vector>
17 #include <map>
18 #include <unordered_map>
19 #include <set>
20 
21 namespace OpenMS
22 {
23  class OPENMS_DLLAPI ModifiedPeptideGenerator
24  {
25  /*
26  * @brief Modifications can be generated and applied to AASequences.
27  */
28 
29  public:
30  // struct needed to wrap the template for pyOpenMS
31  struct MapToResidueType { std::unordered_map<const ResidueModification*, const Residue*> val; };
32 
43  static MapToResidueType getModifications(const StringList& modNames);
44 
45  // Applies fixed modifications to a single peptide
47  const MapToResidueType& fixed_mods,
48  AASequence& peptide);
49 
50  // Applies variable modifications to a single peptide. If keep_original is set the original (e.g. unmodified version) is also returned
52  const MapToResidueType& var_mods,
53  const AASequence& peptide,
54  Size max_variable_mods_per_peptide,
55  std::vector<AASequence>& all_modified_peptides,
56  bool keep_original=true);
57 
58  protected:
59  static const int N_TERM_MODIFICATION_INDEX; // magic constant to distinguish N_TERM only modifications from ANYWHERE modifications placed at N-term residue
60  static const int C_TERM_MODIFICATION_INDEX; // magic constant to distinguish C_TERM only modifications from ANYWHERE modifications placed at C-term residue
61 
62  // Lookup datastructure to allow lock-free generation of modified peptides. Modifications without origin (e.g., "Protein N-term") set the residue to nullptr.
63  static MapToResidueType createResidueModificationToResidueMap_(const std::vector<const ResidueModification*>& mods);
64 
65  // Fast implementation of modification placement. No combinatoric placement is needed in this case - just every site is modified once by each compatible modification. Already modified residues are skipped
67  const MapToResidueType& var_mods,
68  const AASequence& peptide,
69  std::vector<AASequence>& all_modified_peptides,
70  bool keep_original=true);
71 
72  private:
74  static void applyAllModsAtIdxAndExtend_(std::vector<AASequence>& original_sequences, int idx_to_modify, const std::vector<const ResidueModification*>& mods, const MapToResidueType& var_mods);
76  static void applyModToPep_(AASequence& current_peptide, int current_index, const ResidueModification* m, const MapToResidueType& var_mods);
77  };
78 }
Representation of a peptide/protein sequence.
Definition: AASequence.h:86
Definition: ModifiedPeptideGenerator.h:24
static void applyVariableModifications(const MapToResidueType &var_mods, const AASequence &peptide, Size max_variable_mods_per_peptide, std::vector< AASequence > &all_modified_peptides, bool keep_original=true)
std::unordered_map< const ResidueModification *, const Residue * > val
Definition: ModifiedPeptideGenerator.h:31
static const int N_TERM_MODIFICATION_INDEX
Definition: ModifiedPeptideGenerator.h:59
static MapToResidueType getModifications(const StringList &modNames)
Retrieve modifications from strings.
static void applyModToPep_(AASequence &current_peptide, int current_index, const ResidueModification *m, const MapToResidueType &var_mods)
applies a modification m to the current_peptide at current_index. Overwrites mod if it exists....
static void applyAtMostOneVariableModification_(const MapToResidueType &var_mods, const AASequence &peptide, std::vector< AASequence > &all_modified_peptides, bool keep_original=true)
static const int C_TERM_MODIFICATION_INDEX
Definition: ModifiedPeptideGenerator.h:60
static void applyAllModsAtIdxAndExtend_(std::vector< AASequence > &original_sequences, int idx_to_modify, const std::vector< const ResidueModification * > &mods, const MapToResidueType &var_mods)
take a vector of AASequences original_sequences, and for each mod in mods, add a version with mod at ...
static void applyFixedModifications(const MapToResidueType &fixed_mods, AASequence &peptide)
static MapToResidueType createResidueModificationToResidueMap_(const std::vector< const ResidueModification * > &mods)
Definition: ModifiedPeptideGenerator.h:31
Representation of a modification on an amino acid residue.
Definition: ResidueModification.h:53
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22