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< Enums::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< Enums::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()=" << peptideSp.get()->getSequence()
46 << " max_isotope_number=" << max_isotope_number
47 << " spectrum.size=" << spectrum.size() << " parent_charge=" << parent_charge
48 << " ion_type_list.size=" << ion_type_list_in.size()
49 << " max_isotope_rank=" << max_isotope_rank;
50 PeptideFragmentIonListBase fragmentIonList(peptideSp, ion_type_list_in);
51 std::list<Enums::PeptideIon> ion_type_list(ion_type_list_in);
52
53 ion_type_list.sort([](const Enums::PeptideIon &iona, const Enums::PeptideIon &ionb) {
54 if(iona == Enums::PeptideIon::b)
55 return true;
56 if(ionb == Enums::PeptideIon::b)
57 return false;
58 if(iona == Enums::PeptideIon::y)
59 return true;
60 if(ionb == Enums::PeptideIon::y)
61 return false;
62 return iona > ionb;
63 });
64
65 qDebug() << " fragmentIonList.size()=" << fragmentIonList.size();
66 std::vector<DataPoint> peak_list(spectrum.begin(), spectrum.end());
67 for(auto ion_type : ion_type_list)
68 {
69 const std::list<PeptideFragmentIonSp> peptide_fragment_ion_list =
70 fragmentIonList.getPeptideFragmentIonSp(ion_type);
71 qDebug() << " peptide_fragment_ion_list.size()=" << peptide_fragment_ion_list.size();
72
73 for(unsigned int charge = 1; charge <= parent_charge; charge++)
74 {
75 qDebug();
76 for(auto &&peptide_fragment_ion : peptide_fragment_ion_list)
77 {
78 qDebug() << "peptide_fragment_ion.get()->getMz(charge)="
79 << peptide_fragment_ion.get()->getMz(charge);
80 PeptideNaturalIsotopeList isotope_list(peptide_fragment_ion);
81 for(unsigned int isotope_number = 0; isotope_number <= max_isotope_number;
82 isotope_number++)
83 {
84 qDebug();
85 PeptideNaturalIsotopeAverage *p_isotopeIon;
86 if(max_isotope_rank == 0)
87 {
88 // fast constructor, no need to compute isotope ratio
89 p_isotopeIon = new PeptideNaturalIsotopeAverage(
90 peptide_fragment_ion, isotope_number, charge, precision);
91 }
92 else
93 {
94 p_isotopeIon = new PeptideNaturalIsotopeAverage(
95 isotope_list, max_isotope_rank, isotope_number, charge, precision);
96 }
97
98 qDebug() << "max_isotope_rank=" << max_isotope_rank
99 << " isotope_number=" << isotope_number << " charge=" << charge
100 << " precision=" << precision
101 << " p_isotopeIon->getMz()=" << p_isotopeIon->getMz() << " "
102 << isotope_number << " " << p_isotopeIon->toString();
103
104 std::vector<DataPoint>::iterator it_peak =
105 getBestPeakIterator(peak_list, *p_isotopeIon);
106 if(it_peak != peak_list.end())
107 {
108 _peak_ion_match_list.push_back(
109 PeakIonIsotopeMatch(*it_peak,
110 p_isotopeIon->makePeptideNaturalIsotopeAverageSp(),
111 peptide_fragment_ion));
112 peak_list.erase(it_peak);
113
114 qDebug()
115 << isotope_number << " " << _peak_ion_match_list.back().toString();
116 }
117 delete p_isotopeIon;
118 }
119 }
120 }
121 }
122 }
123 catch(PappsoException &exception_pappso)
124 {
125 QString errorStr =
126 QObject::tr("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("ERROR building PeptideIsotopeSpectrumMatch, std exception:\n%1")
137 .arg(exception_std.what());
138 qDebug() << "PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
139 "std::exception :\n"
140 << errorStr;
141 throw PappsoException(errorStr);
142 }
143
144 qDebug() << "_peak_ion_match_list.size()=" << _peak_ion_match_list.size();
145}
std::list< PeakIonIsotopeMatch > _peak_ion_match_list
virtual std::vector< DataPoint >::iterator getBestPeakIterator(std::vector< DataPoint > &peak_list, const PeptideNaturalIsotopeAverage &ion) const
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter)
Definition types.h:286
@ y
Cter amino ions.
Definition types.h:295
@ b
Nter acylium ions.
Definition types.h:287

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

Referenced by PeptideIsotopeSpectrumMatch().

◆ PeptideIsotopeSpectrumMatch() [2/3]

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

Definition at line 147 of file peptideisotopespectrummatch.cpp.

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

References _peak_ion_match_list, _precision, and getBestPeakIterator().

◆ PeptideIsotopeSpectrumMatch() [3/3]

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

Definition at line 183 of file peptideisotopespectrummatch.cpp.

184 : _precision(other._precision), _peak_ion_match_list(other._peak_ion_match_list)
185{
186 qDebug();
187}

References PeptideIsotopeSpectrumMatch(), _peak_ion_match_list, and _precision.

◆ ~PeptideIsotopeSpectrumMatch()

pappso::PeptideIsotopeSpectrumMatch::~PeptideIsotopeSpectrumMatch ( )
virtual

Definition at line 189 of file peptideisotopespectrummatch.cpp.

190{
191}

Member Function Documentation

◆ begin()

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

Definition at line 235 of file peptideisotopespectrummatch.cpp.

236{
237 return _peak_ion_match_list.begin();
238}

References _peak_ion_match_list.

◆ dropPeaksLackingMonoisotope()

void pappso::PeptideIsotopeSpectrumMatch::dropPeaksLackingMonoisotope ( )

Definition at line 246 of file peptideisotopespectrummatch.cpp.

247{
248 qDebug();
249 _peak_ion_match_list.sort([](const PeakIonIsotopeMatch &a, const PeakIonIsotopeMatch &b) {
250 if(a.getPeptideIonType() < b.getPeptideIonType())
251 return true;
252 if(a.getPeptideFragmentIonSp().get()->size() < b.getPeptideFragmentIonSp().get()->size())
253 return true;
254 if(a.getCharge() < b.getCharge())
255 return true;
256 if(a.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber() <
257 b.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
258 return true;
259 return false;
260 });
262 std::size_t nserie = 0;
263 std::size_t isotopeserie = 0;
264 unsigned int charge = 0;
265 for(std::list<PeakIonIsotopeMatch>::iterator it = _peak_ion_match_list.begin();
266 it != _peak_ion_match_list.end();
267 it++)
268 {
269 if((nserie != it->getPeptideFragmentIonSp().get()->size()) ||
270 (ion_type != it->getPeptideIonType()) || (charge != it->getCharge()))
271 {
272 ion_type = it->getPeptideIonType();
273 isotopeserie = 0;
274 nserie = it->getPeptideFragmentIonSp().get()->size();
275 charge = it->getCharge();
276 }
277 if(isotopeserie <= it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
278 {
279 isotopeserie = it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber();
280 }
281 else
282 {
283 it = _peak_ion_match_list.erase(it);
284 }
285 }
286 qDebug();
287}

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

◆ end()

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

Definition at line 240 of file peptideisotopespectrummatch.cpp.

241{
242 return _peak_ion_match_list.end();
243}

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 195 of file peptideisotopespectrummatch.cpp.

197{
198 // qDebug();
199 std::vector<DataPoint>::iterator itpeak = peak_list.begin();
200 std::vector<DataPoint>::iterator itend = peak_list.end();
201 std::vector<DataPoint>::iterator itselect = peak_list.end();
202
203 pappso_double best_intensity = 0;
204
205 while(itpeak != itend)
206 {
207 // qDebug() << itpeak->x;
208 if(ion.matchPeak(itpeak->x))
209 {
210 if(itpeak->y > best_intensity)
211 {
212 best_intensity = itpeak->y;
213 itselect = itpeak;
214 }
215 }
216 itpeak++;
217 }
218 // qDebug();
219 return (itselect);
220}
double pappso_double
A type definition for doubles.
Definition types.h:61

References pappso::PeptideNaturalIsotopeAverage::matchPeak().

Referenced by PeptideIsotopeSpectrumMatch(), and PeptideIsotopeSpectrumMatch().

◆ getPeakIonIsotopeMatchList()

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

Definition at line 223 of file peptideisotopespectrummatch.cpp.

224{
225 qDebug() << "_peak_ion_match_list.size()=" << _peak_ion_match_list.size();
227}

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 230 of file peptideisotopespectrummatch.cpp.

231{
232 return _peak_ion_match_list.size();
233}

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

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