libpappsomspp
Library for mass spectrometry
peptidemodificatorbase.cpp
Go to the documentation of this file.
1 /**
2  * \file protein/peptidemodificatorbase.h
3  * \date 6/12/2016
4  * \author Olivier Langella
5  * \brief base class for all peptide modification builders
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * Contributors:
27  * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
28  *implementation
29  ******************************************************************************/
30 
31 #include "peptidemodificatorbase.h"
32 
33 namespace pappso
34 {
36 {
37 }
38 
40 {
41 }
42 
43 void
45 {
46  m_pattern.setPattern(pattern);
47 }
48 
49 void
51  std::vector<unsigned int> &position_list, const QString &peptide_str)
52 {
53 
54  int pos = 0;
55  while((pos = m_pattern.indexIn(peptide_str, pos)) != -1)
56  {
57  if(m_pattern.pos(1) == -1)
58  {
59  // no motif, just push position
60  position_list.push_back(pos);
61  pos++;
62  }
63  else
64  {
65  // there is a motif : target this position
66  pos = m_pattern.pos(1);
67  if((position_list.size() > 0) &&
68  (position_list.back() == (unsigned int)pos))
69  {
70  pos = m_pattern.pos(0) + 1;
71  }
72  else
73  {
74  position_list.push_back(pos);
75  pos = m_pattern.pos(0) + 1;
76  }
77  }
78  }
79 }
80 
81 void
83  std::vector<unsigned int> &position_list,
84  const Peptide *p_peptide,
85  AaModificationP mod,
86  unsigned int modification_counter)
87 {
88 
89  int pos = 0;
90  const QString peptide_str = p_peptide->getSequence();
91  while((pos = m_pattern.indexIn(peptide_str, pos)) != -1)
92  {
93  if(m_pattern.pos(1) == -1)
94  {
95  // no motif, just push position
96  if(p_peptide->getConstAa(pos).getNumberOfModification(mod) ==
97  modification_counter)
98  {
99  position_list.push_back(pos);
100  }
101  pos++;
102  }
103  else
104  {
105  // there is a motif : target this position
106  pos = m_pattern.pos(1);
107  if((position_list.size() > 0) &&
108  (position_list.back() == (unsigned int)pos))
109  {
110  pos = m_pattern.pos(0) + 1;
111  }
112  else
113  {
114  if(p_peptide->getConstAa(pos).getNumberOfModification(mod) ==
115  modification_counter)
116  {
117  position_list.push_back(pos);
118  }
119  pos = m_pattern.pos(0) + 1;
120  }
121  }
122  }
123 }
124 } // namespace pappso
unsigned int getNumberOfModification(AaModificationP mod) const
Definition: aa.cpp:193
virtual void setModificationPattern(QString &pattern) final
set the pattern on which the modification will be applied (usually the list of concerned AA)
virtual void getModificationPositionList(std::vector< unsigned int > &position_list, const QString &peptide_str) final
const QString getSequence() const override
print amino acid sequence without modifications
Definition: peptide.cpp:139
const Aa & getConstAa(unsigned int position) const
Definition: peptide.cpp:529
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
base class for all peptide modification builders