libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
grpmappeptidetosubgroupset.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
#include <QDebug>
25
#include <QObject>
26
27
#include "
grpmappeptidetosubgroupset.h
"
28
#include "
grppeptideset.h
"
29
30
#include "
pappsomspp/core/pappsoexception.h
"
31
32
33
namespace
pappso
34
{
35
GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet
()
36
{
37
}
38
39
GrpMapPeptideToSubGroupSet::~GrpMapPeptideToSubGroupSet
()
40
{
41
}
42
43
GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet
(
const
GrpMapPeptideToSubGroupSet
&other)
44
:
m_mapPeptideToSubGroupSet
(other.
m_mapPeptideToSubGroupSet
)
45
{
46
}
47
unsigned
int
48
GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet::size()
const
49
{
50
return
m_mapPeptideToSubGroupSet.size();
51
}
52
53
void
54
GrpMapPeptideToSubGroupSet::getSubGroupSet
(
const
GrpPeptideSet
&peptide_set_in,
55
GrpSubGroupSet
&impacted_subgroup_set)
const
56
{
57
qDebug() <<
"GrpMapPeptideToSubGroupSet::getSubGroupSet begin "
;
58
auto
it_peptide_end = peptide_set_in.
m_peptidePtrList
.end();
59
std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
60
m_mapPeptideToSubGroupSet
.end();
61
62
for
(
auto
it_peptide = peptide_set_in.
m_peptidePtrList
.begin(); it_peptide != it_peptide_end;
63
it_peptide++)
64
{
65
std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map =
66
m_mapPeptideToSubGroupSet
.find(*it_peptide);
67
if
(it_map != it_map_end)
68
{
69
impacted_subgroup_set.
addAll
(it_map->second);
70
}
71
}
72
qDebug() <<
"GrpMapPeptideToSubGroupSet::getSubGroupSet end "
;
73
}
74
void
75
GrpMapPeptideToSubGroupSet::check
(std::list<GrpSubGroupSp> &m_grpSubGroupSpList)
const
76
{
77
qDebug() <<
"GrpMapPeptideToSubGroupSet::std begin "
;
78
GrpMapPeptideToSubGroupSet
test(*
this
);
79
qDebug() <<
"GrpMapPeptideToSubGroupSet::std before test.size() "
<< test.
size
();
80
81
for
(
auto
pair :
m_mapPeptideToSubGroupSet
)
82
{
83
qDebug() <<
"GrpMapPeptideToSubGroupSet::std before peptide "
<< pair.first->getSequence()
84
<<
" "
<< pair.first;
85
}
86
87
for
(
GrpSubGroupSp
&sub_group_sp : m_grpSubGroupSpList)
88
{
89
test.
remove
(sub_group_sp.get());
90
}
91
qDebug() <<
"GrpMapPeptideToSubGroupSet::std after test.size() "
<< test.
size
();
92
93
qDebug() <<
"GrpMapPeptideToSubGroupSet::std begin "
;
94
}
95
96
void
97
GrpMapPeptideToSubGroupSet::remove
(
GrpSubGroup
*p_remove_sub_group)
98
{
99
qDebug() <<
"GrpMapPeptideToSubGroupSet::remove begin "
100
<< p_remove_sub_group->
getFirstAccession
();
101
// std::list<std::pair<GrpPeptide*, GrpSubGroupSet>>
102
// m_mapPeptideToSubGroupSet;
103
const
GrpPeptideSet
&peptide_set_in = p_remove_sub_group->
getPeptideSet
();
104
105
auto
it_peptide_end = peptide_set_in.
m_peptidePtrList
.end();
106
std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
107
m_mapPeptideToSubGroupSet
.end();
108
109
for
(
auto
it_peptide = peptide_set_in.
m_peptidePtrList
.begin(); it_peptide != it_peptide_end;
110
it_peptide++)
111
{
112
std::map<GrpPeptide *, GrpSubGroupSet>::iterator it_map =
113
m_mapPeptideToSubGroupSet
.find(*it_peptide);
114
if
(it_map != it_map_end)
115
{
116
it_map->second.remove(p_remove_sub_group);
117
if
(it_map->second.size() == 0)
118
{
119
m_mapPeptideToSubGroupSet
.erase(it_map);
120
}
121
}
122
else
123
{
124
throw
PappsoException
(QObject::tr(
"remove ERROR, peptide %1 from subgroup %2 not "
125
"referenced in GrpMapPeptideToSubGroupSet"
)
126
.arg((*it_peptide)->getSequence())
127
.arg(p_remove_sub_group->
getFirstAccession
()));
128
}
129
}
130
131
qDebug() <<
"GrpMapPeptideToSubGroupSet::remove end "
<< p_remove_sub_group->
getFirstAccession
();
132
}
133
void
134
GrpMapPeptideToSubGroupSet::add
(
GrpSubGroup
*p_add_sub_group)
135
{
136
qDebug() <<
"GrpMapPeptideToSubGroupSet::add begin m_mapPeptideToSubGroupSet.size()"
137
<<
m_mapPeptideToSubGroupSet
.size();
138
139
140
const
GrpPeptideSet
&peptide_set_in = p_add_sub_group->
getPeptideSet
();
141
142
auto
it_peptide_end = peptide_set_in.
m_peptidePtrList
.end();
143
144
for
(
auto
it_peptide = peptide_set_in.
m_peptidePtrList
.begin(); it_peptide != it_peptide_end;
145
it_peptide++)
146
{
147
std::pair<std::map<GrpPeptide *, GrpSubGroupSet>::iterator,
bool
> ret =
148
m_mapPeptideToSubGroupSet
.insert(
149
std::pair<GrpPeptide *, GrpSubGroupSet>(*it_peptide,
GrpSubGroupSet
()));
150
// if (ret.second==false) { => key already exists
151
ret.first->second.add(p_add_sub_group);
152
}
153
154
qDebug() <<
"GrpMapPeptideToSubGroupSet::add end"
;
155
}
156
157
158
bool
159
GrpMapPeptideToSubGroupSet::hasSpecificPeptide
(
const
GrpSubGroup
*p_sub_group)
const
160
{
161
qDebug() <<
"GrpMapPeptideToSubGroupSet::hasSpecificPeptide begin"
;
162
163
const
GrpPeptideSet
&peptide_set_in = p_sub_group->
getPeptideSet
();
164
165
auto
it_peptide_end = peptide_set_in.
m_peptidePtrList
.end();
166
std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
167
m_mapPeptideToSubGroupSet
.end();
168
169
for
(
auto
it_peptide = peptide_set_in.
m_peptidePtrList
.begin(); it_peptide != it_peptide_end;
170
it_peptide++)
171
{
172
std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map =
173
m_mapPeptideToSubGroupSet
.find(*it_peptide);
174
if
(it_map != it_map_end)
175
{
176
if
(it_map->second.size() == 1)
177
{
178
return
true
;
179
}
180
}
181
else
182
{
183
throw
PappsoException
(QObject::tr(
"hasSpecificPeptide ERROR, peptide %1 from subgroup %2 "
184
"not referenced in GrpMapPeptideToSubGroupSet"
)
185
.arg((*it_peptide)->getSequence())
186
.arg(p_sub_group->
getFirstAccession
()));
187
}
188
}
189
190
qDebug() <<
"GrpMapPeptideToSubGroupSet::hasSpecificPeptide end"
;
191
return
false
;
192
}
193
194
const
QString
195
GrpMapPeptideToSubGroupSet::printInfos
()
const
196
{
197
QString infos;
198
auto
itMap =
m_mapPeptideToSubGroupSet
.begin();
199
auto
itMapEnd =
m_mapPeptideToSubGroupSet
.end();
200
201
while
(itMap != itMapEnd)
202
{
203
infos.append(
204
itMap->first->getSequence() +
" "
+
205
QString(
"0x%1"
).arg((quintptr)itMap->first, QT_POINTER_SIZE * 2, 16, QChar(
'0'
)) +
"\n"
);
206
itMap++;
207
}
208
209
return
infos;
210
}
211
212
}
// namespace pappso
pappso::GrpMapPeptideToSubGroupSet::~GrpMapPeptideToSubGroupSet
~GrpMapPeptideToSubGroupSet()
Definition
grpmappeptidetosubgroupset.cpp:39
pappso::GrpMapPeptideToSubGroupSet::hasSpecificPeptide
bool hasSpecificPeptide(const GrpSubGroup *get) const
tells if this subgroup contains a specific peptide
Definition
grpmappeptidetosubgroupset.cpp:159
pappso::GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet
GrpMapPeptideToSubGroupSet()
Definition
grpmappeptidetosubgroupset.cpp:35
pappso::GrpMapPeptideToSubGroupSet::size
unsigned int size() const
pappso::GrpMapPeptideToSubGroupSet::check
void check(std::list< GrpSubGroupSp > &m_grpSubGroupSpList) const
check function only usefull for testing purpose
Definition
grpmappeptidetosubgroupset.cpp:75
pappso::GrpMapPeptideToSubGroupSet::getSubGroupSet
void getSubGroupSet(const GrpPeptideSet &peptide_set_in, GrpSubGroupSet &impacted_subgroup_set) const
get all subgroups concerned by a list of peptides
Definition
grpmappeptidetosubgroupset.cpp:54
pappso::GrpMapPeptideToSubGroupSet::remove
void remove(GrpSubGroup *p_remove_sub_group)
removes in the map all references of the group to remove (p_remove_sub_group)
Definition
grpmappeptidetosubgroupset.cpp:97
pappso::GrpMapPeptideToSubGroupSet::printInfos
const QString printInfos() const
Definition
grpmappeptidetosubgroupset.cpp:195
pappso::GrpMapPeptideToSubGroupSet::m_mapPeptideToSubGroupSet
std::map< GrpPeptide *, GrpSubGroupSet > m_mapPeptideToSubGroupSet
Definition
grpmappeptidetosubgroupset.h:39
pappso::GrpMapPeptideToSubGroupSet::add
void add(GrpSubGroup *p_add_sub_group)
add in the map all peptides of the subgroup to add
Definition
grpmappeptidetosubgroupset.cpp:134
pappso::GrpPeptideSet
Definition
grppeptideset.h:36
pappso::GrpPeptideSet::m_peptidePtrList
std::list< GrpPeptide * > m_peptidePtrList
Definition
grppeptideset.h:41
pappso::GrpSubGroupSet
Definition
grpsubgroupset.h:34
pappso::GrpSubGroupSet::addAll
void addAll(const GrpSubGroupSet &other)
Definition
grpsubgroupset.cpp:45
pappso::GrpSubGroup
Definition
grpsubgroup.h:43
pappso::GrpSubGroup::getPeptideSet
const GrpPeptideSet & getPeptideSet() const
Definition
grpsubgroup.cpp:132
pappso::GrpSubGroup::getFirstAccession
const QString & getFirstAccession() const
Definition
grpsubgroup.cpp:223
pappso::PappsoException
Definition
pappsoexception.h:41
grpmappeptidetosubgroupset.h
grppeptideset.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
pappsomspp
core
grouping
grpmappeptidetosubgroupset.cpp
Generated on
for libpappsomspp by
1.17.0