libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
grppeptideset.cpp
Go to the documentation of this file.
1
2/*******************************************************************************
3 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
4 *
5 * This file is part of the PAPPSOms++ library.
6 *
7 * PAPPSOms++ is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * PAPPSOms++ is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Contributors:
21 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
22 *implementation
23 ******************************************************************************/
24
25#include <QDebug>
26#include "grppeptideset.h"
27
28using namespace pappso;
33{
34 auto it = p_protein->begin();
35 while(it != p_protein->end())
36 {
37 m_peptidePtrList.push_back(*it);
38 it++;
39 }
40}
44
48
51{
53 return *this;
54}
55
56bool
58{
59 if(m_peptidePtrList.size() != other.m_peptidePtrList.size())
60 {
61 return false;
62 }
63 return privContainsAll(other);
64}
65
66bool
67GrpPeptideSet::contains(const GrpPeptide *p_grp_peptide) const
68{
69 if(std::find(m_peptidePtrList.begin(), m_peptidePtrList.end(), p_grp_peptide) ==
70 m_peptidePtrList.end())
71 {
72 return false;
73 }
74 return true;
75}
76
77bool
78GrpPeptideSet::containsAll(const GrpPeptideSet &peptideSetIn) const
79{
80 if(m_peptidePtrList.size() < peptideSetIn.m_peptidePtrList.size())
81 {
82 return false;
83 }
84 return privContainsAll(peptideSetIn);
85}
86
87bool
89{
90 if(m_peptidePtrList.size() > peptideSetIn.m_peptidePtrList.size())
91 {
92 return privContainsAll(peptideSetIn);
93 }
94 return false;
95}
96
97bool
99{
100 std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
101 innerIt = peptideSetIn.m_peptidePtrList.begin();
102 innerEnd = peptideSetIn.m_peptidePtrList.end();
103 outerIt = m_peptidePtrList.begin();
104 outerEnd = m_peptidePtrList.end();
105
106
107 while((innerIt != innerEnd) && (outerIt != outerEnd))
108 {
109 if(*innerIt > *outerIt)
110 {
111 outerIt++;
112 continue;
113 }
114 if(*innerIt < *outerIt)
115 {
116 return false;
117 }
118 if(*innerIt == *outerIt)
119 {
120 innerIt++;
121 outerIt++;
122 }
123 }
124 if(innerIt == innerEnd)
125 {
126 return true;
127 }
128 return false;
129}
130
131bool
133{
134 std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
135
136 innerIt = peptideSetIn.m_peptidePtrList.begin();
137 innerEnd = peptideSetIn.m_peptidePtrList.end();
138 outerIt = m_peptidePtrList.begin();
139 outerEnd = m_peptidePtrList.end();
140
141
142 while((innerIt != innerEnd) && (outerIt != outerEnd))
143 {
144 if(*innerIt > *outerIt)
145 {
146 outerIt++;
147 continue;
148 }
149 if(*innerIt < *outerIt)
150 {
151 innerIt++;
152 continue;
153 }
154 if(*innerIt == *outerIt)
155 {
156 return true;
157 }
158 }
159 return false;
160}
161
162void
164{
165
166 qDebug() << "GrpPeptideSet::addAll begin";
167 std::list<GrpPeptide *>::iterator it(m_peptidePtrList.begin());
168 std::list<GrpPeptide *>::iterator itEnd(m_peptidePtrList.end());
169 std::list<GrpPeptide *>::const_iterator itIn(peptideSetIn.m_peptidePtrList.begin());
170 std::list<GrpPeptide *>::const_iterator itInEnd(peptideSetIn.m_peptidePtrList.end());
171
172 while((itIn != itInEnd) && (it != itEnd))
173 {
174 if(*itIn > *it)
175 {
176 it++;
177 continue;
178 }
179 if(*itIn < *it)
180 {
181 it = m_peptidePtrList.insert(it, *itIn);
182 it++;
183 itIn++;
184 continue;
185 }
186 if(*itIn == *it)
187 {
188 itIn++;
189 it++;
190 }
191 }
192 while(itIn != itInEnd)
193 {
194 m_peptidePtrList.push_back(*itIn);
195 itIn++;
196 }
197 qDebug() << "GrpPeptideSet::addAll end";
198}
199
200
201void
203{
204 qDebug() << "GrpPeptideSet::numbering begin";
205
206 m_peptidePtrList.sort(
207 [](GrpPeptide *first, GrpPeptide *second) { return ((*first) < (*second)); });
208 unsigned int i = 1;
209 for(auto &&p_grp_peptide : m_peptidePtrList)
210 {
211 p_grp_peptide->setRank(i);
212 i++;
213 }
214
215 qDebug() << "GrpPeptideSet::numbering end";
216}
217
218
219void
221{
222 qDebug() << "GrpPeptideSet::setGroupNumber begin";
223 for(auto &&p_grp_peptide : m_peptidePtrList)
224 {
225 p_grp_peptide->setGroupNumber(i);
226 }
227
228 qDebug() << "GrpPeptideSet::setGroupNumber end";
229}
230
231std::vector<const GrpPeptide *>
233{
234 std::vector<const GrpPeptide *> peptide_list;
235 for(GrpPeptide *peptide : m_peptidePtrList)
236 {
237 peptide_list.push_back(peptide);
238 }
239 return peptide_list;
240}
241
242const QString
244{
245 QString infos;
246 std::list<GrpPeptide *>::const_iterator it(m_peptidePtrList.begin()),
247 itEnd(m_peptidePtrList.end());
248
249
250 while(it != itEnd)
251 {
252 infos.append((*it)->getSequence() + " " +
253 QString("0x%1").arg((quintptr)*it, QT_POINTER_SIZE * 2, 16, QChar('0')) + "\n");
254 it++;
255 }
256
257 return infos;
258}
std::list< GrpPeptide * > m_peptidePtrList
const QString printInfos() const
void addAll(const GrpPeptideSet &peptideSet)
std::vector< const GrpPeptide * > getGrpPeptideList() const
bool operator==(const GrpPeptideSet &other) const
bool containsAny(const GrpPeptideSet &peptideSet) const
void setGroupNumber(unsigned int i)
GrpPeptideSet & operator=(const GrpPeptideSet &other)
bool biggerAndContainsAll(const GrpPeptideSet &peptideSet) const
bool contains(const GrpPeptide *p_grp_peptide) const
bool privContainsAll(const GrpPeptideSet &peptideSetIn) const
bool containsAll(const GrpPeptideSet &peptideSet) const
const_iterator end() const
const_iterator begin() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39