libpappsomspp
Library for mass spectrometry
peptidefragmention.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/peptide/peptidefragmention.cpp
3  * \date 10/3/2015
4  * \author Olivier Langella
5  * \brief peptide ion model
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2015 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 <QDebug>
32 #include "peptidefragmention.h"
33 #include "../pappsoexception.h"
36 
37 namespace pappso
38 {
40  PeptideIon ion_type)
41  : PeptideFragmentIon(sp_fragment, ion_type, 0)
42 {
43 }
44 
46  const PeptideFragmentSp &sp_fragment,
47  PeptideIon ion_type,
48  unsigned int number_of_neutral_phospho_loss)
49  : msp_fragment(sp_fragment), m_ionType(ion_type)
50 {
51  m_mass = msp_fragment.get()->getMass();
52  PeptideDirection direction = msp_fragment.get()->getPeptideIonDirection();
54  {
55  throw PappsoException(
56  QString("PeptideIon %1 is not an %2 fragment")
59  }
60  m_mass -= MASSH2O;
61  switch(m_ionType)
62  {
63  // -MASSH2O
64  case PeptideIon::yp:
65  m_neutralPhosphoLossNumber = number_of_neutral_phospho_loss;
66  m_mass -=
68  ion_type = PeptideIon::y;
69  break;
70  case PeptideIon::bp:
71  m_neutralPhosphoLossNumber = number_of_neutral_phospho_loss;
72  m_mass -=
74  ion_type = PeptideIon::b;
75  break;
76  default:
77  break;
78  }
80 }
81 
83  : msp_fragment(other.msp_fragment), m_ionType(other.m_ionType)
84 {
85  m_mass = other.m_mass;
86 }
87 
88 
90  PeptideFragmentIon &&toCopy) // move constructor
91  : msp_fragment(std::move(toCopy.msp_fragment)),
92  m_ionType(toCopy.m_ionType),
93  m_mass(toCopy.m_mass)
94 {
95 }
96 
98 {
99 }
100 
101 
104 {
105  return pappso::getPeptideIonDirection(ion_type);
106 }
107 
108 const QString
110 {
112  {
114  }
116 }
117 
118 const QString
120 {
121  switch(m_ionType)
122  {
123  case PeptideIon::y:
124  return "y";
125  break;
126  case PeptideIon::yp:
127  return "yP";
128  break;
129  case PeptideIon::ystar:
130  return "y*";
131  break;
132  case PeptideIon::yo:
133  return "yO";
134  break;
135  case PeptideIon::bstar:
136  return "b*";
137  break;
138  case PeptideIon::bo:
139  return "bO";
140  break;
141  case PeptideIon::a:
142  return "a";
143  break;
144  case PeptideIon::astar:
145  return "a*";
146  break;
147  case PeptideIon::ao:
148  return "aO";
149  break;
150  case PeptideIon::c:
151  return "c";
152  break;
153  // SvgIon.moxygen - mN
154  case PeptideIon::z:
155  return "z";
156  break;
157  case PeptideIon::b:
158  return "b";
159  break;
160  case PeptideIon::bp:
161  return "bP";
162  break;
163  case PeptideIon::x:
164  return "x";
165  break;
166  default:
167  throw PappsoException(QString("PeptideIon name not implemented"));
168  break;
169  }
170 }
171 
172 const QColor
174 {
175  switch(m_ionType)
176  {
177  case PeptideIon::y:
178  return QColor("red");
179  break;
180  case PeptideIon::yp:
181  return QColor("red");
182  break;
183  case PeptideIon::ystar:
184  return QColor("red");
185  break;
186  case PeptideIon::yo:
187  return QColor("orange");
188  break;
189  case PeptideIon::x:
190  return QColor("orange");
191  break;
192  case PeptideIon::bstar:
193  return QColor("blue");
194  break;
195  case PeptideIon::bo:
196  return QColor("#ff00ff");
197  break;
198  case PeptideIon::a:
199  return QColor("green");
200  break;
201  case PeptideIon::astar:
202  return QColor("green");
203  break;
204  case PeptideIon::ao:
205  return QColor("green");
206  break;
207  case PeptideIon::c:
208  return QColor("blue");
209  break;
210  // SvgIon.moxygen - mN
211  case PeptideIon::z:
212  return QColor("red");
213  break;
214  case PeptideIon::b:
215  return QColor("blue");
216  break;
217  case PeptideIon::bp:
218  return QColor("blue");
219  break;
220  default:
221  throw PappsoException(QString("PeptideIon color not implemented %1")
223  break;
224  }
225 }
226 
227 int
229 {
230  int number = msp_fragment.get()->getNumberOfAtom(atom);
231  int diff = 0;
232  switch(atom)
233  {
235  switch(m_ionType)
236  {
237  case PeptideIon::y:
238  break;
239  case PeptideIon::yp:
240  // H 1 O 3 P 1 + H 2 0
241  break;
242  case PeptideIon::ystar:
243  // m_mass -= MASSNH3;
244  break;
245  case PeptideIon::yo:
246  // m_mass -= MASSH2O;
247  break;
248  case PeptideIon::bstar:
249  // m_mass -= MASSH2O;
250  // m_mass -= MASSNH3;
251  break;
252  case PeptideIon::bo:
253  // m_mass -= MASSH2O;
254  // m_mass -= MASSH2O;
255  break;
256  case PeptideIon::a:
257  // m_mass -= MASSH2O;
258  // m_mass -= MASSCO;
259  diff = -1;
260  break;
261  case PeptideIon::c:
262  // m_mass += MASSNH3;
263  break;
264  // SvgIon.moxygen - mN
265  case PeptideIon::z:
266  // m_mass -= MASSH2O;
267  // m_mass += MASSOXYGEN - MASSNITROGEN - MPROTIUM;
268  break;
269  case PeptideIon::b:
270  // m_mass -= MASSH2O;
271  break;
272  case PeptideIon::bp:
273  // H 1 O 3 P 1 + H 2 0
274  break;
275 
276  case PeptideIon::astar:
277  // m_mass -= MASSH2O;
278  // m_mass = - MASSCO - MASSNH3;
279  diff = -1;
280  break;
281  case PeptideIon::ao:
282  // m_mass -= MASSH2O;
283  // m_mass = - MASSCO - MASSH2O;
284  diff = -1;
285  break;
286  case PeptideIon::x:
287  // +MASSCO + MASSOXYGEN
288  diff = +1;
289  break;
290  default:
291  throw PappsoException(QString("PeptideIon name not implemented"));
292  break;
293  }
294  break;
296  switch(m_ionType)
297  {
298  case PeptideIon::y:
299  break;
300  case PeptideIon::yp:
301  // H 1 O 3 P 1 + H 2 0
302  diff = -3 * m_neutralPhosphoLossNumber;
303  break;
304  case PeptideIon::ystar:
305  // m_mass -= MASSNH3;
306  diff = -3;
307  break;
308  case PeptideIon::yo:
309  // m_mass -= MASSH2O;
310  diff = -2;
311  break;
312  case PeptideIon::bstar:
313  // m_mass -= MASSH2O;
314  // m_mass -= MASSNH3;
315  diff = -5;
316  break;
317  case PeptideIon::bo:
318  // m_mass -= MASSH2O;
319  // m_mass -= MASSH2O;
320  diff = -4;
321  break;
322  case PeptideIon::a:
323  // m_mass -= MASSH2O;
324  // m_mass -= MASSCO;
325  diff = -2;
326  break;
327  case PeptideIon::c:
328  // m_mass += MASSNH3;
329  diff = -3;
330  break;
331  // SvgIon.moxygen - mN
332  case PeptideIon::z:
333  // m_mass -= MASSH2O;
334  // m_mass += MASSOXYGEN - MASSNITROGEN - MPROTIUM;
335  diff = -3;
336  break;
337  case PeptideIon::b:
338  // m_mass -= MASSH2O;
339  diff = -2;
340  break;
341  case PeptideIon::bp:
342  // H 1 O 3 P 1 + H 2 0
343  diff = -3 * m_neutralPhosphoLossNumber;
344  break;
345 
346 
347  case PeptideIon::astar:
348  // m_mass -= MASSH2O;
349  // m_mass = - MASSCO - MASSNH3;
350  diff = -5;
351  break;
352  case PeptideIon::ao:
353  // m_mass -= MASSH2O;
354  // m_mass = - MASSCO - MASSH2O;
355  diff = -4;
356  break;
357  case PeptideIon::x:
358  // +MASSCO + MASSOXYGEN
359  diff = -2;
360  break;
361  default:
362  throw PappsoException(QString("PeptideIon name not implemented"));
363  break;
364  }
365  break;
367  switch(m_ionType)
368  {
369  case PeptideIon::y:
370  break;
371  case PeptideIon::yp:
372  // H 1 O 3 P 1 + H 2 0
373  break;
374 
375  case PeptideIon::ystar:
376  // m_mass -= MASSNH3;
377  diff = -1;
378  break;
379  case PeptideIon::yo:
380  // m_mass -= MASSH2O;
381  break;
382  case PeptideIon::bstar:
383  // m_mass -= MASSH2O;
384  // m_mass -= MASSNH3;
385  diff = -1;
386  break;
387  case PeptideIon::bo:
388  // m_mass -= MASSH2O;
389  // m_mass -= MASSH2O;
390  break;
391  case PeptideIon::a:
392  // m_mass -= MASSH2O;
393  // m_mass -= MASSCO;
394  break;
395  case PeptideIon::c:
396  // m_mass += MASSNH3;
397  diff = -1;
398  break;
399  // SvgIon.moxygen - mN
400  case PeptideIon::z:
401  // m_mass -= MASSH2O;
402  // m_mass += MASSOXYGEN - MASSNITROGEN - MPROTIUM;
403  diff = -1;
404  break;
405  case PeptideIon::b:
406  // m_mass -= MASSH2O;
407  break;
408  case PeptideIon::bp:
409  // H 1 O 3 P 1 + H 2 0
410  break;
411 
412 
413  case PeptideIon::astar:
414  // m_mass -= MASSH2O;
415  // m_mass = - MASSCO - MASSNH3;
416  diff = -1;
417  break;
418  case PeptideIon::ao:
419  // m_mass -= MASSH2O;
420  // m_mass = - MASSCO - MASSH2O;
421  break;
422  case PeptideIon::x:
423  // +MASSCO + MASSOXYGEN
424  break;
425  default:
426  throw PappsoException(QString("PeptideIon name not implemented"));
427  break;
428  }
429  break;
431  switch(m_ionType)
432  {
433  case PeptideIon::y:
434  break;
435  case PeptideIon::yp:
436  // H 1 O 3 P 1 + H 2 0
437  diff = -4 * m_neutralPhosphoLossNumber;
438  break;
439 
440  case PeptideIon::ystar:
441  // m_mass -= MASSNH3;
442  break;
443  case PeptideIon::yo:
444  // m_mass -= MASSH2O;
445  diff = -1;
446  break;
447  case PeptideIon::bstar:
448  // m_mass -= MASSH2O;
449  // m_mass -= MASSNH3;
450  diff = -1;
451  break;
452  case PeptideIon::bo:
453  // m_mass -= MASSH2O;
454  // m_mass -= MASSH2O;
455  diff = -2;
456  break;
457  case PeptideIon::a:
458  // m_mass -= MASSH2O;
459  // m_mass -= MASSCO;
460  diff = -2;
461  break;
462  case PeptideIon::c:
463  // m_mass += MASSNH3;
464  break;
465  // SvgIon.moxygen - mN
466  case PeptideIon::z:
467  // m_mass -= MASSH2O;
468  // m_mass += MASSOXYGEN - MASSNITROGEN - MPROTIUM;
469  diff = -2;
470  break;
471  case PeptideIon::b:
472  // m_mass -= MASSH2O;
473  diff = -1;
474  break;
475  case PeptideIon::bp:
476  // H 1 O 3 P 1 + H 2 0
477  diff = -4 * m_neutralPhosphoLossNumber;
478  break;
479 
480 
481  case PeptideIon::astar:
482  // m_mass -= MASSH2O;
483  // m_mass = - MASSCO - MASSNH3;
484  diff = -2;
485  break;
486  case PeptideIon::ao:
487  // m_mass -= MASSH2O;
488  // m_mass = - MASSCO - MASSH2O;
489  diff = -3;
490  break;
491  case PeptideIon::x:
492  // +MASSCO + MASSOXYGEN
493  diff = +1;
494  break;
495  default:
496  throw PappsoException(
497  QObject::tr("PeptideIon name not implemented"));
498  break;
499  }
500  break;
502  break;
503  default:
504  qDebug() << "PeptideFragmentIon::getNumberOfAtom(AtomIsotopeSurvey "
505  "atom) NOT IMPLEMENTED";
506  }
507  return number + diff;
508 }
509 
510 
511 int
513 {
514  int number = msp_fragment.get()->getNumberOfIsotope(isotope);
515  return number;
516 }
517 
520 {
521  return std::make_shared<PeptideFragmentIon>(*this);
522 }
523 
524 
525 unsigned int
527 {
528  return msp_fragment.get()->size();
529 }
530 
531 const QString
533 {
534  return msp_fragment.get()->getSequence();
535 }
536 
537 const PeptideFragmentSp &
539 {
540  return msp_fragment;
541 }
542 
543 const QString
545 {
546  return QString("%1-%2").arg(getPeptideIonName(m_ionType)).arg(size());
547 }
548 
551 {
552  return m_mass;
553 }
554 
557 {
558  return m_ionType;
559 }
562 {
563  return msp_fragment.get()->getPeptideIonDirection();
564 }
565 unsigned int
567 {
569 }
570 
571 bool
573 {
574  return msp_fragment.get()->isPalindrome();
575 }
576 
577 
578 } // namespace pappso
PeptideFragmentIonSp makePeptideFragmentIonSp() const
const QString getPeptideIonName() const
virtual const PeptideFragmentSp & getPeptideFragmentSp() const
PeptideIon getPeptideIonType() const
const PeptideFragmentSp msp_fragment
unsigned int getNumberOfNeutralPhosphoLoss() const
virtual const QString getSequence() const override
amino acid sequence without modification
virtual unsigned int size() const override
PeptideFragmentIon(const PeptideFragmentSp &sp_fragment, PeptideIon ion_type, unsigned int number_of_neutral_phospho_loss)
static const QColor getPeptideIonColor(PeptideIon ion_type)
virtual int getNumberOfAtom(AtomIsotopeSurvey atom) const override
get the number of atom C, O, N, H in the molecule
pappso_double getMass() const override
PeptideDirection getPeptideIonDirection() const
virtual bool isPalindrome() const override
tells if the peptide sequence is a palindrome
virtual const QString getName() const override
virtual int getNumberOfIsotope(Isotope isotope) const override
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
static const QString getPeptideIonDirectionName(PeptideDirection direction)
static pappso_double getDeltaMass(PeptideIon ion_type)
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:385
@ 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.
std::shared_ptr< const PeptideFragmentIon > PeptideFragmentIonSp
PeptideDirection
Definition: peptide.h:46
AtomIsotopeSurvey
Definition: types.h:76
double pappso_double
A type definition for doubles.
Definition: types.h:48
Isotope
Definition: types.h:91
PeptideDirection getPeptideIonDirection(PeptideIon ion_type)
get the direction of a peptide ion
Definition: peptide.cpp:54
const pappso_double MASSH2O((MPROTIUM *2)+MASSOXYGEN)
const pappso_double MASSPHOSPHORYLATEDR(MPROTIUM+(MASSOXYGEN *3)+MASSPHOSPHORUS)
std::shared_ptr< const PeptideFragment > PeptideFragmentSp
peptide ion model
peptide natural isotope model
class dedicated to raw mass computations of peptide products (fragments)