libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
peptidenaturalisotopeaverage.cpp
Go to the documentation of this file.
1
2
/*******************************************************************************
3
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4
*
5
* This file is part of the PAPPSOms++ library.
6
*
7
* PAPPSOms++ is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* PAPPSOms++ is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19
*
20
* Contributors:
21
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22
*implementation
23
******************************************************************************/
24
25
#include "
pappsomspp/core/pappsoexception.h
"
26
#include "
peptidenaturalisotopeaverage.h
"
27
28
#include "
peptidenaturalisotopelist.h
"
29
30
namespace
pappso
31
{
32
33
34
PeptideNaturalIsotopeAverage::PeptideNaturalIsotopeAverage
(
const
PeptideInterfaceSp
&peptide,
35
unsigned
int
isotopeNumber,
36
unsigned
int
charge,
37
PrecisionPtr
precision)
38
:
mcsp_peptideSp
(peptide),
39
m_isotopeLevel
(isotopeNumber),
40
m_isotopeRank
(1),
41
m_z
(charge),
42
mp_precision
(precision)
43
{
44
45
m_peptideNaturalIsotopeSpList
.clear();
46
47
double
diffC13 = ((double)isotopeNumber *
DIFFC12C13
) / (double)charge;
48
49
m_averageMz
= peptide.get()->
getMz
(charge) + diffC13;
50
m_abundanceRatio
= 0;
51
}
52
53
PeptideNaturalIsotopeAverage::PeptideNaturalIsotopeAverage
(
const
PeptideInterfaceSp
&peptide,
54
unsigned
int
askedIsotopeRank,
55
unsigned
int
isotopeLevel,
56
unsigned
int
charge,
57
PrecisionPtr
precision)
58
:
PeptideNaturalIsotopeAverage
(
59
PeptideNaturalIsotopeList
(peptide), askedIsotopeRank, isotopeLevel, charge, precision)
60
{
61
}
62
63
PeptideNaturalIsotopeAverage::PeptideNaturalIsotopeAverage
(
64
const
PeptideNaturalIsotopeList
&isotopeList,
65
unsigned
int
askedIsotopeRank,
66
unsigned
int
isotope_number,
67
unsigned
int
charge,
68
PrecisionPtr
precision)
69
:
mcsp_peptideSp
(isotopeList.
getPeptideInterfaceSp
()),
70
m_isotopeLevel
(isotope_number),
71
m_isotopeRank
(askedIsotopeRank),
72
m_z
(charge),
73
mp_precision
(precision)
74
{
// get the askedIsotopeRank :
75
std::vector<PeptideNaturalIsotopeSp> v_isotope_list(
76
isotopeList.
getByIsotopeNumber
(isotope_number,
m_z
));
77
78
qDebug() <<
"v_isotope_list.size()="
<< v_isotope_list.size() <<
" "
<< isotope_number <<
" "
79
<< askedIsotopeRank;
80
m_abundanceRatio
= 0;
81
m_averageMz
= 0;
82
if
(askedIsotopeRank > v_isotope_list.size())
83
{
84
// there is no isotope at this rank
85
return
;
86
// throw PappsoException(QObject::tr("askedIsotopeRank greater than
87
// v_isotope_list.size() %1 vs
88
// %2").arg(askedIsotopeRank).arg(v_isotope_list.size()));
89
}
90
else
if
(askedIsotopeRank < 1)
91
{
92
throw
PappsoException
(
93
QObject::tr(
"askedIsotopeRank must be 1 or more and not %1"
).arg(askedIsotopeRank));
94
}
95
96
unsigned
int
rank = 0;
97
98
recursiveDepletion
(v_isotope_list, rank);
99
100
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
101
}
102
103
104
void
105
PeptideNaturalIsotopeAverage::recursiveDepletion
(
106
std::vector<PeptideNaturalIsotopeSp> &v_isotope_list,
unsigned
int
rank)
107
{
108
rank++;
109
110
m_abundanceRatio
= 0;
111
m_averageMz
= 0;
112
m_peptideNaturalIsotopeSpList
.clear();
113
std::vector<PeptideNaturalIsotopeSp> peptide_list;
114
// select neighbors in the precision range :
115
MzRange
mz_range(v_isotope_list[0].get()->
getMz
(
m_z
),
mp_precision
);
116
117
for
(
auto
&isotope_sp : v_isotope_list)
118
{
119
if
(mz_range.
contains
(isotope_sp.get()->getMz(
m_z
)))
120
{
121
peptide_list.push_back(isotope_sp);
122
m_abundanceRatio
+= isotope_sp.get()->getIntensityRatio(
m_z
);
123
m_averageMz
+= (isotope_sp.get()->
getMz
(
m_z
) * isotope_sp.get()->getIntensityRatio(
m_z
));
124
}
125
}
126
127
if
(peptide_list.size() > 0)
128
{
129
m_averageMz
=
m_averageMz
/
m_abundanceRatio
;
130
131
// depletion
132
auto
it_remove =
133
std::remove_if(v_isotope_list.begin(),
134
v_isotope_list.end(),
135
[peptide_list](
const
PeptideNaturalIsotopeSp
&isotope_sp) {
136
auto it = std::find(peptide_list.begin(), peptide_list.end(), isotope_sp);
137
return (it != peptide_list.end());
138
});
139
v_isotope_list.erase(it_remove, v_isotope_list.end());
140
141
if
(rank ==
m_isotopeRank
)
142
{
143
m_peptideNaturalIsotopeSpList
= peptide_list;
144
return
;
145
}
146
else
147
{
148
unsigned
int
charge =
m_z
;
149
std::sort(v_isotope_list.begin(),
150
v_isotope_list.end(),
151
[charge](
const
PeptideNaturalIsotopeSp
&m,
const
PeptideNaturalIsotopeSp
&n) {
152
return (m.get()->getIntensityRatio(charge) >
153
n.get()->getIntensityRatio(charge));
154
});
155
recursiveDepletion
(v_isotope_list, rank);
156
}
157
}
158
else
159
{
160
m_abundanceRatio
= 0;
161
m_averageMz
= 0;
162
}
163
}
164
165
PeptideNaturalIsotopeAverageSp
166
PeptideNaturalIsotopeAverage::makePeptideNaturalIsotopeAverageSp
()
const
167
{
168
return
std::make_shared<PeptideNaturalIsotopeAverage>(*
this
);
169
}
170
171
PeptideNaturalIsotopeAverage::PeptideNaturalIsotopeAverage
(
172
const
PeptideNaturalIsotopeAverage
&other)
173
:
mcsp_peptideSp
(other.
mcsp_peptideSp
),
mp_precision
(other.
mp_precision
)
174
{
175
176
qDebug();
177
m_peptideNaturalIsotopeSpList
= other.
m_peptideNaturalIsotopeSpList
;
178
179
m_averageMz
= other.
m_averageMz
;
180
m_abundanceRatio
= other.
m_abundanceRatio
;
181
m_isotopeLevel
= other.
m_isotopeLevel
;
182
m_isotopeRank
= other.
m_isotopeRank
;
183
m_z
= other.
m_z
;
184
qDebug();
185
}
186
187
PeptideNaturalIsotopeAverage::~PeptideNaturalIsotopeAverage
()
188
{
189
}
190
191
pappso_double
192
PeptideNaturalIsotopeAverage::getMz
()
const
193
{
194
return
m_averageMz
;
195
}
196
197
pappso_double
198
PeptideNaturalIsotopeAverage::getIntensityRatio
()
const
199
{
200
return
m_abundanceRatio
;
201
}
202
203
unsigned
int
204
PeptideNaturalIsotopeAverage::getCharge
()
const
205
{
206
return
m_z
;
207
}
208
209
unsigned
int
210
PeptideNaturalIsotopeAverage::getIsotopeNumber
()
const
211
{
212
return
m_isotopeLevel
;
213
}
214
215
unsigned
int
216
PeptideNaturalIsotopeAverage::getIsotopeRank
()
const
217
{
218
return
m_isotopeRank
;
219
}
220
221
const
std::vector<PeptideNaturalIsotopeSp> &
222
PeptideNaturalIsotopeAverage::getComponents
()
const
223
{
224
return
m_peptideNaturalIsotopeSpList
;
225
}
226
227
const
PeptideInterfaceSp
&
228
PeptideNaturalIsotopeAverage::getPeptideInterfaceSp
()
const
229
{
230
return
mcsp_peptideSp
;
231
}
232
233
PrecisionPtr
234
PeptideNaturalIsotopeAverage::getPrecision
()
const
235
{
236
return
mp_precision
;
237
}
238
239
bool
240
PeptideNaturalIsotopeAverage::matchPeak
(
pappso_double
peak_mz)
const
241
{
242
// qDebug() << "PeptideNaturalIsotopeAverage::matchPeak";
243
// qDebug() << "PeptideNaturalIsotopeAverage::matchPeak precision " <<
244
// mp_precision.getDelta(200);
245
return
(
MzRange
(
getMz
(),
mp_precision
).contains(peak_mz));
246
}
247
248
bool
249
PeptideNaturalIsotopeAverage::isEmpty
()
const
250
{
251
return
(
m_peptideNaturalIsotopeSpList
.size() == 0);
252
}
253
254
QString
255
PeptideNaturalIsotopeAverage::toString
()
const
256
{
257
return
QString(
"%1 l%2 mz%3 z%4 N%5"
)
258
.arg(
getPeptideInterfaceSp
().get()->getSequence())
259
.arg(
getPeptideInterfaceSp
().get()->size())
260
.arg(
getMz
())
261
.arg(
getCharge
())
262
.arg(
getIsotopeNumber
());
263
}
264
}
// namespace pappso
pappso::MzRange
Definition
mzrange.h:46
pappso::MzRange::contains
bool contains(pappso_double) const
Definition
mzrange.cpp:115
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::PeptideNaturalIsotopeAverage::~PeptideNaturalIsotopeAverage
virtual ~PeptideNaturalIsotopeAverage()
Definition
peptidenaturalisotopeaverage.cpp:187
pappso::PeptideNaturalIsotopeAverage::m_peptideNaturalIsotopeSpList
std::vector< PeptideNaturalIsotopeSp > m_peptideNaturalIsotopeSpList
Definition
peptidenaturalisotopeaverage.h:87
pappso::PeptideNaturalIsotopeAverage::m_abundanceRatio
pappso_double m_abundanceRatio
Definition
peptidenaturalisotopeaverage.h:90
pappso::PeptideNaturalIsotopeAverage::getIsotopeRank
unsigned int getIsotopeRank() const
Definition
peptidenaturalisotopeaverage.cpp:216
pappso::PeptideNaturalIsotopeAverage::mcsp_peptideSp
const PeptideInterfaceSp mcsp_peptideSp
Definition
peptidenaturalisotopeaverage.h:86
pappso::PeptideNaturalIsotopeAverage::toString
virtual QString toString() const
Definition
peptidenaturalisotopeaverage.cpp:255
pappso::PeptideNaturalIsotopeAverage::PeptideNaturalIsotopeAverage
PeptideNaturalIsotopeAverage(const PeptideInterfaceSp &peptide, unsigned int isotopeNumber, unsigned int charge, PrecisionPtr precision)
fast constructor simple isotope build, not computing isotope ratio
Definition
peptidenaturalisotopeaverage.cpp:34
pappso::PeptideNaturalIsotopeAverage::m_isotopeRank
unsigned int m_isotopeRank
Definition
peptidenaturalisotopeaverage.h:92
pappso::PeptideNaturalIsotopeAverage::getIntensityRatio
pappso_double getIntensityRatio() const
Definition
peptidenaturalisotopeaverage.cpp:198
pappso::PeptideNaturalIsotopeAverage::getComponents
const std::vector< PeptideNaturalIsotopeSp > & getComponents() const
Definition
peptidenaturalisotopeaverage.cpp:222
pappso::PeptideNaturalIsotopeAverage::isEmpty
bool isEmpty() const
Definition
peptidenaturalisotopeaverage.cpp:249
pappso::PeptideNaturalIsotopeAverage::getMz
pappso_double getMz() const
Definition
peptidenaturalisotopeaverage.cpp:192
pappso::PeptideNaturalIsotopeAverage::m_isotopeLevel
unsigned int m_isotopeLevel
Definition
peptidenaturalisotopeaverage.h:91
pappso::PeptideNaturalIsotopeAverage::matchPeak
virtual bool matchPeak(pappso_double peak_mz) const final
Definition
peptidenaturalisotopeaverage.cpp:240
pappso::PeptideNaturalIsotopeAverage::getPeptideInterfaceSp
const PeptideInterfaceSp & getPeptideInterfaceSp() const
Definition
peptidenaturalisotopeaverage.cpp:228
pappso::PeptideNaturalIsotopeAverage::getCharge
unsigned int getCharge() const
Definition
peptidenaturalisotopeaverage.cpp:204
pappso::PeptideNaturalIsotopeAverage::recursiveDepletion
void recursiveDepletion(std::vector< PeptideNaturalIsotopeSp > &v_isotope_list, unsigned int rank)
Definition
peptidenaturalisotopeaverage.cpp:105
pappso::PeptideNaturalIsotopeAverage::getIsotopeNumber
unsigned int getIsotopeNumber() const
Definition
peptidenaturalisotopeaverage.cpp:210
pappso::PeptideNaturalIsotopeAverage::m_averageMz
pappso_double m_averageMz
Definition
peptidenaturalisotopeaverage.h:89
pappso::PeptideNaturalIsotopeAverage::m_z
unsigned int m_z
Definition
peptidenaturalisotopeaverage.h:93
pappso::PeptideNaturalIsotopeAverage::makePeptideNaturalIsotopeAverageSp
PeptideNaturalIsotopeAverageSp makePeptideNaturalIsotopeAverageSp() const
Definition
peptidenaturalisotopeaverage.cpp:166
pappso::PeptideNaturalIsotopeAverage::getPrecision
PrecisionPtr getPrecision() const
Definition
peptidenaturalisotopeaverage.cpp:234
pappso::PeptideNaturalIsotopeAverage::mp_precision
PrecisionPtr mp_precision
Definition
peptidenaturalisotopeaverage.h:94
pappso::PeptideNaturalIsotopeList
Definition
peptidenaturalisotopelist.h:49
pappso::PeptideNaturalIsotopeList::getByIsotopeNumber
std::vector< PeptideNaturalIsotopeSp > getByIsotopeNumber(unsigned int isotopeLevel, unsigned int charge) const
Definition
peptidenaturalisotopelist.cpp:304
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::PeptideNaturalIsotopeSp
std::shared_ptr< const PeptideNaturalIsotope > PeptideNaturalIsotopeSp
Definition
peptidenaturalisotope.h:43
pappso::PeptideInterfaceSp
std::shared_ptr< const PeptideInterface > PeptideInterfaceSp
Definition
peptideinterface.h:40
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition
types.h:60
pappso::PeptideNaturalIsotopeAverageSp
std::shared_ptr< const PeptideNaturalIsotopeAverage > PeptideNaturalIsotopeAverageSp
Definition
peptidenaturalisotopeaverage.h:40
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition
precision.h:122
pappso::DIFFC12C13
const pappso_double DIFFC12C13(1.0033548378)
pappsoexception.h
peptidenaturalisotopeaverage.h
peptidenaturalisotopelist.h
pappsomspp
core
peptide
peptidenaturalisotopeaverage.cpp
Generated on
for libpappsomspp by
1.17.0