libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
grpsubgroup.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 "
grpsubgroup.h
"
27
#include "
grppeptideset.h
"
28
#include "
pappsomspp/core/pappsoexception.h
"
29
#include "
pappsomspp/core/utils.h
"
30
31
32
namespace
pappso
33
{
34
35
36
GrpSubGroup::GrpSubGroup
(
GrpProtein
*p_protein) :
m_peptidePtrList
(p_protein)
37
{
38
m_grpProteinPtrList
.push_back(p_protein);
39
}
40
41
GrpSubGroup::GrpSubGroup
(
const
GrpSubGroup
&other)
42
:
m_grpProteinPtrList
(other.
m_grpProteinPtrList
),
m_peptidePtrList
(other.
m_peptidePtrList
)
43
{
44
}
45
46
unsigned
int
47
GrpSubGroup::getGroupNumber
()
const
48
{
49
return
m_groupNumber
;
50
}
51
unsigned
int
52
GrpSubGroup::getSubGroupNumber
()
const
53
{
54
return
m_subGroupNumber
;
55
}
56
const
std::vector<GrpProtein *> &
57
GrpSubGroup::getGrpProteinList
()
const
58
{
59
return
m_grpProteinPtrList
;
60
}
61
const
QString
62
GrpSubGroup::getGroupingId
()
const
63
{
64
if
(
m_groupNumber
== 0)
65
{
66
return
""
;
67
}
68
return
QString(
"%1.%2"
)
69
.arg(
Utils::getLexicalOrderedString
(
m_groupNumber
))
70
.arg(
Utils::getLexicalOrderedString
(
m_subGroupNumber
));
71
}
72
unsigned
int
73
GrpSubGroup::maxCount
()
const
74
{
75
unsigned
int
max = 0;
76
for
(
GrpProtein
*p_protein :
m_grpProteinPtrList
)
77
{
78
if
(max < p_protein->getCount())
79
{
80
max = p_protein->getCount();
81
}
82
}
83
return
max;
84
}
85
bool
86
GrpSubGroup::operator<
(
const
GrpSubGroup
&other)
const
87
{
88
if
(
m_peptidePtrList
.size() == other.
m_peptidePtrList
.
size
())
89
{
90
if
(
maxCount
() == other.
maxCount
())
91
{
92
if
(
m_grpProteinPtrList
.size() == other.
m_grpProteinPtrList
.size())
93
{
94
// compare peptide set surface ?
95
// alphabetic order taken into account
96
return
((*(
m_grpProteinPtrList
.begin()))->getAccession() <
97
(*(other.
m_grpProteinPtrList
.begin()))->getAccession());
98
}
99
else
100
{
101
// if there is same peptide size evidence, then perhaps it's
102
// better to consider that
103
// the best group is the one that include more proteins
104
return
(
m_grpProteinPtrList
.size() > other.
m_grpProteinPtrList
.size());
105
}
106
}
107
else
108
{
109
// counts are evidences of the presence of a subgroup
110
// the fewer is the count, the weaker is the subgroup
111
return
(
maxCount
() > other.
maxCount
());
112
}
113
}
114
else
115
{
116
// peptides are evidences of the presence of a subgroup
117
// the fewer is the peptide list, the weaker is the subgroup
118
return
(
m_peptidePtrList
.size() > other.
m_peptidePtrList
.
size
());
119
}
120
}
121
122
GrpSubGroup::~GrpSubGroup
()
123
{
124
}
125
GrpSubGroupSp
126
GrpSubGroup::makeGrpSubGroupSp
()
127
{
128
return
std::make_shared<GrpSubGroup>(*
this
);
129
}
130
131
const
GrpPeptideSet
&
132
GrpSubGroup::getPeptideSet
()
const
133
{
134
return
m_peptidePtrList
;
135
}
136
137
bool
138
GrpSubGroup::merge
(
GrpSubGroup
*p_subgroup)
139
{
140
qDebug() <<
"GrpSubGroup::merge begin "
<<
m_grpProteinPtrList
.size() <<
" "
141
<< this->
getFirstAccession
() <<
" "
<< p_subgroup->
getFirstAccession
();
142
// if (this == p_subgroup) {
143
// return true;
144
//}
145
if
(p_subgroup->
m_peptidePtrList
==
m_peptidePtrList
)
146
{
147
// m_grpProteinPtrList.splice (m_grpProteinPtrList.end(),
148
// p_subgroup->m_grpProteinPtrList);
149
m_grpProteinPtrList
.insert(
m_grpProteinPtrList
.end(),
150
p_subgroup->
m_grpProteinPtrList
.begin(),
151
p_subgroup->
m_grpProteinPtrList
.end());
152
// m_grpProteinPtrList.insert (m_grpProteinPtrList.end(),
153
// p_subgroup->m_grpProteinPtrList.begin(),p_subgroup->m_grpProteinPtrList.end());
154
return
true
;
155
}
156
else
157
{
158
return
false
;
159
}
160
}
161
162
bool
163
GrpSubGroup::includes
(
const
GrpSubGroup
*p_subgroup)
const
164
{
165
if
(
m_peptidePtrList
.biggerAndContainsAll(p_subgroup->
getPeptideSet
()))
166
{
167
return
true
;
168
}
169
else
170
{
171
return
false
;
172
}
173
}
174
175
void
176
GrpSubGroup::setGroupNumber
(
unsigned
int
i)
177
{
178
m_groupNumber
= i;
179
for
(
auto
&&p_protein :
m_grpProteinPtrList
)
180
{
181
p_protein->setGroupNumber(i);
182
}
183
}
184
185
void
186
GrpSubGroup::setSubGroupNumber
(
unsigned
int
i)
187
{
188
m_subGroupNumber
= i;
189
for
(
auto
&&p_protein :
m_grpProteinPtrList
)
190
{
191
p_protein->setSubGroupNumber(i);
192
}
193
}
194
195
void
196
GrpSubGroup::numbering
()
197
{
198
qDebug() <<
"GrpSubGroup::numbering begin"
;
199
200
// sort proteins by accession numbers :
201
// m_grpProteinPtrList.sort([](GrpProtein * first, GrpProtein * second) {
202
// return (first->getAccession() < second->getAccession()) ;
203
//});
204
std::sort(
m_grpProteinPtrList
.begin(),
205
m_grpProteinPtrList
.end(),
206
[](
GrpProtein
*first,
GrpProtein
*second) {
207
return (first->getAccession() < second->getAccession());
208
});
209
// list unique removes all but the first element from every consecutive group
210
// of equal elements in the container
211
// m_grpProteinPtrList.unique();
212
213
214
unsigned
int
i = 1;
215
for
(
auto
&&p_protein :
m_grpProteinPtrList
)
216
{
217
p_protein->setRank(i);
218
i++;
219
}
220
qDebug() <<
"GrpSubGroup::numbering end"
;
221
}
222
const
QString &
223
GrpSubGroup::getFirstAccession
()
const
224
{
225
auto
it =
m_grpProteinPtrList
.begin();
226
if
(it ==
m_grpProteinPtrList
.end())
227
{
228
throw
PappsoException
(QObject::tr(
"m_grpProteinPtrList is empty"
));
229
}
230
else
231
{
232
return
(*it)->getAccession();
233
}
234
}
235
236
std::size_t
237
GrpSubGroup::peptideListSize
()
const
238
{
239
return
m_peptidePtrList
.size();
240
}
241
242
}
// namespace pappso
pappso::GrpPeptideSet
Definition
grppeptideset.h:36
pappso::GrpPeptideSet::size
unsigned int size() const
Definition
grppeptideset.h:54
pappso::GrpProtein
Definition
grpprotein.h:40
pappso::GrpSubGroup::operator<
bool operator<(const GrpSubGroup &other) const
sort subgroups between each other a subgroup containing less peptides is weaker (less) than the other
Definition
grpsubgroup.cpp:86
pappso::GrpSubGroup::m_grpProteinPtrList
std::vector< GrpProtein * > m_grpProteinPtrList
Definition
grpsubgroup.h:45
pappso::GrpSubGroup::getSubGroupNumber
unsigned int getSubGroupNumber() const
Definition
grpsubgroup.cpp:52
pappso::GrpSubGroup::getGroupNumber
unsigned int getGroupNumber() const
Definition
grpsubgroup.cpp:47
pappso::GrpSubGroup::~GrpSubGroup
~GrpSubGroup()
Definition
grpsubgroup.cpp:122
pappso::GrpSubGroup::setSubGroupNumber
void setSubGroupNumber(unsigned int i)
Definition
grpsubgroup.cpp:186
pappso::GrpSubGroup::getPeptideSet
const GrpPeptideSet & getPeptideSet() const
Definition
grpsubgroup.cpp:132
pappso::GrpSubGroup::GrpSubGroup
GrpSubGroup(GrpProtein *p_protein)
Definition
grpsubgroup.cpp:36
pappso::GrpSubGroup::getGroupingId
const QString getGroupingId() const
Definition
grpsubgroup.cpp:62
pappso::GrpSubGroup::numbering
void numbering()
Definition
grpsubgroup.cpp:196
pappso::GrpSubGroup::setGroupNumber
void setGroupNumber(unsigned int i)
Definition
grpsubgroup.cpp:176
pappso::GrpSubGroup::includes
bool includes(const GrpSubGroup *p_subgroup) const
Definition
grpsubgroup.cpp:163
pappso::GrpSubGroup::peptideListSize
std::size_t peptideListSize() const
Definition
grpsubgroup.cpp:237
pappso::GrpSubGroup::maxCount
unsigned int maxCount() const
Definition
grpsubgroup.cpp:73
pappso::GrpSubGroup::m_groupNumber
unsigned int m_groupNumber
Definition
grpsubgroup.h:48
pappso::GrpSubGroup::getFirstAccession
const QString & getFirstAccession() const
Definition
grpsubgroup.cpp:223
pappso::GrpSubGroup::merge
bool merge(GrpSubGroup *p_subgroup)
Definition
grpsubgroup.cpp:138
pappso::GrpSubGroup::m_subGroupNumber
unsigned int m_subGroupNumber
Definition
grpsubgroup.h:47
pappso::GrpSubGroup::getGrpProteinList
const std::vector< GrpProtein * > & getGrpProteinList() const
Definition
grpsubgroup.cpp:57
pappso::GrpSubGroup::m_peptidePtrList
GrpPeptideSet m_peptidePtrList
Definition
grpsubgroup.h:46
pappso::GrpSubGroup::makeGrpSubGroupSp
GrpSubGroupSp makeGrpSubGroupSp()
Definition
grpsubgroup.cpp:126
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition
utils.cpp:72
grppeptideset.h
grpsubgroup.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::GrpSubGroupSp
std::shared_ptr< GrpSubGroup > GrpSubGroupSp
Definition
grpsubgroup.h:39
pappsoexception.h
utils.h
pappsomspp
core
grouping
grpsubgroup.cpp
Generated on
for libpappsomspp by
1.17.0