libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::PeptideIsotopeSpectrumMatch Class Reference

#include <peptideisotopespectrummatch.h>

Public Types

typedef std::list< PeakIonIsotopeMatch >::const_iterator const_iterator
 

Public Member Functions

 PeptideIsotopeSpectrumMatch (const MassSpectrum &spectrum, const PeptideSp &peptide_sp, unsigned int parent_charge, PrecisionPtr precision, const std::list< PeptideIon > &ion_type_list, unsigned int max_isotope_number, unsigned int max_isotope_rank)
 annotate spectrum with peptide ions and isotopes
 
 PeptideIsotopeSpectrumMatch (const MassSpectrum &spectrum, std::vector< PeptideNaturalIsotopeAverageSp > v_peptideIsotopeList, std::vector< PeptideFragmentIonSp > v_peptideIonList, PrecisionPtr precision)
 
 PeptideIsotopeSpectrumMatch (const PeptideIsotopeSpectrumMatch &other)
 
virtual ~PeptideIsotopeSpectrumMatch ()
 
const std::list< PeakIonIsotopeMatch > & getPeakIonIsotopeMatchList () const
 
std::size_t size () const
 
const_iterator begin () const
 
const_iterator end () const
 
void dropPeaksLackingMonoisotope ()
 

Private Member Functions

virtual std::vector< DataPoint >::iterator getBestPeakIterator (std::vector< DataPoint > &peak_list, const PeptideNaturalIsotopeAverage &ion) const
 

Private Attributes

PrecisionPtr _precision
 
std::list< PeakIonIsotopeMatch_peak_ion_match_list
 

Detailed Description

Definition at line 39 of file peptideisotopespectrummatch.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 71 of file peptideisotopespectrummatch.h.

Constructor & Destructor Documentation

◆ PeptideIsotopeSpectrumMatch() [1/3]

pappso::PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch ( const MassSpectrum spectrum,
const PeptideSp peptide_sp,
unsigned int  parent_charge,
PrecisionPtr  precision,
const std::list< PeptideIon > &  ion_type_list,
unsigned int  max_isotope_number,
unsigned int  max_isotope_rank 
)

annotate spectrum with peptide ions and isotopes

Parameters
spectrumthe spectrum to annotate
peptide_sppeptide to fragment
parent_chargecharge of the ion parent
precisionMS2 mass measurement precision
ion_listion types to compute fragments
max_isotope_numbermaximum isotope number to compute (0 means only monoisotope is computed)
max_isotope_rankmaximum rank inside isotope level to compute

Definition at line 31 of file peptideisotopespectrummatch.cpp.

39 : _precision(precision)
40{
41
42 try
43 {
45 qDebug() << "peptideSp.get()->getSequence()="
46 << peptideSp.get()->getSequence()
47 << " max_isotope_number=" << max_isotope_number
48 << " spectrum.size=" << spectrum.size()
49 << " parent_charge=" << parent_charge
50 << " ion_type_list.size=" << ion_type_list.size()
51 << " max_isotope_rank=" << max_isotope_rank;
52 PeptideFragmentIonListBase fragmentIonList(peptideSp, ion_type_list);
53 qDebug() << " fragmentIonList.size()=" << fragmentIonList.size();
54 std::vector<DataPoint> peak_list(spectrum.begin(), spectrum.end());
55 for(auto ion_type : ion_type_list)
56 {
57 const std::list<PeptideFragmentIonSp> peptide_fragment_ion_list =
58 fragmentIonList.getPeptideFragmentIonSp(ion_type);
59 qDebug() << " peptide_fragment_ion_list.size()="
60 << peptide_fragment_ion_list.size();
61
62 for(unsigned int charge = 1; charge <= parent_charge; charge++)
63 {
64 qDebug();
65 for(auto &&peptide_fragment_ion : peptide_fragment_ion_list)
66 {
67 qDebug() << "peptide_fragment_ion.get()->getMz(charge)="
68 << peptide_fragment_ion.get()->getMz(charge);
69 PeptideNaturalIsotopeList isotope_list(peptide_fragment_ion);
70 for(unsigned int isotope_number = 0;
71 isotope_number <= max_isotope_number;
72 isotope_number++)
73 {
74 qDebug();
75 PeptideNaturalIsotopeAverage *p_isotopeIon;
76 if(max_isotope_rank == 0)
77 {
78 // fast constructor, no need to compute isotope ratio
79 p_isotopeIon = new PeptideNaturalIsotopeAverage(
80 peptide_fragment_ion,
81 isotope_number,
82 charge,
83 precision);
84 }
85 else
86 {
87 p_isotopeIon =
88 new PeptideNaturalIsotopeAverage(isotope_list,
89 max_isotope_rank,
90 isotope_number,
91 charge,
92 precision);
93 }
94
95 qDebug()
96 << "max_isotope_rank=" << max_isotope_rank
97 << " isotope_number=" << isotope_number
98 << " charge=" << charge << " precision=" << precision
99 << " p_isotopeIon->getMz()=" << p_isotopeIon->getMz()
100 << " " << isotope_number << " "
101 << p_isotopeIon->toString();
102
103 std::vector<DataPoint>::iterator it_peak =
104 getBestPeakIterator(peak_list, *p_isotopeIon);
105 if(it_peak != peak_list.end())
106 {
107 _peak_ion_match_list.push_back(PeakIonIsotopeMatch(
108 *it_peak,
109 p_isotopeIon->makePeptideNaturalIsotopeAverageSp(),
110 peptide_fragment_ion));
111 peak_list.erase(it_peak);
112
113 qDebug() << isotope_number << " "
114 << _peak_ion_match_list.back().toString();
115 }
116 delete p_isotopeIon;
117 }
118 }
119 }
120 }
121 }
122 catch(PappsoException &exception_pappso)
123 {
124 QString errorStr =
125 QObject::tr(
126 "ERROR building PeptideIsotopeSpectrumMatch, PAPPSO exception:\n%1")
127 .arg(exception_pappso.qwhat());
128 qDebug() << "PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
129 "PappsoException :\n"
130 << errorStr;
131 throw PappsoException(errorStr);
132 }
133 catch(std::exception &exception_std)
134 {
135 QString errorStr =
136 QObject::tr(
137 "ERROR building PeptideIsotopeSpectrumMatch, std exception:\n%1")
138 .arg(exception_std.what());
139 qDebug() << "PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
140 "std::exception :\n"
141 << errorStr;
142 throw PappsoException(errorStr);
143 }
144
145 qDebug() << "_peak_ion_match_list.size()=" << _peak_ion_match_list.size();
146}
std::list< PeakIonIsotopeMatch > _peak_ion_match_list
virtual std::vector< DataPoint >::iterator getBestPeakIterator(std::vector< DataPoint > &peak_list, const PeptideNaturalIsotopeAverage &ion) const

References _peak_ion_match_list, getBestPeakIterator(), pappso::PeptideNaturalIsotopeAverage::getMz(), pappso::PeptideFragmentIonListBase::getPeptideFragmentIonSp(), pappso::PeptideNaturalIsotopeAverage::makePeptideNaturalIsotopeAverageSp(), pappso::PappsoException::qwhat(), pappso::PeptideFragmentIonListBase::size(), and pappso::PeptideNaturalIsotopeAverage::toString().

◆ PeptideIsotopeSpectrumMatch() [2/3]

pappso::PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch ( const MassSpectrum spectrum,
std::vector< PeptideNaturalIsotopeAverageSp v_peptideIsotopeList,
std::vector< PeptideFragmentIonSp v_peptideIonList,
PrecisionPtr  precision 
)

Definition at line 148 of file peptideisotopespectrummatch.cpp.

153 : _precision(precision)
154{
155 qDebug() << " begin";
156 if(v_peptideIsotopeList.size() != v_peptideIonList.size())
157 {
158 throw PappsoException(
159 QObject::tr(
160 "v_peptideIsotopeList.size() %1 != v_peptideIonList.size() %2")
161 .arg(v_peptideIsotopeList.size())
162 .arg(v_peptideIonList.size()));
163 }
164
165 auto isotopeIt = v_peptideIsotopeList.begin();
166 auto ionIt = v_peptideIonList.begin();
167 std::vector<DataPoint> peak_list(spectrum.begin(), spectrum.end());
168
169 while(isotopeIt != v_peptideIsotopeList.end())
170 {
171 std::vector<DataPoint>::iterator it_peak =
172 getBestPeakIterator(peak_list, *(isotopeIt->get()));
173 if(it_peak != peak_list.end())
174 {
175 _peak_ion_match_list.push_back(
176 PeakIonIsotopeMatch(*it_peak, *isotopeIt, *ionIt));
177 peak_list.erase(it_peak);
178 }
179 isotopeIt++;
180 ionIt++;
181 }
182 qDebug() << "_peak_ion_match_list.size()=" << _peak_ion_match_list.size()
183 << " end";
184}

References _peak_ion_match_list, and getBestPeakIterator().

◆ PeptideIsotopeSpectrumMatch() [3/3]

pappso::PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch ( const PeptideIsotopeSpectrumMatch other)

Definition at line 187 of file peptideisotopespectrummatch.cpp.

189 : _precision(other._precision),
190 _peak_ion_match_list(other._peak_ion_match_list)
191{
192 qDebug();
193}

◆ ~PeptideIsotopeSpectrumMatch()

pappso::PeptideIsotopeSpectrumMatch::~PeptideIsotopeSpectrumMatch ( )
virtual

Definition at line 195 of file peptideisotopespectrummatch.cpp.

196{
197}

Member Function Documentation

◆ begin()

PeptideIsotopeSpectrumMatch::const_iterator pappso::PeptideIsotopeSpectrumMatch::begin ( ) const

Definition at line 242 of file peptideisotopespectrummatch.cpp.

243{
244 return _peak_ion_match_list.begin();
245}

References _peak_ion_match_list.

◆ dropPeaksLackingMonoisotope()

void pappso::PeptideIsotopeSpectrumMatch::dropPeaksLackingMonoisotope ( )

Definition at line 253 of file peptideisotopespectrummatch.cpp.

254{
255 qDebug();
257 [](const PeakIonIsotopeMatch &a, const PeakIonIsotopeMatch &b) {
258 if(a.getPeptideIonType() < b.getPeptideIonType())
259 return true;
260 if(a.getPeptideFragmentIonSp().get()->size() <
261 b.getPeptideFragmentIonSp().get()->size())
262 return true;
263 if(a.getCharge() < b.getCharge())
264 return true;
265 if(a.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber() <
266 b.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
267 return true;
268 return false;
269 });
270 PeptideIon ion_type = PeptideIon::b;
271 std::size_t nserie = 0;
272 std::size_t isotopeserie = 0;
273 unsigned int charge = 0;
274 for(std::list<PeakIonIsotopeMatch>::iterator it =
275 _peak_ion_match_list.begin();
276 it != _peak_ion_match_list.end();
277 it++)
278 {
279 if((nserie != it->getPeptideFragmentIonSp().get()->size()) ||
280 (ion_type != it->getPeptideIonType()) || (charge != it->getCharge()))
281 {
282 ion_type = it->getPeptideIonType();
283 isotopeserie = 0;
284 nserie = it->getPeptideFragmentIonSp().get()->size();
285 charge = it->getCharge();
286 }
287 if(isotopeserie <=
288 it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
289 {
290 isotopeserie =
291 it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber();
292 }
293 else
294 {
295 it = _peak_ion_match_list.erase(it);
296 }
297 }
298 qDebug();
299}
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition types.h:425
@ b
Nter acylium ions.

References _peak_ion_match_list, pappso::a, and pappso::b.

◆ end()

PeptideIsotopeSpectrumMatch::const_iterator pappso::PeptideIsotopeSpectrumMatch::end ( ) const

Definition at line 247 of file peptideisotopespectrummatch.cpp.

248{
249 return _peak_ion_match_list.end();
250}

References _peak_ion_match_list.

◆ getBestPeakIterator()

std::vector< DataPoint >::iterator pappso::PeptideIsotopeSpectrumMatch::getBestPeakIterator ( std::vector< DataPoint > &  peak_list,
const PeptideNaturalIsotopeAverage ion 
) const
privatevirtual

Definition at line 201 of file peptideisotopespectrummatch.cpp.

204{
205 // qDebug();
206 std::vector<DataPoint>::iterator itpeak = peak_list.begin();
207 std::vector<DataPoint>::iterator itend = peak_list.end();
208 std::vector<DataPoint>::iterator itselect = peak_list.end();
209
210 pappso_double best_intensity = 0;
211
212 while(itpeak != itend)
213 {
214 // qDebug() << itpeak->x;
215 if(ion.matchPeak(itpeak->x))
216 {
217 if(itpeak->y > best_intensity)
218 {
219 best_intensity = itpeak->y;
220 itselect = itpeak;
221 }
222 }
223 itpeak++;
224 }
225 // qDebug();
226 return (itselect);
227}
double pappso_double
A type definition for doubles.
Definition types.h:50

References pappso::PeptideNaturalIsotopeAverage::matchPeak().

Referenced by PeptideIsotopeSpectrumMatch(), and PeptideIsotopeSpectrumMatch().

◆ getPeakIonIsotopeMatchList()

const std::list< PeakIonIsotopeMatch > & pappso::PeptideIsotopeSpectrumMatch::getPeakIonIsotopeMatchList ( ) const

Definition at line 230 of file peptideisotopespectrummatch.cpp.

231{
232 qDebug() << "_peak_ion_match_list.size()=" << _peak_ion_match_list.size();
234}

References _peak_ion_match_list.

Referenced by pappso::IonIsotopeRatioScore::IonIsotopeRatioScore(), and pappso::MassSpectrumWidget::peptideAnnotate().

◆ size()

std::size_t pappso::PeptideIsotopeSpectrumMatch::size ( ) const

Definition at line 237 of file peptideisotopespectrummatch.cpp.

238{
239 return _peak_ion_match_list.size();
240}

References _peak_ion_match_list.

Member Data Documentation

◆ _peak_ion_match_list

std::list<PeakIonIsotopeMatch> pappso::PeptideIsotopeSpectrumMatch::_peak_ion_match_list
private

◆ _precision

PrecisionPtr pappso::PeptideIsotopeSpectrumMatch::_precision
private

Definition at line 84 of file peptideisotopespectrummatch.h.


The documentation for this class was generated from the following files: