libpappsomspp
Library for mass spectrometry
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
void add(GrpSubGroup *p_add_sub_group)
add in the map all peptides of the subgroup to add
void addAll(const GrpPeptideSet &peptideSet)

References pappso::GrpMapPeptideToSubGroupSet::add(), pappso::GrpPeptideSet::addAll(), m_mapPeptideToSubGroupSet, m_peptideSet, and m_subGroupList.

◆ 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 }

◆ ~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 111 of file grpgroup.cpp.

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

References addSubGroupSp(), and m_subGroupList.

◆ addSubGroupSp()

void GrpGroup::addSubGroupSp ( const GrpSubGroupSp grpSubGroupSp)

Definition at line 150 of file grpgroup.cpp.

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

References pappso::GrpMapPeptideToSubGroupSet::add(), pappso::GrpPeptideSet::addAll(), pappso::GrpSubGroupSet::contains(), pappso::GrpSubGroupSet::erase(), pappso::GrpMapPeptideToSubGroupSet::getSubGroupSet(), pappso::GrpSubGroupSet::m_grpSubGroupPtrList, m_mapPeptideToSubGroupSet, m_peptideSet, m_subGroupList, and pappso::GrpMapPeptideToSubGroupSet::remove().

Referenced by addGroup().

◆ check()

void GrpGroup::check ( ) const
protected

Definition at line 126 of file grpgroup.cpp.

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

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

◆ containsAny()

bool GrpGroup::containsAny ( const GrpPeptideSet peptideSet) const

Definition at line 104 of file grpgroup.cpp.

105 {
106 
107  return m_peptideSet.containsAny(peptideSet);
108 }
bool containsAny(const GrpPeptideSet &peptideSet) const

References pappso::GrpPeptideSet::containsAny(), and m_peptideSet.

◆ 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:52

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.

◆ makeGrpGroupSp()

GrpGroupSp GrpGroup::makeGrpGroupSp ( )
protected

Definition at line 98 of file grpgroup.cpp.

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

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

◆ numbering()

void GrpGroup::numbering ( )

Definition at line 254 of file grpgroup.cpp.

255 {
256  qDebug() << "GrpGroup::numbering begin";
257 
258  for(auto &&sub_group_sp : m_subGroupList)
259  {
260  sub_group_sp.get()->numbering();
261  }
262  m_subGroupList.sort([](GrpSubGroupSp &first, GrpSubGroupSp &second) {
263  return ((*first.get()) < (*second.get()));
264  });
265  unsigned int i = 1;
266  for(auto &&sub_group_sp : m_subGroupList)
267  {
268  sub_group_sp.get()->setSubGroupNumber(i);
269  i++;
270  }
271 
273  qDebug() << "GrpGroup::numbering end";
274 }

References m_peptideSet, m_subGroupList, and pappso::GrpPeptideSet::numbering().

◆ operator<()

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

Definition at line 90 of file grpgroup.cpp.

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

References m_subGroupList.

◆ removeFirstNonInformativeSubGroup()

bool GrpGroup::removeFirstNonInformativeSubGroup ( )
protected

Definition at line 278 of file grpgroup.cpp.

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

References pappso::GrpMapPeptideToSubGroupSet::hasSpecificPeptide(), m_mapPeptideToSubGroupSet, m_subGroupList, and pappso::GrpMapPeptideToSubGroupSet::remove().

Referenced by removeNonInformativeSubGroups().

◆ removeNonInformativeSubGroups()

bool GrpGroup::removeNonInformativeSubGroups ( )

Definition at line 329 of file grpgroup.cpp.

330 {
331  qDebug() << "GrpGroup::removeNonInformativeSubGroups begin";
333  {
335  {
336  qDebug() << "GrpGroup::removeNonInformativeSubGroups while";
337  }
338  }
339  else
340  {
341  return false;
342  }
343  return true;
344 }
bool removeFirstNonInformativeSubGroup()
Definition: grpgroup.cpp:278

References removeFirstNonInformativeSubGroup().

◆ setGroupNumber()

void GrpGroup::setGroupNumber ( unsigned int  i)

Definition at line 240 of file grpgroup.cpp.

241 {
242  qDebug() << "GrpGroup::setGroupNumber begin";
243  m_groupNumber = i;
244  for(auto &&sub_group_sp : m_subGroupList)
245  {
246  sub_group_sp->setGroupNumber(i);
247  }
249  qDebug() << "GrpGroup::setGroupNumber end";
250 }
void setGroupNumber(unsigned int i)

References m_groupNumber, m_peptideSet, m_subGroupList, and pappso::GrpPeptideSet::setGroupNumber().

Friends And Related Function Documentation

◆ GrpExperiment

friend class GrpExperiment
friend

Definition at line 45 of file grpgroup.h.

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

Definition at line 52 of file grpgroup.h.

Referenced by GrpGroup(), addSubGroupSp(), check(), and removeFirstNonInformativeSubGroup().

◆ m_peptideSet

GrpPeptideSet pappso::GrpGroup::m_peptideSet
private

◆ m_subGroupList

std::list<GrpSubGroupSp> pappso::GrpGroup::m_subGroupList
private

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