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 33 of file grpmappeptidetosubgroupset.cpp.

34{
35}

◆ GrpMapPeptideToSubGroupSet() [2/2]

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

Definition at line 41 of file grpmappeptidetosubgroupset.cpp.

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

◆ ~GrpMapPeptideToSubGroupSet()

pappso::GrpMapPeptideToSubGroupSet::~GrpMapPeptideToSubGroupSet ( )

Definition at line 37 of file grpmappeptidetosubgroupset.cpp.

38{
39}

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 141 of file grpmappeptidetosubgroupset.cpp.

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

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 76 of file grpmappeptidetosubgroupset.cpp.

78{
79 qDebug() << "GrpMapPeptideToSubGroupSet::std begin ";
81 qDebug() << "GrpMapPeptideToSubGroupSet::std before test.size() "
82 << test.size();
83
84 for(auto pair : m_mapPeptideToSubGroupSet)
85 {
86 qDebug() << "GrpMapPeptideToSubGroupSet::std before peptide "
87 << pair.first->getSequence() << " " << pair.first;
88 }
89
90 for(GrpSubGroupSp &sub_group_sp : m_grpSubGroupSpList)
91 {
92 test.remove(sub_group_sp.get());
93 }
94 qDebug() << "GrpMapPeptideToSubGroupSet::std after test.size() "
95 << test.size();
96
97 qDebug() << "GrpMapPeptideToSubGroupSet::std begin ";
98}
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 53 of file grpmappeptidetosubgroupset.cpp.

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

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 169 of file grpmappeptidetosubgroupset.cpp.

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

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 208 of file grpmappeptidetosubgroupset.cpp.

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

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 101 of file grpmappeptidetosubgroupset.cpp.

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

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: