libpappsomspp
Library for mass spectrometry
peptidevariablemodificationreplacement.cpp
Go to the documentation of this file.
1 /**
2  * \file protein/peptidevariablemodificationreplacement.h
3  * \date 5/12/2016
4  * \author Olivier Langella
5  * \brief potential replacement of a modification by an other
6  */
7 /*******************************************************************************
8  * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
9  *
10  * This file is part of the PAPPSOms++ library.
11  *
12  * PAPPSOms++ is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * PAPPSOms++ is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
24  *
25  * Contributors:
26  * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
27  *implementation
28  ******************************************************************************/
29 
31 
32 
33 namespace pappso
34 {
36  AaModificationP mod_before, AaModificationP mod_after)
38 {
39  mp_modAfter = mod_after;
40  /** this forces to check that the targetted modified sites really has the
41  * mod_before */
43 }
44 
47 {
48 }
49 
50 
51 void
53  Peptide &new_peptide, unsigned int position)
54 {
55  // replace all mod_before by mod_after :
56  Aa &aa = new_peptide.getAa(position);
58  unsigned int i = 0;
59  while(i < m_modificationCount)
60  {
62  i++;
63  }
64 }
65 
66 
67 void
69  std::int8_t sequence_database_id,
70  const ProteinSp &protein_sp,
71  bool is_decoy,
72  const PeptideSp &peptide_sp_original,
73  unsigned int start,
74  bool is_nter,
75  unsigned int missed_cleavage_number,
76  bool semi_enzyme)
77 {
78  // QString s = "Banana";
79 
80 
81  bool modify_this_peptide = true;
83  {
84  modify_this_peptide = false;
85  if((m_isProtNterMod) && (is_nter))
86  {
87  // this an Nter peptide
88  modify_this_peptide = true;
89  }
90  else if((m_isProtCterMod) &&
91  (protein_sp.get()->size() ==
92  (start + peptide_sp_original.get()->size())))
93  {
94  // this is a Cter peptide
95  modify_this_peptide = true;
96  }
97  else if(m_isProtElseMod)
98  {
99  modify_this_peptide = true;
100  }
101  }
102 
103  if(modify_this_peptide)
104  {
105  std::vector<unsigned int> position_list;
107  position_list, peptide_sp_original.get(), mp_mod, m_modificationCount);
108 
109  // std::vector< unsigned int > position_list =
110  // peptide_sp_original.get()->getAaPositionList(_aamp_modification_list);
111  // std::string s = "12345";
112  // no AA modification :
113  if(m_minNumberMod == 0)
114  {
115  m_sink->setPeptideSp(sequence_database_id,
116  protein_sp,
117  is_decoy,
118  peptide_sp_original,
119  start,
120  is_nter,
121  missed_cleavage_number,
122  semi_enzyme);
123  }
124 
125  unsigned int nb_pos = position_list.size();
126  if(nb_pos > 0)
127  {
128  // loop to find 1 to n-1 AA modification combinations
129  unsigned int comb_size = 1;
130  while((comb_size < nb_pos) && (comb_size <= m_maxNumberMod))
131  {
132  do
133  {
134  // std::cout << std::string(being,begin + comb_size) <<
135  // std::endl;
136  Peptide new_peptide(*(peptide_sp_original.get()));
137  for(unsigned int i = 0; i < comb_size; i++)
138  {
139  // new_peptide.addAaModification(mp_mod,position_list[i]);
140  this->replaceModificationsAtPosition(new_peptide,
141  position_list[i]);
142  }
143  PeptideSp new_peptide_sp = new_peptide.makePeptideSp();
144  m_sink->setPeptideSp(sequence_database_id,
145  protein_sp,
146  is_decoy,
147  new_peptide_sp,
148  start,
149  is_nter,
150  missed_cleavage_number,
151  semi_enzyme);
152  }
153  while(next_combination(position_list.begin(),
154  position_list.begin() + comb_size,
155  position_list.end()));
156  comb_size++;
157  }
158 
159  if(nb_pos <= m_maxNumberMod)
160  {
161  // the last combination : all aa are modified :
162  Peptide new_peptide(*(peptide_sp_original.get()));
163  for(unsigned int i = 0; i < nb_pos; i++)
164  {
165  // new_peptide.addAaModification(mp_mod,position_list[i]);
166 
167  this->replaceModificationsAtPosition(new_peptide,
168  position_list[i]);
169  }
170  PeptideSp new_peptide_sp = new_peptide.makePeptideSp();
171  m_sink->setPeptideSp(sequence_database_id,
172  protein_sp,
173  is_decoy,
174  new_peptide_sp,
175  start,
176  is_nter,
177  missed_cleavage_number,
178  semi_enzyme);
179  }
180  }
181  }
182  else
183  {
184  // no modification
185  m_sink->setPeptideSp(sequence_database_id,
186  protein_sp,
187  is_decoy,
188  peptide_sp_original,
189  start,
190  is_nter,
191  missed_cleavage_number,
192  semi_enzyme);
193  }
194 }
195 
196 } // namespace pappso
Definition: aa.h:45
void addAaModification(AaModificationP aaModification)
Definition: aa.cpp:150
void removeAaModification(AaModificationP aaModification)
Definition: aa.cpp:137
virtual void getModificationPositionList(std::vector< unsigned int > &position_list, const QString &peptide_str) final
virtual void setPeptideSp(std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideSp &peptide_sp, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme)=0
function to give the products of modifications for a digested peptide
Modify a peptide shared pointer with a variable modification on one AA.
static bool next_combination(const std::vector< unsigned int >::iterator first, std::vector< unsigned int >::iterator k, const std::vector< unsigned int >::iterator last)
PeptideVariableModificationReplacement(AaModificationP mod_before, AaModificationP mod_after)
void replaceModificationsAtPosition(Peptide &new_peptide, unsigned int position)
void setPeptideSp(std::int8_t sequence_database_id, const ProteinSp &protein_sp, bool is_decoy, const PeptideSp &peptide_sp_original, unsigned int start, bool is_nter, unsigned int missed_cleavage_number, bool semi_enzyme) override
function to give the products of modifications for a digested peptide
PeptideSp makePeptideSp() const
Definition: peptide.cpp:125
Aa & getAa(unsigned int position)
Definition: peptide.cpp:535
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp
std::shared_ptr< const Protein > ProteinSp
shared pointer on a Protein object
Definition: protein.h:43
potential replacement of a modification by an other