libpappsomspp
Library for mass spectrometry
grpmappeptidetogroup.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/grouping/grpmappeptidegroup.cpp
3  * \date 15/12/2017
4  * \author Olivier Langella
5  * \brief keep trace of peptide to group assignment
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2017 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * Contributors:
27  * Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
28  *implementation
29  ******************************************************************************/
30 
31 #include "grpmappeptidetogroup.h"
32 
33 namespace pappso
34 {
35 
37 {
38 }
39 
41  : m_mapPeptideToGroup(other.m_mapPeptideToGroup)
42 {
43 }
44 
46 {
47 }
48 
49 void
51  const GrpPeptideSet &peptide_set_in,
52  std::list<GrpGroupSp> &impacted_group_list) const
53 {
54  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
55  std::map<GrpPeptide *, GrpGroupSp>::const_iterator it_map_end =
56  m_mapPeptideToGroup.end();
57 
58  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
59  it_peptide != it_peptide_end;
60  it_peptide++)
61  {
62  std::map<GrpPeptide *, GrpGroupSp>::const_iterator it_map =
63  m_mapPeptideToGroup.find(*it_peptide);
64  if(it_map != it_map_end)
65  {
66  impacted_group_list.push_back(it_map->second);
67  }
68  }
69  impacted_group_list.sort();
70  impacted_group_list.unique();
71 }
72 
73 void
75  GrpGroupSp grp_group)
76 {
77 
78  auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
79 
80  for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin();
81  it_peptide != it_peptide_end;
82  it_peptide++)
83  {
84  std::pair<std::map<GrpPeptide *, GrpGroupSp>::iterator, bool> ret =
85  m_mapPeptideToGroup.insert(
86  std::pair<GrpPeptide *, GrpGroupSp>(*it_peptide, grp_group));
87  if(ret.second == false)
88  { //=> key already exists : replace by grp_group
89  ret.first->second = grp_group;
90  }
91  }
92 }
93 void
94 GrpMapPeptideToGroup::clear(std::list<GrpGroupSp> &grp_group_list)
95 {
96 
97  std::list<GrpGroupSp> new_list;
98  for(auto &pair_map : m_mapPeptideToGroup)
99  {
100  new_list.push_back(pair_map.second);
101  }
102  new_list.sort();
103  new_list.unique();
104 
105  grp_group_list.splice(grp_group_list.end(), new_list);
106  m_mapPeptideToGroup.clear();
107 }
108 } // namespace pappso
void clear(std::list< GrpGroupSp > &grp_group_list)
std::map< GrpPeptide *, GrpGroupSp > m_mapPeptideToGroup
void getGroupList(const GrpPeptideSet &peptide_set_in, std::list< GrpGroupSp > &impacted_group_list) const
get all groups concerned by a list of peptides
void set(const GrpPeptideSet &peptide_set_in, GrpGroupSp grp_group)
set peptide keys pointing on the group
std::list< GrpPeptide * > m_peptidePtrList
Definition: grppeptideset.h:41
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< GrpGroup > GrpGroupSp
Definition: grpgroup.h:38