libpappsomspp
Library for mass spectrometry
peptidefragmentionlistbase.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/peptide/peptidefragmentionlistbase.cpp
3  * \date 10/3/2015
4  * \author Olivier Langella
5  * \brief fragmentation base object
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 
32 
33 #include <QDebug>
34 #include <memory>
35 #include "../pappsoexception.h"
36 
37 namespace pappso
38 {
39 
40 std::list<PeptideIon>
42 {
43  IonList ret;
44  // populate ret
45 
46  ret.push_back(PeptideIon::y);
47  ret.push_back(PeptideIon::yp);
48  ret.push_back(PeptideIon::ystar);
49  ret.push_back(PeptideIon::yo);
50  ret.push_back(PeptideIon::b);
51  ret.push_back(PeptideIon::bp);
52  ret.push_back(PeptideIon::a);
53  ret.push_back(PeptideIon::bstar);
54  ret.push_back(PeptideIon::bo);
55  return ret;
56 }
57 
58 std::list<PeptideIon>
60 {
61  IonList ret;
62  // populate ret
63 
64  ret.push_back(PeptideIon::y);
65  ret.push_back(PeptideIon::c);
66  ret.push_back(PeptideIon::z);
67  ret.push_back(PeptideIon::ystar);
68  ret.push_back(PeptideIon::yo);
69  return ret;
70 }
71 
72 const std::list<PeptideIon> &
74 {
75  return m_ionList;
76 }
77 
79  const IonList &ions)
80  : msp_peptide(peptide), m_ionList(ions)
81 {
82  try
83  {
84  qDebug()
85  << "PeptideFragmentIonListBase::PeptideFragmentIonListBase begin "
86  << ions.size();
87  std::list<PeptideFragmentSp> fragment_list =
89 
91  AaModificationP phosphorylation_mod = nullptr;
92 
93 
94  for(auto &&fragment_sp : fragment_list)
95  {
96  // qDebug()<< "PeptideFragmentIonListBase::PeptideFragmentIonListBase
97  // ition";
98  if(fragment_sp.get()->getPeptideIonDirection() ==
100  {
101  for(auto &&ion_type : m_ionList)
102  {
103  // qDebug()<<
104  // "PeptideFragmentIonListBase::PeptideFragmentIonListBase
105  // ition";
106  if((ion_type == PeptideIon::y) ||
107  (ion_type == PeptideIon::ystar) ||
108  (ion_type == PeptideIon::yo) ||
109  (ion_type == PeptideIon::z))
110  {
112  std::make_shared<PeptideFragmentIon>(fragment_sp,
113  ion_type));
114  }
115  else if(ion_type == PeptideIon::yp)
116  {
117  if(phosphorylation_mod == nullptr)
118  {
119  phosphorylation_mod =
120  AaModification::getInstance("MOD:00696");
122  peptide.get()->getNumberOfModification(
123  phosphorylation_mod);
124  }
125  for(unsigned int i = 0; i < m_phosphorylationNumber; i++)
126  {
128  std::make_shared<PeptideFragmentIon>(
129  fragment_sp, ion_type, i + 1));
130  }
131  }
132  }
133  }
134  else
135  {
136  for(auto &&ion_type : m_ionList)
137  {
138  // b, bstar, bo, a
139  if((ion_type == PeptideIon::b) ||
140  (ion_type == PeptideIon::bstar) ||
141  (ion_type == PeptideIon::bo) ||
142  (ion_type == PeptideIon::a) || (ion_type == PeptideIon::c))
143  {
145  std::make_shared<PeptideFragmentIon>(fragment_sp,
146  ion_type));
147  }
148  else if(ion_type == PeptideIon::bp)
149  {
150  if(phosphorylation_mod == nullptr)
151  {
152  phosphorylation_mod =
153  AaModification::getInstance("MOD:00696");
155  peptide.get()->getNumberOfModification(
156  phosphorylation_mod);
157  }
158  for(unsigned int i = 0; i < m_phosphorylationNumber; i++)
159  {
161  std::make_shared<PeptideFragmentIon>(
162  fragment_sp, ion_type, i + 1));
163  }
164  }
165  }
166  }
167  }
168  qDebug() << "PeptideFragmentIonListBase::PeptideFragmentIonListBase end "
169  << ions.size();
170  }
171  catch(PappsoException &exception_pappso)
172  {
173  QString errorStr =
174  QObject::tr(
175  "ERROR building PeptideFragmentIonListBase, PAPPSO exception:\n%1")
176  .arg(exception_pappso.qwhat());
177  qDebug() << "PeptideFragmentIonListBase::PeptideFragmentIonListBase "
178  "PappsoException :\n"
179  << errorStr;
180  throw PappsoException(errorStr);
181  }
182  catch(std::exception &exception_std)
183  {
184  QString errorStr =
185  QObject::tr(
186  "ERROR building PeptideFragmentIonListBase, std exception:\n%1")
187  .arg(exception_std.what());
188  qDebug() << "PeptideFragmentIonListBase::PeptideFragmentIonListBase "
189  "std::exception :\n"
190  << errorStr;
191  throw PappsoException(errorStr);
192  }
193 }
194 
196  const PeptideFragmentIonListBase &other)
197  : msp_peptide(other.msp_peptide),
198  msp_peptide_fragment_ion_list(other.msp_peptide_fragment_ion_list),
199  m_ionList(other.m_ionList),
200  m_phosphorylationNumber(other.m_phosphorylationNumber)
201 {
202 }
203 
204 
207 {
208  return std::make_shared<const PeptideFragmentIonListBase>(*this);
209 }
210 
211 
213 {
214 }
215 
216 const std::list<PeptideFragmentSp>
218 {
219  std::list<PeptideFragmentSp> peptide_fragment_list;
220 
221  unsigned int max = peptide.get()->size() - 1;
222  for(unsigned int i = 0; i < max; i++)
223  {
224 
225  peptide_fragment_list.push_back(std::make_shared<PeptideFragment>(
226  peptide, PeptideDirection::Nter, i + 1));
227  peptide_fragment_list.push_back(std::make_shared<PeptideFragment>(
228  peptide, PeptideDirection::Cter, i + 1));
229  }
230  return peptide_fragment_list;
231 }
232 
233 const std::list<PeptideFragmentIonSp>
235 {
236  std::list<PeptideFragmentIonSp> ion_list;
237  for(auto &&peptide_fragment_ion_sp : msp_peptide_fragment_ion_list)
238  {
239  if(peptide_fragment_ion_sp.get()->getPeptideIonType() == ion_type)
240  {
241  ion_list.push_back(peptide_fragment_ion_sp);
242  }
243  }
244  return (ion_list);
245 }
246 
247 const PeptideFragmentIonSp &
249  unsigned int size) const
250 {
251 
252  return getPeptideFragmentIonSp(ion_type, size, 0);
253 }
254 
255 const PeptideFragmentIonSp &
257  PeptideIon ion_type,
258  unsigned int size,
259  unsigned int number_of_neutral_phospho_loss) const
260 {
261  for(auto &&peptide_fragment_ion_sp : msp_peptide_fragment_ion_list)
262  {
263  if(peptide_fragment_ion_sp.get()->getPeptideIonType() == ion_type)
264  {
265  if(peptide_fragment_ion_sp.get()->size() == size)
266  {
267  if(peptide_fragment_ion_sp.get()
268  ->getNumberOfNeutralPhosphoLoss() ==
269  number_of_neutral_phospho_loss)
270  {
271  return (peptide_fragment_ion_sp);
272  }
273  }
274  }
275  }
276 
277  throw PappsoException(QString("PeptideFragmentIon %1 of size %2 not found")
279  .arg(size));
280 }
281 
282 } // namespace pappso
static AaModificationP getInstance(const QString &accession)
virtual const QString & qwhat() const
std::list< PeptideFragmentIonSp > msp_peptide_fragment_ion_list
const std::list< PeptideFragmentIonSp > getPeptideFragmentIonSp(PeptideIon ion_type) const
static std::list< PeptideIon > getETDionList()
PeptideFragmentIonListBaseSp makePeptideFragmentIonListBaseSp() const
PeptideFragmentIonListBase(const PeptideSp &peptide, const IonList &ions)
const std::list< PeptideIon > & getIonList() const
static const std::list< PeptideFragmentSp > getPeptideFragmentList(const PeptideSp &peptide)
static std::list< PeptideIon > getCIDionList()
const QString getPeptideIonName() const
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.
@ ystar
Cter amino ions + NH3 loss.
@ yo
Cter amino ions + H2O loss.
@ bstar
Nter acylium ions + NH3 loss.
@ b
Nter acylium ions.
@ bo
Nter acylium ions + H2O loss.
@ z
Cter carbocations.
std::shared_ptr< const PeptideFragmentIon > PeptideFragmentIonSp
std::shared_ptr< const Peptide > PeptideSp
std::shared_ptr< const PeptideFragmentIonListBase > PeptideFragmentIonListBaseSp
@ max
maximum of intensities
fragmentation base object