libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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
32
33namespace pappso
34{
38
42
43void
45{
46 m_pattern.setPattern(pattern);
47}
48
49void
51 std::vector<unsigned int> &position_list, const QString &peptide_str)
52{
53
54 int pos = 0;
55 QRegularExpressionMatch match_pattern = m_pattern.match(peptide_str, pos);
56
57 while(match_pattern.hasMatch())
58 {
59 pos = match_pattern.capturedStart(0);
60 if(match_pattern.lastCapturedIndex() == 0)
61 {
62 // no motif, just push position
63 position_list.push_back(pos);
64 pos++;
65 }
66 else
67 {
68 // there is a motif : target this position
69 pos = match_pattern.capturedStart(1);
70 if((position_list.size() > 0) &&
71 (position_list.back() == (unsigned int)pos))
72 {
73 pos = match_pattern.capturedStart(0) + 1;
74 }
75 else
76 {
77 position_list.push_back(pos);
78 pos = match_pattern.capturedStart(0) + 1;
79 }
80 }
81 match_pattern = m_pattern.match(peptide_str, pos);
82 }
83}
84
85void
87 std::vector<unsigned int> &position_list,
88 const Peptide *p_peptide,
90 unsigned int modification_counter)
91{
92
93 int pos = 0;
94 const QString peptide_str = p_peptide->getSequence();
95 QRegularExpressionMatch match_pattern = m_pattern.match(peptide_str, pos);
96
97 while(match_pattern.hasMatch())
98 {
99 pos = match_pattern.capturedStart(0);
100 if(match_pattern.lastCapturedIndex() == 0)
101 {
102 // no motif, just push position
103 if(p_peptide->getConstAa(pos).getNumberOfModification(mod) ==
104 modification_counter)
105 {
106 position_list.push_back(pos);
107 }
108 pos++;
109 }
110 else
111 {
112 // there is a motif : target this position
113 pos = match_pattern.capturedStart(1);
114 if((position_list.size() > 0) &&
115 (position_list.back() == (unsigned int)pos))
116 {
117 pos = match_pattern.capturedStart(0) + 1;
118 }
119 else
120 {
121 if(p_peptide->getConstAa(pos).getNumberOfModification(mod) ==
122 modification_counter)
123 {
124 position_list.push_back(pos);
125 }
126 pos = match_pattern.capturedStart(0) + 1;
127 }
128 }
129 match_pattern = m_pattern.match(peptide_str, pos);
130 }
131}
132} // namespace pappso
unsigned int getNumberOfModification(AaModificationP mod) const
Definition aa.cpp:233
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:222
const Aa & getConstAa(unsigned int position) const
Definition peptide.cpp:612
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