libpappsomspp
Library for mass spectrometry
peptidefragment.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/peptide/peptidefragment.h
3  * \date 10/3/2015
4  * \author Olivier Langella
5  * \brief peptide fragment 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 "peptidefragment.h"
32 #include "../pappsoexception.h"
33 
34 namespace pappso
35 {
36 
37 
39  PeptideDirection direction,
40  unsigned int size)
41  : msp_peptide(sp_peptide), m_direction(direction), m_size(size)
42 {
44  {
45  std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
46  std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
47  unsigned int i = 0;
48  while(i < m_size)
49  {
50  m_mass += it->getMass();
51  it++;
52  i++;
53  }
55  AaModification::getInstance("internal:Cter_hydrolytic_cleavage_HO");
56  }
57  else
58  {
59  std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
60  std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
61  unsigned int i = 0;
62  while(i < m_size)
63  {
64  m_mass += it->getMass();
65  it++;
66  i++;
67  }
69  AaModification::getInstance("internal:Nter_hydrolytic_cleavage_H");
70  }
72 }
73 
74 
76  : msp_peptide(other.msp_peptide),
77  m_direction(other.m_direction),
78  m_size(other.m_size)
79 {
80  m_mass = other.m_mass;
81 }
82 
83 
85  : msp_peptide(std::move(toCopy.msp_peptide)),
86  m_direction(toCopy.m_direction),
87  m_size(toCopy.m_size),
88  m_mass(toCopy.m_mass)
89 {
90 }
91 
92 
94 {
95 }
96 
97 const QString
99 {
100  switch(direction)
101  {
103  return "Cter";
104  break;
106  return "Nter";
107  break;
108  default:
109  throw PappsoException(QString("direction name not implemented"));
110  break;
111  }
112 }
113 
114 const QString
116 {
117  QString sequence = msp_peptide.get()->getSequence();
118  int diffSize = msp_peptide.get()->size() - m_size;
120  {
121  sequence = sequence.mid(0, m_size);
122  }
123  else
124  {
125  sequence = sequence.mid(diffSize, m_size);
126  }
127  return sequence;
128 }
129 
130 
131 int
133 {
134  int number = 0;
136  {
137  std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
138  std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
139  unsigned int i = 0;
140  while(i < m_size)
141  {
142  number += it->getNumberOfAtom(atom);
143  it++;
144  i++;
145  }
146  }
147  else
148  {
149  std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
150  std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
151  unsigned int i = 0;
152  while(i < m_size)
153  {
154  number += it->getNumberOfAtom(atom);
155  it++;
156  i++;
157  }
158  }
159  number += m_nterCterCleavage->getNumberOfAtom(atom);
160  // qDebug() << "Aa::getMass() end " << mass;
161  return number;
162 }
163 
164 int
166 {
167  int number = 0;
169  {
170  std::vector<Aa>::const_iterator it(msp_peptide.get()->begin());
171  std::vector<Aa>::const_iterator end(msp_peptide.get()->end());
172  unsigned int i = 0;
173  while(i < m_size)
174  {
175  number += it->getNumberOfIsotope(isotope);
176  it++;
177  i++;
178  }
179  }
180  else
181  {
182  std::vector<Aa>::const_reverse_iterator it(msp_peptide.get()->rbegin());
183  std::vector<Aa>::const_reverse_iterator end(msp_peptide.get()->rend());
184  unsigned int i = 0;
185  while(i < m_size)
186  {
187  number += it->getNumberOfIsotope(isotope);
188  it++;
189  i++;
190  }
191  }
192  // number += m_nterCterCleavage->getNumberOfIsotope(atom);
193  // qDebug() << "Aa::getMass() end " << mass;
194  return number;
195 }
196 
197 
198 const PeptideSp &
200 {
201  return msp_peptide;
202 };
203 unsigned int
205 {
206  return m_size;
207 }
208 
211 {
212  return m_mass;
213 }
214 
217 {
218  return m_direction;
219 }
220 
221 bool
223 {
224  return msp_peptide.get()->isPalindrome();
225 }
226 
227 
228 } // namespace pappso
int getNumberOfAtom(AtomIsotopeSurvey atom) const override final
get the number of atom C, O, N, H in the molecule
pappso_double getMass() const
static AaModificationP getInstance(const QString &accession)
const unsigned int m_size
PeptideDirection getPeptideIonDirection() const
virtual pappso_double getMass() const override
virtual const QString getSequence() const override
amino acid sequence without modification
const PeptideSp msp_peptide
virtual int getNumberOfIsotope(Isotope isotope) const override
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
PeptideFragment(const PeptideSp &sp_peptide, PeptideDirection direction, unsigned int size)
AaModificationP m_nterCterCleavage
virtual const PeptideSp & getPeptideSp() const
static const QString getPeptideIonDirectionName(PeptideDirection direction)
virtual bool isPalindrome() const override
tells if the peptide sequence is a palindrome
virtual int getNumberOfAtom(AtomIsotopeSurvey atom) const override
get the number of atom C, O, N, H in the molecule
virtual unsigned int size() const override
const PeptideDirection m_direction
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp
PeptideDirection
Definition: peptide.h:46
AtomIsotopeSurvey
Definition: types.h:77
double pappso_double
A type definition for doubles.
Definition: types.h:49
Isotope
Definition: types.h:92
peptide fragment model