libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
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 "
pappsomspp/core/pappsoexception.h
"
33
34
namespace
pappso
35
{
36
37
38
PeptideFragment::PeptideFragment
(
const
PeptideSp
&sp_peptide,
39
PeptideDirection
direction,
40
unsigned
int
size
)
41
:
msp_peptide
(sp_peptide),
m_direction
(direction),
m_size
(
size
)
42
{
43
if
(
m_direction
==
PeptideDirection::Nter
)
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
}
54
55
if
(
msp_peptide
.get()->getNterModification() !=
nullptr
)
56
{
57
m_mass
+=
msp_peptide
.get()->getNterModification()->getMass();
58
}
59
}
60
else
61
{
62
std::vector<Aa>::const_reverse_iterator it(
msp_peptide
.get()->rbegin());
63
std::vector<Aa>::const_reverse_iterator end(
msp_peptide
.get()->rend());
64
unsigned
int
i = 0;
65
while
(i <
m_size
)
66
{
67
m_mass
+= it->getMass();
68
it++;
69
i++;
70
}
71
if
(
msp_peptide
.get()->getCterModification() !=
nullptr
)
72
{
73
m_mass
+=
msp_peptide
.get()->getCterModification()->getMass();
74
}
75
}
76
77
m_mass
+=
msp_peptide
.get()->getCleavageNterModification()->
getMass
();
78
m_mass
+=
msp_peptide
.get()->getCleavageCterModification()->
getMass
();
79
}
80
81
82
PeptideFragment::PeptideFragment
(
const
PeptideFragment
&other)
83
:
msp_peptide
(other.
msp_peptide
),
m_direction
(other.
m_direction
),
m_size
(other.
m_size
)
84
{
85
m_mass
= other.
m_mass
;
86
}
87
88
89
PeptideFragment::PeptideFragment
(
PeptideFragment
&&toCopy)
// move constructor
90
:
msp_peptide
(std::move(toCopy.
msp_peptide
)),
91
m_direction
(toCopy.
m_direction
),
92
m_size
(toCopy.
m_size
),
93
m_mass
(toCopy.
m_mass
)
94
{
95
}
96
97
98
PeptideFragment::~PeptideFragment
()
99
{
100
}
101
102
const
QString
103
PeptideFragment::getPeptideIonDirectionName
(
PeptideDirection
direction)
104
{
105
switch
(direction)
106
{
107
case
PeptideDirection::Cter
:
108
return
"Cter"
;
109
break
;
110
case
PeptideDirection::Nter
:
111
return
"Nter"
;
112
break
;
113
default
:
114
throw
PappsoException
(QString(
"direction name not implemented"
));
115
break
;
116
}
117
}
118
119
const
QString
120
PeptideFragment::getSequence
()
const
121
{
122
QString sequence =
msp_peptide
.get()->getSequence();
123
int
diffSize =
msp_peptide
.get()->size() -
m_size
;
124
if
(
m_direction
==
PeptideDirection::Nter
)
125
{
126
sequence = sequence.mid(0,
m_size
);
127
}
128
else
129
{
130
sequence = sequence.mid(diffSize,
m_size
);
131
}
132
return
sequence;
133
}
134
135
136
int
137
PeptideFragment::getNumberOfAtom
(
Enums::AtomIsotopeSurvey
atom)
const
138
{
139
int
number = 0;
140
if
(
m_direction
==
PeptideDirection::Nter
)
141
{
142
std::vector<Aa>::const_iterator it(
msp_peptide
.get()->begin());
143
std::vector<Aa>::const_iterator end(
msp_peptide
.get()->end());
144
unsigned
int
i = 0;
145
while
(i <
m_size
)
146
{
147
number += it->getNumberOfAtom(atom);
148
it++;
149
i++;
150
}
151
if
(
msp_peptide
.get()->getNterModification() !=
nullptr
)
152
{
153
number +=
msp_peptide
.get()->getNterModification()->getNumberOfAtom(atom);
154
}
155
}
156
else
157
{
158
std::vector<Aa>::const_reverse_iterator it(
msp_peptide
.get()->rbegin());
159
std::vector<Aa>::const_reverse_iterator end(
msp_peptide
.get()->rend());
160
unsigned
int
i = 0;
161
while
(i <
m_size
)
162
{
163
number += it->getNumberOfAtom(atom);
164
it++;
165
i++;
166
}
167
if
(
msp_peptide
.get()->getCterModification() !=
nullptr
)
168
{
169
number +=
msp_peptide
.get()->getCterModification()->getNumberOfAtom(atom);
170
}
171
}
172
number +=
msp_peptide
.get()->getCleavageNterModification()->getNumberOfAtom(atom);
173
number +=
msp_peptide
.get()->getCleavageCterModification()->getNumberOfAtom(atom);
174
// qDebug() << "Aa::getMass() end " << mass;
175
return
number;
176
}
177
178
int
179
PeptideFragment::getNumberOfIsotope
(
Enums::Isotope
isotope)
const
180
{
181
int
number = 0;
182
if
(
m_direction
==
PeptideDirection::Nter
)
183
{
184
std::vector<Aa>::const_iterator it(
msp_peptide
.get()->begin());
185
std::vector<Aa>::const_iterator end(
msp_peptide
.get()->end());
186
unsigned
int
i = 0;
187
while
(i <
m_size
)
188
{
189
number += it->getNumberOfIsotope(isotope);
190
it++;
191
i++;
192
}
193
if
(
msp_peptide
.get()->getNterModification() !=
nullptr
)
194
{
195
number +=
msp_peptide
.get()->getNterModification()->getNumberOfIsotope(isotope);
196
}
197
}
198
else
199
{
200
std::vector<Aa>::const_reverse_iterator it(
msp_peptide
.get()->rbegin());
201
std::vector<Aa>::const_reverse_iterator end(
msp_peptide
.get()->rend());
202
unsigned
int
i = 0;
203
while
(i <
m_size
)
204
{
205
number += it->getNumberOfIsotope(isotope);
206
it++;
207
i++;
208
}
209
if
(
msp_peptide
.get()->getCterModification() !=
nullptr
)
210
{
211
number +=
msp_peptide
.get()->getCterModification()->getNumberOfIsotope(isotope);
212
}
213
}
214
number +=
msp_peptide
.get()->getCleavageNterModification()->getNumberOfIsotope(isotope);
215
number +=
msp_peptide
.get()->getCleavageCterModification()->getNumberOfIsotope(isotope);
216
// number += m_nterCterCleavage->getNumberOfIsotope(atom);
217
// qDebug() << "Aa::getMass() end " << mass;
218
return
number;
219
}
220
221
222
const
PeptideSp
&
223
PeptideFragment::getPeptideSp
()
const
224
{
225
return
msp_peptide
;
226
};
227
unsigned
int
228
PeptideFragment::size
()
const
229
{
230
return
m_size
;
231
}
232
233
pappso_double
234
PeptideFragment::getMass
()
const
235
{
236
return
m_mass
;
237
}
238
239
PeptideDirection
240
PeptideFragment::getPeptideIonDirection
()
const
241
{
242
return
m_direction
;
243
}
244
245
bool
246
PeptideFragment::isPalindrome
()
const
247
{
248
return
msp_peptide
.get()->isPalindrome();
249
}
250
251
252
}
// namespace pappso
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::PeptideFragment::m_size
const unsigned int m_size
Definition
peptidefragment.h:74
pappso::PeptideFragment::getPeptideIonDirection
PeptideDirection getPeptideIonDirection() const
Definition
peptidefragment.cpp:240
pappso::PeptideFragment::getMass
virtual pappso_double getMass() const override
Definition
peptidefragment.cpp:234
pappso::PeptideFragment::getSequence
virtual const QString getSequence() const override
amino acid sequence without modification
Definition
peptidefragment.cpp:120
pappso::PeptideFragment::msp_peptide
const PeptideSp msp_peptide
Definition
peptidefragment.h:72
pappso::PeptideFragment::PeptideFragment
PeptideFragment(const PeptideSp &sp_peptide, PeptideDirection direction, unsigned int size)
Definition
peptidefragment.cpp:38
pappso::PeptideFragment::getPeptideSp
virtual const PeptideSp & getPeptideSp() const
Definition
peptidefragment.cpp:223
pappso::PeptideFragment::getPeptideIonDirectionName
static const QString getPeptideIonDirectionName(PeptideDirection direction)
Definition
peptidefragment.cpp:103
pappso::PeptideFragment::isPalindrome
virtual bool isPalindrome() const override
tells if the peptide sequence is a palindrome
Definition
peptidefragment.cpp:246
pappso::PeptideFragment::~PeptideFragment
virtual ~PeptideFragment()
Definition
peptidefragment.cpp:98
pappso::PeptideFragment::getNumberOfIsotope
virtual int getNumberOfIsotope(Enums::Isotope isotope) const override
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
Definition
peptidefragment.cpp:179
pappso::PeptideFragment::size
virtual unsigned int size() const override
Definition
peptidefragment.cpp:228
pappso::PeptideFragment::m_mass
pappso_double m_mass
Definition
peptidefragment.h:76
pappso::PeptideFragment::m_direction
const PeptideDirection m_direction
Definition
peptidefragment.h:73
pappso::PeptideFragment::getNumberOfAtom
virtual int getNumberOfAtom(Enums::AtomIsotopeSurvey atom) const override
get the number of atom C, O, N, H in the molecule
Definition
peptidefragment.cpp:137
pappso::Enums::AtomIsotopeSurvey
AtomIsotopeSurvey
Definition
types.h:103
pappso::Enums::Isotope
Isotope
Definition
types.h:119
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::PeptideSp
std::shared_ptr< const Peptide > PeptideSp
Definition
aamodification.h:48
pappso::PeptideDirection
PeptideDirection
Definition
peptide.h:47
pappso::PeptideDirection::Cter
@ Cter
Definition
peptide.h:49
pappso::PeptideDirection::Nter
@ Nter
Definition
peptide.h:48
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition
types.h:60
pappsoexception.h
peptidefragment.h
pappsomspp
core
peptide
peptidefragment.cpp
Generated on
for libpappsomspp by
1.17.0