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
33namespace 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
51void
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
67void
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 // s.replace(QRegExp("a[mn]"), "ox");
80
81
82 bool modify_this_peptide = true;
84 {
85 modify_this_peptide = false;
86 if((m_isProtNterMod) && (is_nter))
87 {
88 // this an Nter peptide
89 modify_this_peptide = true;
90 }
91 else if((m_isProtCterMod) &&
92 (protein_sp.get()->size() ==
93 (start + peptide_sp_original.get()->size())))
94 {
95 // this is a Cter peptide
96 modify_this_peptide = true;
97 }
98 else if(m_isProtElseMod)
99 {
100 modify_this_peptide = true;
101 }
102 }
103
104 if(modify_this_peptide)
105 {
106 std::vector<unsigned int> position_list;
108 position_list, peptide_sp_original.get(), mp_mod, m_modificationCount);
109
110 // std::vector< unsigned int > position_list =
111 // peptide_sp_original.get()->getAaPositionList(_aamp_modification_list);
112 // std::string s = "12345";
113 // no AA modification :
114 if(m_minNumberMod == 0)
115 {
116 m_sink->setPeptideSp(sequence_database_id,
117 protein_sp,
118 is_decoy,
119 peptide_sp_original,
120 start,
121 is_nter,
122 missed_cleavage_number,
123 semi_enzyme);
124 }
125
126 unsigned int nb_pos = position_list.size();
127 if(nb_pos > 0)
128 {
129 // loop to find 1 to n-1 AA modification combinations
130 unsigned int comb_size = 1;
131 while((comb_size < nb_pos) && (comb_size <= m_maxNumberMod))
132 {
133 do
134 {
135 // std::cout << std::string(being,begin + comb_size) <<
136 // std::endl;
137 Peptide new_peptide(*(peptide_sp_original.get()));
138 for(unsigned int i = 0; i < comb_size; i++)
139 {
140 // new_peptide.addAaModification(mp_mod,position_list[i]);
141 this->replaceModificationsAtPosition(new_peptide,
142 position_list[i]);
143 }
144 PeptideSp new_peptide_sp = new_peptide.makePeptideSp();
145 m_sink->setPeptideSp(sequence_database_id,
146 protein_sp,
147 is_decoy,
148 new_peptide_sp,
149 start,
150 is_nter,
151 missed_cleavage_number,
152 semi_enzyme);
153 }
154 while(next_combination(position_list.begin(),
155 position_list.begin() + comb_size,
156 position_list.end()));
157 comb_size++;
158 }
159
160 if(nb_pos <= m_maxNumberMod)
161 {
162 // the last combination : all aa are modified :
163 Peptide new_peptide(*(peptide_sp_original.get()));
164 for(unsigned int i = 0; i < nb_pos; i++)
165 {
166 // new_peptide.addAaModification(mp_mod,position_list[i]);
167
168 this->replaceModificationsAtPosition(new_peptide,
169 position_list[i]);
170 }
171 PeptideSp new_peptide_sp = new_peptide.makePeptideSp();
172 m_sink->setPeptideSp(sequence_database_id,
173 protein_sp,
174 is_decoy,
175 new_peptide_sp,
176 start,
177 is_nter,
178 missed_cleavage_number,
179 semi_enzyme);
180 }
181 }
182 }
183 else
184 {
185 // no modification
186 m_sink->setPeptideSp(sequence_database_id,
187 protein_sp,
188 is_decoy,
189 peptide_sp_original,
190 start,
191 is_nter,
192 missed_cleavage_number,
193 semi_enzyme);
194 }
195}
196
197} // 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:47
potential replacement of a modification by an other