libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::GrpGroup Class Reference

#include <grpgroup.h>

Public Member Functions

 GrpGroup (const GrpGroup &grpGroupSp)
 ~GrpGroup ()
bool operator< (const GrpGroup &other) const
bool containsAny (const GrpPeptideSet &peptideSet) const
void addSubGroupSp (const GrpSubGroupSp &grpSubGroupSp)
void addGroup (GrpGroup *p_group_to_add)
void numbering ()
void setGroupNumber (unsigned int i)
bool removeNonInformativeSubGroups ()
const QString getGroupingId () const
unsigned int getGroupNumber () const
const GrpPeptideSetgetGrpPeptideSet () const
std::vector< GrpSubGroupSpConstgetGrpSubGroupSpList () const

Protected Member Functions

const std::list< GrpSubGroupSp > & getSubGroupSpList () const
 GrpGroup (GrpSubGroupSp &grpSubGroupSp)
GrpGroupSp makeGrpGroupSp ()
bool removeFirstNonInformativeSubGroup ()
void check () const

Private Attributes

std::list< GrpSubGroupSpm_subGroupList
unsigned int m_groupNumber = 0
GrpPeptideSet m_peptideSet
GrpMapPeptideToSubGroupSet m_mapPeptideToSubGroupSet

Friends

class GrpExperiment

Detailed Description

Definition at line 43 of file grpgroup.h.

Constructor & Destructor Documentation

◆ GrpGroup() [1/2]

GrpGroup::GrpGroup ( GrpSubGroupSp & grpSubGroupSp)
protected

Definition at line 37 of file grpgroup.cpp.

38{
39 m_peptideSet.addAll(grpSubGroupSp.get()->getPeptideSet());
40 m_subGroupList.push_back(grpSubGroupSp);
41 m_mapPeptideToSubGroupSet.add(grpSubGroupSp.get());
42}
std::list< GrpSubGroupSp > m_subGroupList
Definition grpgroup.h:48
GrpMapPeptideToSubGroupSet m_mapPeptideToSubGroupSet
Definition grpgroup.h:52
GrpPeptideSet m_peptideSet
Definition grpgroup.h:50
const GrpPeptideSet & getPeptideSet() const

References pappso::GrpSubGroup::getPeptideSet(), m_mapPeptideToSubGroupSet, m_peptideSet, and m_subGroupList.

Referenced by GrpGroup(), addGroup(), and operator<().

◆ GrpGroup() [2/2]

GrpGroup::GrpGroup ( const GrpGroup & grpGroupSp)

Definition at line 43 of file grpgroup.cpp.

44 : m_subGroupList(other.m_subGroupList),
45 m_peptideSet(other.m_peptideSet),
46 m_mapPeptideToSubGroupSet(other.m_mapPeptideToSubGroupSet)
47{
48}

References GrpGroup(), m_mapPeptideToSubGroupSet, m_peptideSet, and m_subGroupList.

◆ ~GrpGroup()

GrpGroup::~GrpGroup ( )

Definition at line 50 of file grpgroup.cpp.

51{
52}

Member Function Documentation

◆ addGroup()

void GrpGroup::addGroup ( GrpGroup * p_group_to_add)

Definition at line 110 of file grpgroup.cpp.

111{
112 if(this == p_group_to_add)
113 {
114 throw PappsoException(QObject::tr("addGroup ERROR, this == p_group_to_add"));
115 }
116
117 for(GrpSubGroupSp &sgToAdd : p_group_to_add->m_subGroupList)
118 {
119 addSubGroupSp(sgToAdd);
120 }
121}
void addSubGroupSp(const GrpSubGroupSp &grpSubGroupSp)
Definition grpgroup.cpp:147
std::shared_ptr< GrpSubGroup > GrpSubGroupSp
Definition grpsubgroup.h:39

References GrpGroup(), addSubGroupSp(), and m_subGroupList.

Referenced by pappso::GrpExperiment::addSubGroupSp().

◆ addSubGroupSp()

void GrpGroup::addSubGroupSp ( const GrpSubGroupSp & grpSubGroupSp)

Definition at line 147 of file grpgroup.cpp.

148{
149
150 qDebug() << "GrpGroup::addSubGroupSp begin " << grpSubGroupSp.get()->getFirstAccession();
151
152
153 // look for impacted subgroups (containing peptides alsoe present in incoming
154 // subgroup
155 GrpSubGroupSet impacted_subgroup_list;
156 m_mapPeptideToSubGroupSet.getSubGroupSet(grpSubGroupSp.get()->getPeptideSet(),
157 impacted_subgroup_list);
158 if(impacted_subgroup_list.contains(grpSubGroupSp.get()))
159 {
160 throw PappsoException(QObject::tr("addSubGroupSp ERROR, subgroup %1 is already in group")
161 .arg(grpSubGroupSp.get()->getFirstAccession()));
162 }
163
164 // look for impacted subgroup equal to incoming subgroup and merge it and exit
165 qDebug() << "GrpGroup::addSubGroupSp look for impacted subgroup equal to "
166 "incoming subgroup and merge it and exit";
167 auto it_impacted_sg = impacted_subgroup_list.m_grpSubGroupPtrList.begin();
168 auto it_impacted_sg_end = impacted_subgroup_list.m_grpSubGroupPtrList.end();
169 while(it_impacted_sg != it_impacted_sg_end)
170 {
171
172 if((*it_impacted_sg)->merge(grpSubGroupSp.get()))
173 {
174 qDebug() << "GrpGroup::addSubGroupSp merge";
175 return;
176 }
177 it_impacted_sg++;
178 }
179
180 // look for impacted subgroup including totally the incoming subgroup and exit
181 qDebug() << "GrpGroup::addSubGroupSp look for impacted subgroup including "
182 "totally the incoming subgroup and exit";
183 it_impacted_sg = impacted_subgroup_list.m_grpSubGroupPtrList.begin();
184 while(it_impacted_sg != it_impacted_sg_end)
185 {
186 if((*it_impacted_sg)->includes(grpSubGroupSp.get()))
187 {
188 qDebug() << "GrpGroup::addSubGroupSp includes";
189 return;
190 }
191 it_impacted_sg++;
192 }
193
194 // look for impacted subgroup totally included in incoming subgroup and remove
195 // it
196 qDebug() << "GrpGroup::addSubGroupSp look for impacted subgroup totally "
197 "included in incoming subgroup and remove it";
198 it_impacted_sg = impacted_subgroup_list.m_grpSubGroupPtrList.begin();
199 while(it_impacted_sg != it_impacted_sg_end)
200 {
201 if(grpSubGroupSp.get()->includes((*it_impacted_sg)))
202 {
203 // this->removeSubGroup(*it_impacted_sg);
204 // it_impacted_sg = impacted_subgroup_list.erase(it_impacted_sg);
205 GrpSubGroup *sg_to_remove = *it_impacted_sg;
206 it_impacted_sg = impacted_subgroup_list.erase(it_impacted_sg);
207 m_mapPeptideToSubGroupSet.remove(sg_to_remove);
208 m_subGroupList.remove_if([sg_to_remove](GrpSubGroupSp &sub_groupSp) {
209 return (sg_to_remove == sub_groupSp.get());
210 });
211 // m_mapPeptideToSubGroupSet.check(m_subGroupList);
212 }
213 else
214 {
215 it_impacted_sg++;
216 }
217 }
218 qDebug() << "GrpGroup::addSubGroupSp finally add the new subgroup to current group";
219
220 // finally add the new subgroup to current group
221 m_subGroupList.push_back(grpSubGroupSp);
222 m_mapPeptideToSubGroupSet.add(grpSubGroupSp.get());
223 m_peptideSet.addAll(grpSubGroupSp.get()->getPeptideSet());
224
225
226 // check();
227 // m_mapPeptideToSubGroupSet.check(m_subGroupList);
228
229 qDebug() << "GrpGroup::addSubGroupSp end";
230}
bool contains(GrpSubGroup *get) const
std::list< GrpSubGroup * >::iterator erase(std::list< GrpSubGroup * >::iterator it)
std::list< GrpSubGroup * > m_grpSubGroupPtrList
bool includes(const GrpSubGroup *p_subgroup) const
const QString & getFirstAccession() const

References pappso::GrpSubGroupSet::contains(), pappso::GrpSubGroupSet::erase(), pappso::GrpSubGroup::getFirstAccession(), pappso::GrpSubGroup::getPeptideSet(), pappso::GrpSubGroup::includes(), pappso::GrpSubGroupSet::m_grpSubGroupPtrList, m_mapPeptideToSubGroupSet, m_peptideSet, and m_subGroupList.

Referenced by addGroup(), and pappso::GrpExperiment::addSubGroupSp().

◆ check()

void GrpGroup::check ( ) const
protected

Definition at line 124 of file grpgroup.cpp.

125{
126 qDebug() << "GrpGroup::check begin ";
127 GrpSubGroupSet impacted_subgroup_list;
128 m_mapPeptideToSubGroupSet.getSubGroupSet(this->m_peptideSet, impacted_subgroup_list);
129
130 // if (impacted_subgroup_list.size() != this->m_subGroupList.size()) {
131 qDebug() << "GrpGroup::check impacted_subgroup_list.size() != "
132 "this->m_subGroupList.size()";
133 qDebug() << impacted_subgroup_list.printInfos();
134
135 for(auto sg : m_subGroupList)
136 {
137 qDebug() << sg->getFirstAccession() << " " << sg.get();
138 }
139 //}
140 qDebug() << m_mapPeptideToSubGroupSet.printInfos();
141 qDebug() << m_peptideSet.printInfos();
142 qDebug() << "GrpGroup::check end ";
143}
const QString printInfos() const

References m_mapPeptideToSubGroupSet, m_peptideSet, m_subGroupList, and pappso::GrpSubGroupSet::printInfos().

◆ containsAny()

bool GrpGroup::containsAny ( const GrpPeptideSet & peptideSet) const

Definition at line 103 of file grpgroup.cpp.

104{
105
106 return m_peptideSet.containsAny(peptideSet);
107}

References m_peptideSet.

Referenced by ContainsAny::operator()(), and pappso::GrpExperiment::startGrouping().

◆ getGroupingId()

const QString GrpGroup::getGroupingId ( ) const

Definition at line 82 of file grpgroup.cpp.

83{
84 if(m_groupNumber == 0)
85 {
86 return "";
87 }
88 return QString("%1").arg(Utils::getLexicalOrderedString(m_groupNumber));
89}
unsigned int m_groupNumber
Definition grpgroup.h:49
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72

References pappso::Utils::getLexicalOrderedString(), and m_groupNumber.

◆ getGroupNumber()

unsigned int GrpGroup::getGroupNumber ( ) const

Definition at line 77 of file grpgroup.cpp.

78{
79 return m_groupNumber;
80}

References m_groupNumber.

◆ getGrpPeptideSet()

const GrpPeptideSet & GrpGroup::getGrpPeptideSet ( ) const

Definition at line 72 of file grpgroup.cpp.

73{
74 return m_peptideSet;
75}

References m_peptideSet.

◆ getGrpSubGroupSpList()

std::vector< GrpSubGroupSpConst > GrpGroup::getGrpSubGroupSpList ( ) const

Definition at line 55 of file grpgroup.cpp.

56{
57 std::vector<GrpSubGroupSpConst> subgroup_list;
58 for(GrpSubGroupSp subgroup : m_subGroupList)
59 {
60 subgroup_list.push_back(subgroup);
61 }
62 return subgroup_list;
63};

References m_subGroupList.

◆ getSubGroupSpList()

const std::list< GrpSubGroupSp > & GrpGroup::getSubGroupSpList ( ) const
protected

Definition at line 66 of file grpgroup.cpp.

67{
68 return m_subGroupList;
69}

References m_subGroupList.

Referenced by pappso::GrpExperiment::removeNonInformativeSubGroups().

◆ makeGrpGroupSp()

GrpGroupSp GrpGroup::makeGrpGroupSp ( )
protected

Definition at line 97 of file grpgroup.cpp.

98{
99 return std::make_shared<GrpGroup>(*this);
100}

Referenced by pappso::GrpExperiment::addSubGroupSp().

◆ numbering()

void GrpGroup::numbering ( )

Definition at line 248 of file grpgroup.cpp.

249{
250 qDebug() << "GrpGroup::numbering begin";
251
252 for(auto &&sub_group_sp : m_subGroupList)
253 {
254 sub_group_sp.get()->numbering();
255 }
256 m_subGroupList.sort(
257 [](GrpSubGroupSp &first, GrpSubGroupSp &second) { return ((*first.get()) < (*second.get())); });
258 unsigned int i = 1;
259 for(auto &&sub_group_sp : m_subGroupList)
260 {
261 sub_group_sp.get()->setSubGroupNumber(i);
262 i++;
263 }
264
265 m_peptideSet.numbering();
266 qDebug() << "GrpGroup::numbering end";
267}

References m_peptideSet, and m_subGroupList.

◆ operator<()

bool GrpGroup::operator< ( const GrpGroup & other) const

Definition at line 90 of file grpgroup.cpp.

92{
93 return ((*(m_subGroupList.begin()->get())) < (*(other.m_subGroupList.begin()->get())));
94}

References GrpGroup(), and m_subGroupList.

◆ removeFirstNonInformativeSubGroup()

bool GrpGroup::removeFirstNonInformativeSubGroup ( )
protected

Definition at line 271 of file grpgroup.cpp.

272{
273 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup begin";
274 std::list<GrpSubGroup *> subgroup_list_to_remove;
275
276 for(auto &&sub_group_sp : m_subGroupList)
277 {
278 if(m_mapPeptideToSubGroupSet.hasSpecificPeptide(sub_group_sp.get()))
279 {
280 }
281 else
282 {
283 subgroup_list_to_remove.push_back(sub_group_sp.get());
284 }
285 }
286 if(subgroup_list_to_remove.size() == 0)
287 {
288 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup end false";
289 return false;
290 }
291
292 // sort subgroup to remove
293 subgroup_list_to_remove.sort(
294 [](GrpSubGroup *first, GrpSubGroup *second) { return ((*first) < (*second)); });
295
296 // remove the last one
297 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup "
298 "subgroup_list_to_remove.front()->peptideListSize() "
299 << subgroup_list_to_remove.front()->peptideListSize();
300 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup "
301 "subgroup_list_to_remove.back()->peptideListSize() "
302 << subgroup_list_to_remove.back()->peptideListSize();
303
304 // the first subgroup is weaker (less peptides or less protein than others)
305 GrpSubGroup *sg_to_remove = subgroup_list_to_remove.front();
306 m_mapPeptideToSubGroupSet.remove(sg_to_remove);
307 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup m_subGroupList.size() "
308 << m_subGroupList.size();
309 m_subGroupList.remove_if(
310 [sg_to_remove](GrpSubGroupSp &sub_groupSp) { return (sg_to_remove == sub_groupSp.get()); });
311 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup after remove if "
312 "m_subGroupList.size() "
313 << m_subGroupList.size();
314 qDebug() << "GrpGroup::removeFirstNonInformativeSubGroup end true";
315 return true;
316}

References m_mapPeptideToSubGroupSet, and m_subGroupList.

Referenced by removeNonInformativeSubGroups().

◆ removeNonInformativeSubGroups()

bool GrpGroup::removeNonInformativeSubGroups ( )

Definition at line 319 of file grpgroup.cpp.

320{
321 qDebug() << "GrpGroup::removeNonInformativeSubGroups begin";
323 {
325 {
326 qDebug() << "GrpGroup::removeNonInformativeSubGroups while";
327 }
328 }
329 else
330 {
331 return false;
332 }
333 return true;
334}
bool removeFirstNonInformativeSubGroup()
Definition grpgroup.cpp:271

References removeFirstNonInformativeSubGroup().

◆ setGroupNumber()

void GrpGroup::setGroupNumber ( unsigned int i)

Definition at line 234 of file grpgroup.cpp.

235{
236 qDebug() << "GrpGroup::setGroupNumber begin";
237 m_groupNumber = i;
238 for(auto &&sub_group_sp : m_subGroupList)
239 {
240 sub_group_sp->setGroupNumber(i);
241 }
242 m_peptideSet.setGroupNumber(i);
243 qDebug() << "GrpGroup::setGroupNumber end";
244}

References m_groupNumber, m_peptideSet, and m_subGroupList.

◆ GrpExperiment

friend class GrpExperiment
friend

Definition at line 45 of file grpgroup.h.

References GrpExperiment.

Referenced by GrpExperiment.

Member Data Documentation

◆ m_groupNumber

unsigned int pappso::GrpGroup::m_groupNumber = 0
private

Definition at line 49 of file grpgroup.h.

Referenced by getGroupingId(), getGroupNumber(), and setGroupNumber().

◆ m_mapPeptideToSubGroupSet

GrpMapPeptideToSubGroupSet pappso::GrpGroup::m_mapPeptideToSubGroupSet
private

◆ m_peptideSet

GrpPeptideSet pappso::GrpGroup::m_peptideSet
private

◆ m_subGroupList


The documentation for this class was generated from the following files: