libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
grppeptideset.cpp
Go to the documentation of this file.
1
2
/*******************************************************************************
3
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4
*
5
* This file is part of the PAPPSOms++ library.
6
*
7
* PAPPSOms++ is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* PAPPSOms++ is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19
*
20
* Contributors:
21
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22
*implementation
23
******************************************************************************/
24
25
#include <QDebug>
26
#include "
grppeptideset.h
"
27
28
using namespace
pappso
;
29
GrpPeptideSet::GrpPeptideSet
()
30
{
31
}
32
GrpPeptideSet::GrpPeptideSet
(
const
GrpProtein
*p_protein)
33
{
34
auto
it = p_protein->
begin
();
35
while
(it != p_protein->
end
())
36
{
37
m_peptidePtrList
.push_back(*it);
38
it++;
39
}
40
}
41
GrpPeptideSet::GrpPeptideSet
(
const
GrpPeptideSet
&other) :
m_peptidePtrList
(other.
m_peptidePtrList
)
42
{
43
}
44
45
GrpPeptideSet::~GrpPeptideSet
()
46
{
47
}
48
49
GrpPeptideSet
&
50
GrpPeptideSet::operator=
(
const
GrpPeptideSet
&other)
51
{
52
m_peptidePtrList
= other.
m_peptidePtrList
;
53
return
*
this
;
54
}
55
56
bool
57
GrpPeptideSet::operator==
(
const
GrpPeptideSet
&other)
const
58
{
59
if
(
m_peptidePtrList
.size() != other.
m_peptidePtrList
.size())
60
{
61
return
false
;
62
}
63
return
privContainsAll
(other);
64
}
65
66
bool
67
GrpPeptideSet::contains
(
const
GrpPeptide
*p_grp_peptide)
const
68
{
69
if
(std::find(
m_peptidePtrList
.begin(),
m_peptidePtrList
.end(), p_grp_peptide) ==
70
m_peptidePtrList
.end())
71
{
72
return
false
;
73
}
74
return
true
;
75
}
76
77
bool
78
GrpPeptideSet::containsAll
(
const
GrpPeptideSet
&peptideSetIn)
const
79
{
80
if
(
m_peptidePtrList
.size() < peptideSetIn.
m_peptidePtrList
.size())
81
{
82
return
false
;
83
}
84
return
privContainsAll
(peptideSetIn);
85
}
86
87
bool
88
GrpPeptideSet::biggerAndContainsAll
(
const
GrpPeptideSet
&peptideSetIn)
const
89
{
90
if
(
m_peptidePtrList
.size() > peptideSetIn.
m_peptidePtrList
.size())
91
{
92
return
privContainsAll
(peptideSetIn);
93
}
94
return
false
;
95
}
96
97
bool
98
GrpPeptideSet::privContainsAll
(
const
GrpPeptideSet
&peptideSetIn)
const
99
{
100
std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
101
innerIt = peptideSetIn.
m_peptidePtrList
.begin();
102
innerEnd = peptideSetIn.
m_peptidePtrList
.end();
103
outerIt =
m_peptidePtrList
.begin();
104
outerEnd =
m_peptidePtrList
.end();
105
106
107
while
((innerIt != innerEnd) && (outerIt != outerEnd))
108
{
109
if
(*innerIt > *outerIt)
110
{
111
outerIt++;
112
continue
;
113
}
114
if
(*innerIt < *outerIt)
115
{
116
return
false
;
117
}
118
if
(*innerIt == *outerIt)
119
{
120
innerIt++;
121
outerIt++;
122
}
123
}
124
if
(innerIt == innerEnd)
125
{
126
return
true
;
127
}
128
return
false
;
129
}
130
131
bool
132
GrpPeptideSet::containsAny
(
const
GrpPeptideSet
&peptideSetIn)
const
133
{
134
std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
135
136
innerIt = peptideSetIn.
m_peptidePtrList
.begin();
137
innerEnd = peptideSetIn.
m_peptidePtrList
.end();
138
outerIt =
m_peptidePtrList
.begin();
139
outerEnd =
m_peptidePtrList
.end();
140
141
142
while
((innerIt != innerEnd) && (outerIt != outerEnd))
143
{
144
if
(*innerIt > *outerIt)
145
{
146
outerIt++;
147
continue
;
148
}
149
if
(*innerIt < *outerIt)
150
{
151
innerIt++;
152
continue
;
153
}
154
if
(*innerIt == *outerIt)
155
{
156
return
true
;
157
}
158
}
159
return
false
;
160
}
161
162
void
163
GrpPeptideSet::addAll
(
const
GrpPeptideSet
&peptideSetIn)
164
{
165
166
qDebug() <<
"GrpPeptideSet::addAll begin"
;
167
std::list<GrpPeptide *>::iterator it(
m_peptidePtrList
.begin());
168
std::list<GrpPeptide *>::iterator itEnd(
m_peptidePtrList
.end());
169
std::list<GrpPeptide *>::const_iterator itIn(peptideSetIn.
m_peptidePtrList
.begin());
170
std::list<GrpPeptide *>::const_iterator itInEnd(peptideSetIn.
m_peptidePtrList
.end());
171
172
while
((itIn != itInEnd) && (it != itEnd))
173
{
174
if
(*itIn > *it)
175
{
176
it++;
177
continue
;
178
}
179
if
(*itIn < *it)
180
{
181
it =
m_peptidePtrList
.insert(it, *itIn);
182
it++;
183
itIn++;
184
continue
;
185
}
186
if
(*itIn == *it)
187
{
188
itIn++;
189
it++;
190
}
191
}
192
while
(itIn != itInEnd)
193
{
194
m_peptidePtrList
.push_back(*itIn);
195
itIn++;
196
}
197
qDebug() <<
"GrpPeptideSet::addAll end"
;
198
}
199
200
201
void
202
GrpPeptideSet::numbering
()
203
{
204
qDebug() <<
"GrpPeptideSet::numbering begin"
;
205
206
m_peptidePtrList
.sort(
207
[](
GrpPeptide
*first,
GrpPeptide
*second) {
return
((*first) < (*second)); });
208
unsigned
int
i = 1;
209
for
(
auto
&&p_grp_peptide :
m_peptidePtrList
)
210
{
211
p_grp_peptide->setRank(i);
212
i++;
213
}
214
215
qDebug() <<
"GrpPeptideSet::numbering end"
;
216
}
217
218
219
void
220
GrpPeptideSet::setGroupNumber
(
unsigned
int
i)
221
{
222
qDebug() <<
"GrpPeptideSet::setGroupNumber begin"
;
223
for
(
auto
&&p_grp_peptide :
m_peptidePtrList
)
224
{
225
p_grp_peptide->setGroupNumber(i);
226
}
227
228
qDebug() <<
"GrpPeptideSet::setGroupNumber end"
;
229
}
230
231
std::vector<const GrpPeptide *>
232
GrpPeptideSet::getGrpPeptideList
()
const
233
{
234
std::vector<const GrpPeptide *> peptide_list;
235
for
(
GrpPeptide
*peptide :
m_peptidePtrList
)
236
{
237
peptide_list.push_back(peptide);
238
}
239
return
peptide_list;
240
}
241
242
const
QString
243
GrpPeptideSet::printInfos
()
const
244
{
245
QString infos;
246
std::list<GrpPeptide *>::const_iterator it(
m_peptidePtrList
.begin()),
247
itEnd(
m_peptidePtrList
.end());
248
249
250
while
(it != itEnd)
251
{
252
infos.append((*it)->getSequence() +
" "
+
253
QString(
"0x%1"
).arg((quintptr)*it, QT_POINTER_SIZE * 2, 16, QChar(
'0'
)) +
"\n"
);
254
it++;
255
}
256
257
return
infos;
258
}
pappso::GrpPeptideSet
Definition
grppeptideset.h:36
pappso::GrpPeptideSet::m_peptidePtrList
std::list< GrpPeptide * > m_peptidePtrList
Definition
grppeptideset.h:41
pappso::GrpPeptideSet::printInfos
const QString printInfos() const
Definition
grppeptideset.cpp:243
pappso::GrpPeptideSet::addAll
void addAll(const GrpPeptideSet &peptideSet)
Definition
grppeptideset.cpp:163
pappso::GrpPeptideSet::getGrpPeptideList
std::vector< const GrpPeptide * > getGrpPeptideList() const
Definition
grppeptideset.cpp:232
pappso::GrpPeptideSet::numbering
void numbering()
Definition
grppeptideset.cpp:202
pappso::GrpPeptideSet::operator==
bool operator==(const GrpPeptideSet &other) const
Definition
grppeptideset.cpp:57
pappso::GrpPeptideSet::containsAny
bool containsAny(const GrpPeptideSet &peptideSet) const
Definition
grppeptideset.cpp:132
pappso::GrpPeptideSet::GrpPeptideSet
GrpPeptideSet()
Definition
grppeptideset.cpp:29
pappso::GrpPeptideSet::setGroupNumber
void setGroupNumber(unsigned int i)
Definition
grppeptideset.cpp:220
pappso::GrpPeptideSet::operator=
GrpPeptideSet & operator=(const GrpPeptideSet &other)
Definition
grppeptideset.cpp:50
pappso::GrpPeptideSet::~GrpPeptideSet
~GrpPeptideSet()
Definition
grppeptideset.cpp:45
pappso::GrpPeptideSet::biggerAndContainsAll
bool biggerAndContainsAll(const GrpPeptideSet &peptideSet) const
Definition
grppeptideset.cpp:88
pappso::GrpPeptideSet::contains
bool contains(const GrpPeptide *p_grp_peptide) const
Definition
grppeptideset.cpp:67
pappso::GrpPeptideSet::privContainsAll
bool privContainsAll(const GrpPeptideSet &peptideSetIn) const
Definition
grppeptideset.cpp:98
pappso::GrpPeptideSet::containsAll
bool containsAll(const GrpPeptideSet &peptideSet) const
Definition
grppeptideset.cpp:78
pappso::GrpPeptide
Definition
grppeptide.h:43
pappso::GrpProtein
Definition
grpprotein.h:40
pappso::GrpProtein::end
const_iterator end() const
Definition
grpprotein.cpp:62
pappso::GrpProtein::begin
const_iterator begin() const
Definition
grpprotein.cpp:57
grppeptideset.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappsomspp
core
grouping
grppeptideset.cpp
Generated on
for libpappsomspp by
1.17.0