libpappsomspp
Library for mass spectrometry
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;
29GrpPeptideSet::GrpPeptideSet()
30{
31}
33{
34 auto it = p_protein->begin();
35 while(it != p_protein->end())
36 {
37 m_peptidePtrList.push_back(*it);
38 it++;
39 }
40}
42 : m_peptidePtrList(other.m_peptidePtrList)
43{
44}
45
47{
48}
49
52{
54 return *this;
55}
56
57bool
59{
60 if(m_peptidePtrList.size() != other.m_peptidePtrList.size())
61 {
62 return false;
63 }
64 return privContainsAll(other);
65}
66
67bool
68GrpPeptideSet::contains(const GrpPeptide *p_grp_peptide) const
69{
70 if(std::find(m_peptidePtrList.begin(),
71 m_peptidePtrList.end(),
72 p_grp_peptide) == m_peptidePtrList.end())
73 {
74 return false;
75 }
76 return true;
77}
78
79bool
80GrpPeptideSet::containsAll(const GrpPeptideSet &peptideSetIn) const
81{
82 if(m_peptidePtrList.size() < peptideSetIn.m_peptidePtrList.size())
83 {
84 return false;
85 }
86 return privContainsAll(peptideSetIn);
87}
88
89bool
91{
92 if(m_peptidePtrList.size() > peptideSetIn.m_peptidePtrList.size())
93 {
94 return privContainsAll(peptideSetIn);
95 }
96 return false;
97}
98
99bool
101{
102 std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
103 innerIt = peptideSetIn.m_peptidePtrList.begin();
104 innerEnd = peptideSetIn.m_peptidePtrList.end();
105 outerIt = m_peptidePtrList.begin();
106 outerEnd = m_peptidePtrList.end();
107
108
109 while((innerIt != innerEnd) && (outerIt != outerEnd))
110 {
111 if(*innerIt > *outerIt)
112 {
113 outerIt++;
114 continue;
115 }
116 if(*innerIt < *outerIt)
117 {
118 return false;
119 }
120 if(*innerIt == *outerIt)
121 {
122 innerIt++;
123 outerIt++;
124 }
125 }
126 if(innerIt == innerEnd)
127 {
128 return true;
129 }
130 return false;
131}
132
133bool
135{
136 std::list<GrpPeptide *>::const_iterator innerIt, outerIt, innerEnd, outerEnd;
137
138 innerIt = peptideSetIn.m_peptidePtrList.begin();
139 innerEnd = peptideSetIn.m_peptidePtrList.end();
140 outerIt = m_peptidePtrList.begin();
141 outerEnd = m_peptidePtrList.end();
142
143
144 while((innerIt != innerEnd) && (outerIt != outerEnd))
145 {
146 if(*innerIt > *outerIt)
147 {
148 outerIt++;
149 continue;
150 }
151 if(*innerIt < *outerIt)
152 {
153 innerIt++;
154 continue;
155 }
156 if(*innerIt == *outerIt)
157 {
158 return true;
159 }
160 }
161 return false;
162}
163
164void
166{
167
168 qDebug() << "GrpPeptideSet::addAll begin";
169 std::list<GrpPeptide *>::iterator it(m_peptidePtrList.begin());
170 std::list<GrpPeptide *>::iterator itEnd(m_peptidePtrList.end());
171 std::list<GrpPeptide *>::const_iterator itIn(
172 peptideSetIn.m_peptidePtrList.begin());
173 std::list<GrpPeptide *>::const_iterator itInEnd(
174 peptideSetIn.m_peptidePtrList.end());
175
176 while((itIn != itInEnd) && (it != itEnd))
177 {
178 if(*itIn > *it)
179 {
180 it++;
181 continue;
182 }
183 if(*itIn < *it)
184 {
185 it = m_peptidePtrList.insert(it, *itIn);
186 it++;
187 itIn++;
188 continue;
189 }
190 if(*itIn == *it)
191 {
192 itIn++;
193 it++;
194 }
195 }
196 while(itIn != itInEnd)
197 {
198 m_peptidePtrList.push_back(*itIn);
199 itIn++;
200 }
201 qDebug() << "GrpPeptideSet::addAll end";
202}
203
204
205void
207{
208 qDebug() << "GrpPeptideSet::numbering begin";
209
210 m_peptidePtrList.sort([](GrpPeptide *first, GrpPeptide *second) {
211 return ((*first) < (*second));
212 });
213 unsigned int i = 1;
214 for(auto &&p_grp_peptide : m_peptidePtrList)
215 {
216 p_grp_peptide->setRank(i);
217 i++;
218 }
219
220 qDebug() << "GrpPeptideSet::numbering end";
221}
222
223
224void
226{
227 qDebug() << "GrpPeptideSet::setGroupNumber begin";
228 for(auto &&p_grp_peptide : m_peptidePtrList)
229 {
230 p_grp_peptide->setGroupNumber(i);
231 }
232
233 qDebug() << "GrpPeptideSet::setGroupNumber end";
234}
235
236std::vector<const GrpPeptide *>
238{
239 std::vector<const GrpPeptide *> peptide_list;
240 for(GrpPeptide *peptide : m_peptidePtrList)
241 {
242 peptide_list.push_back(peptide);
243 }
244 return peptide_list;
245}
246
247const QString
249{
250 QString infos;
251 std::list<GrpPeptide *>::const_iterator it(m_peptidePtrList.begin()),
252 itEnd(m_peptidePtrList.end());
253
254
255 while(it != itEnd)
256 {
257 infos.append((*it)->getSequence() + " " +
258 QString("0x%1").arg(
259 (quintptr)*it, QT_POINTER_SIZE * 2, 16, QChar('0')) +
260 "\n");
261 it++;
262 }
263
264 return infos;
265}
std::list< GrpPeptide * > m_peptidePtrList
Definition: grppeptideset.h:41
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
Definition: grpprotein.cpp:62
const_iterator begin() const
Definition: grpprotein.cpp:57
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39