libpappsomspp
Library for mass spectrometry
pappso::GrpMapPeptideToSubGroupSet Class Reference

#include <grpmappeptidetosubgroupset.h>

Public Member Functions

 GrpMapPeptideToSubGroupSet ()
 
 GrpMapPeptideToSubGroupSet (const GrpMapPeptideToSubGroupSet &other)
 
 ~GrpMapPeptideToSubGroupSet ()
 
void getSubGroupSet (const GrpPeptideSet &peptide_set_in, GrpSubGroupSet &impacted_subgroup_set) const
 get all subgroups concerned by a list of peptides More...
 
void remove (GrpSubGroup *p_remove_sub_group)
 removes in the map all references of the group to remove (p_remove_sub_group) More...
 
void add (GrpSubGroup *p_add_sub_group)
 add in the map all peptides of the subgroup to add More...
 
bool hasSpecificPeptide (const GrpSubGroup *get) const
 tells if this subgroup contains a specific peptide More...
 
void check (std::list< GrpSubGroupSp > &m_grpSubGroupSpList) const
 check function only usefull for testing purpose More...
 
unsigned int size () const
 
const QString printInfos () const
 

Private Attributes

std::map< GrpPeptide *, GrpSubGroupSetm_mapPeptideToSubGroupSet
 

Detailed Description

Definition at line 36 of file grpmappeptidetosubgroupset.h.

Constructor & Destructor Documentation

◆ GrpMapPeptideToSubGroupSet() [1/2]

pappso::GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet ( )

Definition at line 35 of file grpmappeptidetosubgroupset.cpp.

36 {
37 }

◆ GrpMapPeptideToSubGroupSet() [2/2]

pappso::GrpMapPeptideToSubGroupSet::GrpMapPeptideToSubGroupSet ( const GrpMapPeptideToSubGroupSet other)

Definition at line 43 of file grpmappeptidetosubgroupset.cpp.

45  : m_mapPeptideToSubGroupSet(other.m_mapPeptideToSubGroupSet)
46 {
47 }
std::map< GrpPeptide *, GrpSubGroupSet > m_mapPeptideToSubGroupSet

◆ ~GrpMapPeptideToSubGroupSet()

pappso::GrpMapPeptideToSubGroupSet::~GrpMapPeptideToSubGroupSet ( )

Definition at line 39 of file grpmappeptidetosubgroupset.cpp.

40 {
41 }

Member Function Documentation

◆ add()

void pappso::GrpMapPeptideToSubGroupSet::add ( GrpSubGroup p_add_sub_group)

add in the map all peptides of the subgroup to add

Definition at line 143 of file grpmappeptidetosubgroupset.cpp.

144 {
145  qDebug()
146  << "GrpMapPeptideToSubGroupSet::add begin m_mapPeptideToSubGroupSet.size()"
147  << m_mapPeptideToSubGroupSet.size();
148 
149 
150  const GrpPeptideSet &peptide_set_in = p_add_sub_group->getPeptideSet();
151 
152  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
153 
154  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
155  it_peptide != it_peptide_end;
156  it_peptide++)
157  {
158  std::pair<std::map<GrpPeptide *, GrpSubGroupSet>::iterator, bool> ret =
160  std::pair<GrpPeptide *, GrpSubGroupSet>(*it_peptide,
161  GrpSubGroupSet()));
162  // if (ret.second==false) { => key already exists
163  ret.first->second.add(p_add_sub_group);
164  }
165 
166  qDebug() << "GrpMapPeptideToSubGroupSet::add end";
167 }

References pappso::GrpSubGroup::getPeptideSet(), m_mapPeptideToSubGroupSet, and pappso::GrpPeptideSet::m_peptidePtrList.

Referenced by pappso::GrpGroup::GrpGroup(), and pappso::GrpGroup::addSubGroupSp().

◆ check()

void pappso::GrpMapPeptideToSubGroupSet::check ( std::list< GrpSubGroupSp > &  m_grpSubGroupSpList) const

check function only usefull for testing purpose

Definition at line 78 of file grpmappeptidetosubgroupset.cpp.

80 {
81  qDebug() << "GrpMapPeptideToSubGroupSet::std begin ";
82  GrpMapPeptideToSubGroupSet test(*this);
83  qDebug() << "GrpMapPeptideToSubGroupSet::std before test.size() "
84  << test.size();
85 
86  for(auto pair : m_mapPeptideToSubGroupSet)
87  {
88  qDebug() << "GrpMapPeptideToSubGroupSet::std before peptide "
89  << pair.first->getSequence() << " " << pair.first;
90  }
91 
92  for(GrpSubGroupSp &sub_group_sp : m_grpSubGroupSpList)
93  {
94  test.remove(sub_group_sp.get());
95  }
96  qDebug() << "GrpMapPeptideToSubGroupSet::std after test.size() "
97  << test.size();
98 
99  qDebug() << "GrpMapPeptideToSubGroupSet::std begin ";
100 }
std::shared_ptr< GrpSubGroup > GrpSubGroupSp
Definition: grpsubgroup.h:39

References m_mapPeptideToSubGroupSet, remove(), and size().

◆ getSubGroupSet()

void pappso::GrpMapPeptideToSubGroupSet::getSubGroupSet ( const GrpPeptideSet peptide_set_in,
GrpSubGroupSet impacted_subgroup_set 
) const

get all subgroups concerned by a list of peptides

Definition at line 55 of file grpmappeptidetosubgroupset.cpp.

58 {
59  qDebug() << "GrpMapPeptideToSubGroupSet::getSubGroupSet begin ";
60  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
61  std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
63 
64  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
65  it_peptide != it_peptide_end;
66  it_peptide++)
67  {
68  std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map =
69  m_mapPeptideToSubGroupSet.find(*it_peptide);
70  if(it_map != it_map_end)
71  {
72  impacted_subgroup_set.addAll(it_map->second);
73  }
74  }
75  qDebug() << "GrpMapPeptideToSubGroupSet::getSubGroupSet end ";
76 }

References pappso::GrpSubGroupSet::addAll(), m_mapPeptideToSubGroupSet, and pappso::GrpPeptideSet::m_peptidePtrList.

Referenced by pappso::GrpGroup::addSubGroupSp(), and pappso::GrpGroup::check().

◆ hasSpecificPeptide()

bool pappso::GrpMapPeptideToSubGroupSet::hasSpecificPeptide ( const GrpSubGroup get) const

tells if this subgroup contains a specific peptide

Definition at line 171 of file grpmappeptidetosubgroupset.cpp.

173 {
174  qDebug() << "GrpMapPeptideToSubGroupSet::hasSpecificPeptide begin";
175 
176  const GrpPeptideSet &peptide_set_in = p_sub_group->getPeptideSet();
177 
178  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
179  std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
181 
182  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
183  it_peptide != it_peptide_end;
184  it_peptide++)
185  {
186  std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map =
187  m_mapPeptideToSubGroupSet.find(*it_peptide);
188  if(it_map != it_map_end)
189  {
190  if(it_map->second.size() == 1)
191  {
192  return true;
193  }
194  }
195  else
196  {
197  throw PappsoException(
198  QObject::tr("hasSpecificPeptide ERROR, peptide %1 from subgroup %2 "
199  "not referenced in GrpMapPeptideToSubGroupSet")
200  .arg((*it_peptide)->getSequence())
201  .arg(p_sub_group->getFirstAccession()));
202  }
203  }
204 
205  qDebug() << "GrpMapPeptideToSubGroupSet::hasSpecificPeptide end";
206  return false;
207 }

References pappso::GrpSubGroup::getFirstAccession(), pappso::GrpSubGroup::getPeptideSet(), m_mapPeptideToSubGroupSet, and pappso::GrpPeptideSet::m_peptidePtrList.

Referenced by pappso::GrpGroup::removeFirstNonInformativeSubGroup().

◆ printInfos()

const QString pappso::GrpMapPeptideToSubGroupSet::printInfos ( ) const

Definition at line 210 of file grpmappeptidetosubgroupset.cpp.

211 {
212  QString infos;
213  auto itMap = m_mapPeptideToSubGroupSet.begin();
214  auto itMapEnd = m_mapPeptideToSubGroupSet.end();
215 
216  while(itMap != itMapEnd)
217  {
218  infos.append(
219  itMap->first->getSequence() + " " +
220  QString("0x%1").arg(
221  (quintptr)itMap->first, QT_POINTER_SIZE * 2, 16, QChar('0')) +
222  "\n");
223  itMap++;
224  }
225 
226  return infos;
227 }

References m_mapPeptideToSubGroupSet.

Referenced by pappso::GrpGroup::check().

◆ remove()

void pappso::GrpMapPeptideToSubGroupSet::remove ( GrpSubGroup p_remove_sub_group)

removes in the map all references of the group to remove (p_remove_sub_group)

Definition at line 103 of file grpmappeptidetosubgroupset.cpp.

104 {
105  qDebug() << "GrpMapPeptideToSubGroupSet::remove begin "
106  << p_remove_sub_group->getFirstAccession();
107  // std::list<std::pair<GrpPeptide*, GrpSubGroupSet>>
108  // m_mapPeptideToSubGroupSet;
109  const GrpPeptideSet &peptide_set_in = p_remove_sub_group->getPeptideSet();
110 
111  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
112  std::map<GrpPeptide *, GrpSubGroupSet>::const_iterator it_map_end =
114 
115  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
116  it_peptide != it_peptide_end;
117  it_peptide++)
118  {
119  std::map<GrpPeptide *, GrpSubGroupSet>::iterator it_map =
120  m_mapPeptideToSubGroupSet.find(*it_peptide);
121  if(it_map != it_map_end)
122  {
123  it_map->second.remove(p_remove_sub_group);
124  if(it_map->second.size() == 0)
125  {
126  m_mapPeptideToSubGroupSet.erase(it_map);
127  }
128  }
129  else
130  {
131  throw PappsoException(
132  QObject::tr("remove ERROR, peptide %1 from subgroup %2 not "
133  "referenced in GrpMapPeptideToSubGroupSet")
134  .arg((*it_peptide)->getSequence())
135  .arg(p_remove_sub_group->getFirstAccession()));
136  }
137  }
138 
139  qDebug() << "GrpMapPeptideToSubGroupSet::remove end "
140  << p_remove_sub_group->getFirstAccession();
141 }

References pappso::GrpSubGroup::getFirstAccession(), pappso::GrpSubGroup::getPeptideSet(), m_mapPeptideToSubGroupSet, and pappso::GrpPeptideSet::m_peptidePtrList.

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

◆ size()

unsigned int pappso::GrpMapPeptideToSubGroupSet::size ( ) const

Referenced by check().

Member Data Documentation

◆ m_mapPeptideToSubGroupSet

std::map<GrpPeptide *, GrpSubGroupSet> pappso::GrpMapPeptideToSubGroupSet::m_mapPeptideToSubGroupSet
private

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