libpappsomspp
Library for mass spectrometry
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
27
29
30namespace pappso
31{
32
33
35 unsigned int isotopeNumber,
36 unsigned int charge,
37 PrecisionPtr precision)
38 : mcsp_peptideSp(peptide),
39 m_isotopeLevel(isotopeNumber),
41 m_z(charge),
42 mp_precision(precision)
43{
44
46
47 double diffC13 = ((double)isotopeNumber * DIFFC12C13) / (double)charge;
48
49 m_averageMz = peptide.get()->getMz(charge) + diffC13;
51}
52
54 unsigned int askedIsotopeRank,
55 unsigned int isotopeLevel,
56 unsigned int charge,
57 PrecisionPtr precision)
59 PeptideNaturalIsotopeList(peptide), askedIsotopeRank, isotopeLevel, charge, precision)
60{
61}
62
64 const PeptideNaturalIsotopeList &isotopeList,
65 unsigned int askedIsotopeRank,
66 unsigned int isotope_number,
67 unsigned int charge,
68 PrecisionPtr precision)
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;
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
104void
106 std::vector<PeptideNaturalIsotopeSp> &v_isotope_list, unsigned int rank)
107{
108 rank++;
109
111 m_averageMz = 0;
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 {
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 {
161 m_averageMz = 0;
162 }
163}
164
167{
168 return std::make_shared<PeptideNaturalIsotopeAverage>(*this);
169}
170
186
190
196
202
203unsigned int
205{
206 return m_z;
207}
208
209unsigned int
214
215unsigned int
220
221const std::vector<PeptideNaturalIsotopeSp> &
226
227const PeptideInterfaceSp &
232
238
239bool
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
248bool
253
254QString
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
bool contains(pappso_double) const
Definition mzrange.cpp:115
std::vector< PeptideNaturalIsotopeSp > m_peptideNaturalIsotopeSpList
PeptideNaturalIsotopeAverage(const PeptideInterfaceSp &peptide, unsigned int isotopeNumber, unsigned int charge, PrecisionPtr precision)
fast constructor simple isotope build, not computing isotope ratio
const std::vector< PeptideNaturalIsotopeSp > & getComponents() const
virtual bool matchPeak(pappso_double peak_mz) const final
const PeptideInterfaceSp & getPeptideInterfaceSp() const
void recursiveDepletion(std::vector< PeptideNaturalIsotopeSp > &v_isotope_list, unsigned int rank)
PeptideNaturalIsotopeAverageSp makePeptideNaturalIsotopeAverageSp() const
std::vector< PeptideNaturalIsotopeSp > getByIsotopeNumber(unsigned int isotopeLevel, unsigned int charge) const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const PeptideNaturalIsotope > PeptideNaturalIsotopeSp
std::shared_ptr< const PeptideInterface > PeptideInterfaceSp
double pappso_double
A type definition for doubles.
Definition types.h:60
std::shared_ptr< const PeptideNaturalIsotopeAverage > PeptideNaturalIsotopeAverageSp
const PrecisionBase * PrecisionPtr
Definition precision.h:122
const pappso_double DIFFC12C13(1.0033548378)