libpappsomspp
Library for mass spectrometry
xtandemspectrumprocess.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/psm/xtandem/xtandemhyperscore.cpp
3  * \date 16/8/2016
4  * \author Olivier Langella
5  * \brief process spectrum to compute X!Tandem hyperscore
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 "xtandemspectrumprocess.h"
32 #include <QDebug>
33 
34 namespace pappso
35 {
36 
38  : m_filter_keep_greater(150),
39  m_n_most_intense(100),
40  m_filter_rescale(100),
41  m_filter_highpass(0.9)
42 {
43 }
44 
46  const XtandemSpectrumProcess &copy)
47  : m_filter_keep_greater(copy.m_filter_keep_greater),
48  m_n_most_intense(copy.m_n_most_intense),
49  m_filter_rescale(copy.m_filter_rescale),
50  m_filter_highpass(copy.m_filter_highpass)
51 {
56 
61  _y_ions = copy._y_ions; // PeptideIon::y
62  _b_ions = copy._b_ions; // PeptideIon::b
63  _ystar_ions = copy._ystar_ions; // PeptideIon::ystar
64  _bstar_ions = copy._bstar_ions; // PeptideIon::bstar
65  _c_ions = copy._c_ions; // PeptideIon::c
66  _z_ions = copy._z_ions; // PeptideIon::z
67  _a_ions = copy._a_ions; // PeptideIon::a
68  _x_ions = copy._x_ions; // CO2
69 
70  _astar_ions = copy._astar_ions; // PeptideIon::a
71  _ao_ions = copy._ao_ions;
72  _bo_ions = copy._bo_ions;
73  _yo_ions = copy._yo_ions;
74 }
76 {
77 }
78 
79 void
81 {
83 }
84 void
85 XtandemSpectrumProcess::setNmostIntense(unsigned int nmost_intense)
86 {
87  m_n_most_intense = FilterGreatestY(nmost_intense);
88 }
89 void
91 {
92  m_filter_rescale = FilterRescaleY(dynamic_range);
93 }
94 
95 void
97 {
98  m_isRemoveIsotope = remove_isotope;
99 }
100 
101 void
103 {
104  m_isExcludeParent = exclude_parent;
105 }
106 void
108 {
109  m_isExcludeParent_neutral_loss = neutral_loss;
110 }
111 void
113  pappso::pappso_double neutral_loss_mass)
114 {
115  m_neutralLossMass = neutral_loss_mass;
116 }
117 void
119  pappso_double neutral_loss_precision)
120 {
121  m_neutralLossWindowDalton = neutral_loss_precision;
122 }
123 
124 
125 void
127 {
128  m_isRefineSpectrumModel = refine;
129 }
130 
131 // FIXME: enumeration values 'bp' and 'yp' not handled in switch
132 void
133 XtandemSpectrumProcess::setIonScore(PeptideIon ion_type, bool compute_score)
134 {
135  switch(ion_type)
136  {
137  case PeptideIon::y:
138  _y_ions = compute_score;
139  break;
140 
141  case PeptideIon::b:
142  _b_ions = compute_score;
143  break;
144 
145  case PeptideIon::ystar:
146  _ystar_ions = compute_score;
147  break;
148 
149  case PeptideIon::bstar:
150  _bstar_ions = compute_score;
151  break;
152 
153  case PeptideIon::yo:
154  _yo_ions = compute_score;
155  break;
156 
157  case PeptideIon::bo:
158  _bo_ions = compute_score;
159  break;
160 
161  case PeptideIon::z:
162  _z_ions = compute_score;
163  break;
164 
165  case PeptideIon::a:
166  _a_ions = compute_score;
167  break;
168 
169  case PeptideIon::astar:
170  _astar_ions = compute_score;
171  break;
172  case PeptideIon::ao:
173  _ao_ions = compute_score;
174  break;
175  case PeptideIon::c:
176  _c_ions = compute_score;
177  break;
178  case PeptideIon::x:
179  _x_ions = compute_score;
180  break;
181 
182  case PeptideIon::bp:
183  case PeptideIon::yp:
184  break;
185  }
186 }
187 
190 {
192 }
193 unsigned int
195 {
197 }
200 {
202 }
203 bool
205 {
206  return m_isRemoveIsotope;
207 }
208 bool
210 {
211  return m_isExcludeParent;
212 }
213 bool
215 {
217 }
220 {
221  return m_neutralLossMass;
222 }
225 {
227 }
228 
229 bool
231 {
233 }
234 
235 // FIXME: enumeration values 'bp' and 'yp' not handled in switch
236 bool
238 {
239  switch(ion_type)
240  {
241  case PeptideIon::y:
242  return _y_ions;
243 
244  case PeptideIon::b:
245  return _b_ions;
246 
247  case PeptideIon::ystar:
248  return _ystar_ions;
249 
250  case PeptideIon::bstar:
251  return _bstar_ions;
252 
253  case PeptideIon::yo:
254  return _yo_ions;
255 
256  case PeptideIon::bo:
257  return _bo_ions;
258 
259  case PeptideIon::z:
260  return _z_ions;
261 
262  case PeptideIon::a:
263  return _a_ions;
264 
265  case PeptideIon::astar:
266  return _astar_ions;
267  case PeptideIon::ao:
268  return _ao_ions;
269 
270  case PeptideIon::c:
271  return _c_ions;
272  case PeptideIon::x:
273  return _x_ions;
274  default:
275  break;
276  }
277  return false;
278 }
279 
282  pappso_double parent_ion_mz,
283  unsigned int parent_charge) const
284 {
285  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
286  << " parent_charge==" << parent_charge;
287 
288  // 1) clean isotopes
289  MassSpectrum spectrum_process(spectrum);
291  {
292  spectrum_process.massSpectrumFilter(FilterTandemDeisotope());
293  }
294  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
295  // 2) remove parent ion mass
297  {
298  spectrum_process.massSpectrumFilter(
300  MzRange(parent_ion_mz,
302  m_isExcludeParent_lower_dalton / parent_charge),
304  m_isExcludeParent_upper_dalton / parent_charge))));
305  }
306  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() ";
307  // 3) remove low masses
308  // 4) normalization
309  m_filter_keep_greater.filter(spectrum_process);
310  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
311  m_filter_rescale.filter(spectrum_process);
312  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
313  // m_filter_floor.filter(spectrum_process);
314  m_filter_highpass.filter(spectrum_process);
315 
316  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
317  // 5) remove neutral loss
319  {
320  pappso_double parent_ion_mhplus =
321  ((parent_ion_mz - (MHPLUS * parent_charge)) * parent_charge) + MHPLUS;
322 
324  parent_ion_mhplus - m_neutralLossMass,
326 
327  filter_parent.filter(spectrum_process);
328  }
329  // 6) clean isotopes
330  // 7) keep n most intense peaks
331  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__
332  << " parent_charge==" << parent_charge;
333  // return spectrum_process.massSpectrumFilter(m_filter_remove_c13)
334  // .filter(m_nMostIntense);
335 
336  m_filter_remove_c13.filter(spectrum_process);
337  m_n_most_intense.filter(spectrum_process);
338  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() "
339  << spectrum_process.size();
340  return spectrum_process;
341 }
342 
343 
344 } // namespace pappso
keep N datapoints form the greatest intensities to the lowest
Definition: filterpass.h:96
Trace & filter(Trace &data_points) const override
Definition: filterpass.cpp:168
std::size_t getNumberOfPoints() const
Definition: filterpass.cpp:193
Trace & filter(Trace &data_points) const override
Definition: filterpass.cpp:91
Trace & filter(Trace &trace) const override
rescales Y values into a dynamic range if the dynamic range is set to 0, this filter is ignored
Definition: filterpass.h:196
Trace & filter(Trace &data_points) const override
Definition: filterpass.cpp:371
double getDynamicRange() const
Definition: filterpass.cpp:396
Deisotope the mass spectrum this mass spectrum is iterated over and according to a data point-based m...
MassSpectrum & filter(MassSpectrum &data_points) const override
MassSpectrum & filter(MassSpectrum &spectrum) const override
Class to represent a mass spectrum.
Definition: massspectrum.h:71
virtual MassSpectrum & massSpectrumFilter(const MassSpectrumFilterInterface &filter) final
apply a filter on this MassSpectrum
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition: precision.cpp:130
pappso::pappso_double m_isExcludeParent_upper_dalton
void setRemoveIsotope(bool remove_isotope)
pappso::pappso_double getDynamicRange() const
FilterResampleKeepGreater m_filter_keep_greater
void setIonScore(PeptideIon ion_type, bool compute_score)
pappso::pappso_double getNeutralLossMass() const
pappso::pappso_double m_isExcludeParent_lower_dalton
void setExcludeParentNeutralLoss(bool neutral_loss)
void setNeutralLossMass(pappso::pappso_double neutral_loss_mass)
bool getIonScore(PeptideIon ion_type) const
pappso::pappso_double m_neutralLossMass
FilterTandemDeisotope m_filter_remove_c13
void setMinimumMz(pappso_double minimum_mz)
void setNeutralLossWindowDalton(pappso::pappso_double neutral_loss_precision)
pappso::pappso_double getNeutralLossWindowDalton() const
void setDynamicRange(pappso::pappso_double dynamic_range)
pappso::pappso_double m_neutralLossWindowDalton
MassSpectrum process(const MassSpectrum &spectrum, pappso_double parent_ion_mass, unsigned int parent_charge) const
process raw spectrum to prepare hyperscore computation
void setExcludeParent(bool exclude_parent)
void setNmostIntense(unsigned int nmost_intense)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition: types.h:386
@ a
Nter aldimine ions.
@ y
Cter amino ions.
@ c
Nter amino ions.
@ astar
Nter aldimine ions + NH3 loss.
@ ystar
Cter amino ions + NH3 loss.
@ yo
Cter amino ions + H2O loss.
@ bstar
Nter acylium ions + NH3 loss.
@ b
Nter acylium ions.
@ x
Cter acylium ions.
@ bo
Nter acylium ions + H2O loss.
@ ao
Nter aldimine ions + H2O loss.
@ z
Cter carbocations.
const pappso_double MHPLUS(1.007276466879)
double pappso_double
A type definition for doubles.
Definition: types.h:49