libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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
32
33namespace pappso
34{
35
39
44
48
49void
51 std::list<GrpGroupSp> &impacted_group_list) const
52{
53 auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
54 std::map<GrpPeptide *, GrpGroupSp>::const_iterator it_map_end = m_mapPeptideToGroup.end();
55
56 for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin(); it_peptide != it_peptide_end;
57 it_peptide++)
58 {
59 std::map<GrpPeptide *, GrpGroupSp>::const_iterator it_map =
60 m_mapPeptideToGroup.find(*it_peptide);
61 if(it_map != it_map_end)
62 {
63 impacted_group_list.push_back(it_map->second);
64 }
65 }
66 impacted_group_list.sort();
67 impacted_group_list.unique();
68}
69
70void
71GrpMapPeptideToGroup::set(const GrpPeptideSet &peptide_set_in, GrpGroupSp grp_group)
72{
73
74 auto it_peptide_end = peptide_set_in.m_peptidePtrList.end();
75
76 for(auto it_peptide = peptide_set_in.m_peptidePtrList.begin(); it_peptide != it_peptide_end;
77 it_peptide++)
78 {
79 std::pair<std::map<GrpPeptide *, GrpGroupSp>::iterator, bool> ret =
80 m_mapPeptideToGroup.insert(std::pair<GrpPeptide *, GrpGroupSp>(*it_peptide, grp_group));
81 if(ret.second == false)
82 { //=> key already exists : replace by grp_group
83 ret.first->second = grp_group;
84 }
85 }
86}
87void
88GrpMapPeptideToGroup::clear(std::list<GrpGroupSp> &grp_group_list)
89{
90
91 std::list<GrpGroupSp> new_list;
92 for(auto &pair_map : m_mapPeptideToGroup)
93 {
94 new_list.push_back(pair_map.second);
95 }
96 new_list.sort();
97 new_list.unique();
98
99 grp_group_list.splice(grp_group_list.end(), new_list);
100 m_mapPeptideToGroup.clear();
101}
102} // 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
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:39