libpappsomspp
Library for mass spectrometry
pappso::specpeptidoms::SpOMSSpectrum Class Reference

#include <spomsspectrum.h>

Inheritance diagram for pappso::specpeptidoms::SpOMSSpectrum:

Public Member Functions

 SpOMSSpectrum (pappso::QualifiedMassSpectrum &qmass_spectrum, pappso::PrecisionPtr precision_ptr, const pappso::AaCode &aaCode)
 
 SpOMSSpectrum (const SpOMSSpectrumCsp &other)
 
 SpOMSSpectrum (const SpOMSSpectrumCsp &other, double precursor_mass_error)
 Returns a copy of the provided spectrum accounting for the provided precursor mass error. More...
 
virtual ~SpOMSSpectrum ()
 
void addAaPosition (uint8_t aa, const std::size_t r_peak, const std::size_t l_peak, const std::size_t next_l_peak, bool l_support)
 Adds an amino acid position to the data structure. More...
 
std::vector< AaPosition > & getAaPositions (const Aa &aa) const
 Returns the list of aa_positions for a given amino acid. More...
 
std::vector< AaPositiongetAaPositions (const Aa &aa, std::vector< std::size_t > peaks_to_remove) const
 Returns the list of aa_positions for a given amino acid, except those relying on provided peaks. More...
 
std::vector< double > getMassList () const
 Returns the spectrum's list of masses. More...
 
specglob::ExperimentalSpectrumDataPointType peakType (std::size_t indice) const
 Returns the type of one of the spectrum's peaks. More...
 
uint getPrecursorCharge () const
 Returns the spectrum's precursor's charge. More...
 
double getMissingMass (std::size_t peak) const
 Returns the missing mass between a peak and the precursor's mass (shift at the end). More...
 
double getMZShift (std::size_t l_peak, std::size_t r_peak) const
 Returns the mz difference between two peaks. More...
 
std::size_t getComplementaryPeak (std::size_t peak) const
 

Private Member Functions

void preprocessSpectrum ()
 Preprocess the spectrum. More...
 
void removeUnsupportedMasses ()
 Removes the unsupported peaks (without an amino acid to the left) from the spectrum. More...
 
uint32_t computeCondition (const std::size_t l_peak, bool l_support) const
 Computes the "condition" integer, used to apply the three peaks rule. More...
 
void addSupportedPeak (std::size_t peak)
 Add a peak to the supported peaks list. More...
 
void correctPeakIndexes ()
 Reindexes the peaks after removal of the unsupported peaks. More...
 
void fillComplementaryPeakIndexes ()
 For each point of the spectrum, indicate the index of its complementary peak;. More...
 

Private Attributes

pappso::QualifiedMassSpectrum m_qualifiedMassSpectrum
 
std::vector< std::shared_ptr< std::vector< AaPosition > > > m_aapositions
 
pappso::PrecisionPtr m_precision_ptr
 
std::vector< std::shared_ptr< std::vector< uint8_t > > > m_supported_peaks
 
std::vector< int > m_reindexed_peaks
 
const pappso::AaCodem_aaCode
 
std::vector< std::size_t > m_complementary_peak_indexes
 
double m_precursor_mass_error
 

Detailed Description

Definition at line 67 of file spomsspectrum.h.

Constructor & Destructor Documentation

◆ SpOMSSpectrum() [1/3]

pappso::specpeptidoms::SpOMSSpectrum::SpOMSSpectrum ( pappso::QualifiedMassSpectrum qmass_spectrum,
pappso::PrecisionPtr  precision_ptr,
const pappso::AaCode aaCode 
)

Default constructor

Parameters
exp_spectrumExperimentalSpectrum to preprocess
precision_ptrPrecision to use for preprocessing

Definition at line 40 of file spomsspectrum.cpp.

43 : std::vector<pappso::specglob::ExperimentalSpectrumDataPoint>(
44 specglob::ExperimentalSpectrum(qmass_spectrum, precision_ptr)),
45 m_aaCode(aaCode),
46 m_qualifiedMassSpectrum(qmass_spectrum),
47 m_precision_ptr(precision_ptr),
49{
51 for(std::size_t iter = 0; iter < m_aaCode.getSize(); iter++)
52 {
53 m_aapositions.push_back(std::make_shared<std::vector<AaPosition>>());
54 m_aapositions.back()->reserve(this->size() - 1);
55 }
56 m_supported_peaks.reserve(this->size());
57 m_supported_peaks.push_back(std::make_shared<std::vector<uint8_t>>());
58 m_reindexed_peaks.push_back(0);
59 for(std::size_t iter = 1; iter < this->size(); iter++)
60 {
61 m_supported_peaks.push_back(std::make_shared<std::vector<uint8_t>>());
62 m_reindexed_peaks.push_back(-1);
63 }
64 this->at(0).peak_mz = pappso::MHPLUS + 2 * pappso::MPROTIUM + pappso::MASSOXYGEN;
67}
std::size_t getSize() const
Definition: aacode.cpp:74
double getPrecursorMass(bool *ok_p=nullptr) const
get precursor mass given the charge stats and precursor mz
void preprocessSpectrum()
Preprocess the spectrum.
std::vector< std::shared_ptr< std::vector< uint8_t > > > m_supported_peaks
pappso::PrecisionPtr m_precision_ptr
pappso::QualifiedMassSpectrum m_qualifiedMassSpectrum
std::vector< std::shared_ptr< std::vector< AaPosition > > > m_aapositions
const pappso_double MHPLUS(1.007276466879)
const pappso_double MPROTIUM(1.007825032241)
const pappso_double MASSOXYGEN(15.99491461956)

References pappso::QualifiedMassSpectrum::getPrecursorMass(), pappso::AaCode::getSize(), m_aaCode, m_aapositions, m_qualifiedMassSpectrum, m_reindexed_peaks, m_supported_peaks, pappso::MASSOXYGEN(), pappso::MHPLUS(), pappso::MPROTIUM(), and preprocessSpectrum().

◆ SpOMSSpectrum() [2/3]

pappso::specpeptidoms::SpOMSSpectrum::SpOMSSpectrum ( const SpOMSSpectrumCsp other)

Copy constructor

Parameters
otherSpOMSSpectrum to copy

Definition at line 69 of file spomsspectrum.cpp.

70 : std::vector<pappso::specglob::ExperimentalSpectrumDataPoint>(
71 pappso::specglob::ExperimentalSpectrum(other->m_qualifiedMassSpectrum,
72 other->m_precision_ptr)),
73 m_qualifiedMassSpectrum(other->m_qualifiedMassSpectrum),
74 m_aapositions(other->m_aapositions),
75 m_precision_ptr(other->m_precision_ptr),
76 m_supported_peaks(other->m_supported_peaks),
77 m_reindexed_peaks(other->m_reindexed_peaks),
78 m_aaCode(other->m_aaCode),
79 m_complementary_peak_indexes(other->m_complementary_peak_indexes),
80 m_precursor_mass_error(other->m_precursor_mass_error)
81{
82}
std::vector< std::size_t > m_complementary_peak_indexes

◆ SpOMSSpectrum() [3/3]

pappso::specpeptidoms::SpOMSSpectrum::SpOMSSpectrum ( const SpOMSSpectrumCsp other,
double  precursor_mass_error 
)

Returns a copy of the provided spectrum accounting for the provided precursor mass error.

Post-processing constructor

Parameters
otherSpOMSSpectrum to copy
precursor_mass_errorprecursor mass error to account for

Definition at line 84 of file spomsspectrum.cpp.

86 : std::vector<pappso::specglob::ExperimentalSpectrumDataPoint>(
88 other->m_qualifiedMassSpectrum, other->m_precision_ptr, precursor_mass_error)),
89 m_qualifiedMassSpectrum(other->m_qualifiedMassSpectrum),
90 m_precision_ptr(other->m_precision_ptr),
91 m_aaCode(other->m_aaCode),
92 m_precursor_mass_error(precursor_mass_error)
93{
95 for(std::size_t iter = 0; iter < m_aaCode.getSize(); iter++)
96 {
97 m_aapositions.push_back(std::make_shared<std::vector<AaPosition>>());
98 m_aapositions.back()->reserve(this->size() - 1);
99 }
100 m_supported_peaks.reserve(this->size());
101 m_supported_peaks.push_back(std::make_shared<std::vector<uint8_t>>());
102 m_reindexed_peaks.push_back(0);
103 for(std::size_t iter = 1; iter < this->size(); iter++)
104 {
105 m_supported_peaks.push_back(std::make_shared<std::vector<uint8_t>>());
106 m_reindexed_peaks.push_back(-1);
107 }
108 this->at(0).peak_mz = pappso::MHPLUS + 2 * pappso::MPROTIUM + pappso::MASSOXYGEN;
109 this->back().peak_mz =
112}

References pappso::QualifiedMassSpectrum::getPrecursorMass(), pappso::AaCode::getSize(), m_aaCode, m_aapositions, m_qualifiedMassSpectrum, m_reindexed_peaks, m_supported_peaks, pappso::MASSOXYGEN(), pappso::MHPLUS(), pappso::MPROTIUM(), and preprocessSpectrum().

◆ ~SpOMSSpectrum()

pappso::specpeptidoms::SpOMSSpectrum::~SpOMSSpectrum ( )
virtual

Destructor

Definition at line 114 of file spomsspectrum.cpp.

115{
116}

Member Function Documentation

◆ addAaPosition()

void pappso::specpeptidoms::SpOMSSpectrum::addAaPosition ( uint8_t  aa,
const std::size_t  r_peak,
const std::size_t  l_peak,
const std::size_t  next_l_peak,
bool  l_support 
)

Adds an amino acid position to the data structure.

Parameters
aaAmino acid to add to the data structure
r_peakindex of the amino acid's right support peak
l_peakindex of the amino acid's left support peak, if it is supported by an amino acid, otherwise see next_l_peak
next_l_peakindex of the first supported peak to the left of the amino acid's left support peak
l_supportindicates whether the amino acid's left support peak if supported by an amino acid

Definition at line 233 of file spomsspectrum.cpp.

238{
239 // aa=0 corresponds to no amino acid identified, thus aa is always >=1. We substract 1 to aa to
240 // avoid keeping an empty, useless vector.
241 if(l_support)
242 {
243 m_aapositions.at(aa - 1)->push_back(
244 {r_peak, l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
245 }
246 else
247 {
248 m_aapositions.at(aa - 1)->push_back(
249 {r_peak, next_l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
250 }
251}
uint32_t computeCondition(const std::size_t l_peak, bool l_support) const
Computes the "condition" integer, used to apply the three peaks rule.

◆ addSupportedPeak()

void pappso::specpeptidoms::SpOMSSpectrum::addSupportedPeak ( std::size_t  peak)
private

Add a peak to the supported peaks list.

Definition at line 338 of file spomsspectrum.cpp.

339{
340 std::size_t counter = 0;
341 for(std::size_t iter = 0; iter < peak; iter++)
342 {
343 if(m_reindexed_peaks.at(iter) >= 0)
344 {
345 counter++;
346 }
347 }
348 m_reindexed_peaks.at(peak) = counter;
349 for(std::size_t iter = peak + 1; iter < m_reindexed_peaks.size(); iter++)
350 {
351 if(m_reindexed_peaks.at(iter) >= 0)
352 {
353 m_reindexed_peaks.at(iter)++;
354 }
355 }
356}

◆ computeCondition()

uint32_t pappso::specpeptidoms::SpOMSSpectrum::computeCondition ( const std::size_t  l_peak,
bool  l_support 
) const
private

Computes the "condition" integer, used to apply the three peaks rule.

Definition at line 254 of file spomsspectrum.cpp.

256{
257 uint32_t condition;
258 if(l_peak == 0)
259 {
260 condition = 2;
261 }
262 else if(!l_support)
263 {
264 condition = 1;
265 }
266 else
267 {
268 condition = 0;
269 for(std::vector<uint8_t>::iterator aa = m_supported_peaks.at(l_peak)->begin();
270 aa != m_supported_peaks.at(l_peak)->end();
271 aa++)
272 {
273 condition += 2 << *(aa);
274 }
275 }
276 return condition;
277}
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN

◆ correctPeakIndexes()

void pappso::specpeptidoms::SpOMSSpectrum::correctPeakIndexes ( )
private

Reindexes the peaks after removal of the unsupported peaks.

Definition at line 359 of file spomsspectrum.cpp.

360{
361 for(auto aa = m_aapositions.begin(); aa != m_aapositions.end(); aa++)
362 {
363 for(auto aap = aa->get()->begin(); aap != aa->get()->end(); aap++)
364 {
365 aap->l_peak = m_reindexed_peaks.at(aap->l_peak);
366 aap->r_peak = m_reindexed_peaks.at(aap->r_peak);
367 aap->next_l_peak = m_reindexed_peaks.at(aap->next_l_peak);
368 }
369 }
370}

◆ fillComplementaryPeakIndexes()

void pappso::specpeptidoms::SpOMSSpectrum::fillComplementaryPeakIndexes ( )
private

For each point of the spectrum, indicate the index of its complementary peak;.

Definition at line 373 of file spomsspectrum.cpp.

374{
375 std::size_t left_index, right_index;
376
377 m_complementary_peak_indexes.reserve(this->size());
378 while(m_complementary_peak_indexes.size() < this->size())
379 {
380 m_complementary_peak_indexes.push_back(0);
381 }
382 left_index = 0;
383 right_index = this->size() - 1;
384 double comp_mass = m_qualifiedMassSpectrum.getPrecursorMass() + 2 * MHPLUS;
385
386 while(left_index < right_index)
387 {
388 pappso::MzRange mz_range(comp_mass - this->at(left_index).peak_mz, m_precision_ptr);
389 if(mz_range.contains(this->at(right_index).peak_mz))
390 {
391 m_complementary_peak_indexes.at(left_index) = right_index;
392 m_complementary_peak_indexes.at(right_index) = left_index;
393 qDebug() << left_index << right_index;
394 }
395 if(comp_mass - this->at(left_index).peak_mz - this->at(right_index).peak_mz >= 0)
396 {
397 left_index++;
398 }
399 else
400 {
401 right_index--;
402 }
403 }
404}

References pappso::MzRange::contains(), and pappso::MHPLUS().

◆ getAaPositions() [1/2]

std::vector< pappso::specpeptidoms::AaPosition > & pappso::specpeptidoms::SpOMSSpectrum::getAaPositions ( const Aa aa) const

Returns the list of aa_positions for a given amino acid.

Parameters
aaAmino acid for which to retrieve positions

Definition at line 280 of file spomsspectrum.cpp.

281{
282 return *m_aapositions.at(m_aaCode.getAaCode(aa.getLetter()) - 1);
283}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
Definition: aacode.cpp:81

◆ getAaPositions() [2/2]

std::vector< pappso::specpeptidoms::AaPosition > pappso::specpeptidoms::SpOMSSpectrum::getAaPositions ( const Aa aa,
std::vector< std::size_t >  peaks_to_remove 
) const

Returns the list of aa_positions for a given amino acid, except those relying on provided peaks.

Definition at line 286 of file spomsspectrum.cpp.

288{
289 std::vector<AaPosition> aa_positions;
290 for(auto aap : *m_aapositions.at(m_aaCode.getAaCode(aa.getLetter()) - 1))
291 {
292 if(std::find(peaks_to_remove.begin(), peaks_to_remove.end(), aap.r_peak) ==
293 peaks_to_remove.end())
294 {
295 aa_positions.push_back(aap);
296 }
297 }
298 return aa_positions;
299}

◆ getComplementaryPeak()

std::size_t pappso::specpeptidoms::SpOMSSpectrum::getComplementaryPeak ( std::size_t  peak) const

Definition at line 407 of file spomsspectrum.cpp.

408{
409 return m_complementary_peak_indexes.at(peak);
410}

◆ getMassList()

std::vector< double > pappso::specpeptidoms::SpOMSSpectrum::getMassList ( ) const

Returns the spectrum's list of masses.

Definition at line 302 of file spomsspectrum.cpp.

303{
304 std::vector<double> mass_list;
305 for(const specglob::ExperimentalSpectrumDataPoint &n : *this)
306 {
307 mass_list.push_back(n.peak_mz);
308 }
309 return mass_list;
310}

References pappso::specglob::ExperimentalSpectrumDataPoint::peak_mz.

◆ getMissingMass()

double pappso::specpeptidoms::SpOMSSpectrum::getMissingMass ( std::size_t  peak) const

Returns the missing mass between a peak and the precursor's mass (shift at the end).

Definition at line 331 of file spomsspectrum.cpp.

332{
334 this->at(peak).peak_mz + MHPLUS;
335}

References pappso::MHPLUS().

◆ getMZShift()

double pappso::specpeptidoms::SpOMSSpectrum::getMZShift ( std::size_t  l_peak,
std::size_t  r_peak 
) const

Returns the mz difference between two peaks.

Parameters
l_peakleft peak
r_peakright peak

Definition at line 325 of file spomsspectrum.cpp.

326{
327 return this->at(r_peak).peak_mz - this->at(l_peak).peak_mz;
328}

◆ getPrecursorCharge()

uint pappso::specpeptidoms::SpOMSSpectrum::getPrecursorCharge ( ) const

Returns the spectrum's precursor's charge.

Definition at line 319 of file spomsspectrum.cpp.

320{
322}
uint getPrecursorCharge(bool *ok=nullptr) const
get precursor charge

◆ peakType()

pappso::specglob::ExperimentalSpectrumDataPointType pappso::specpeptidoms::SpOMSSpectrum::peakType ( std::size_t  indice) const

Returns the type of one of the spectrum's peaks.

Parameters
indicePeak index to be identified

Definition at line 313 of file spomsspectrum.cpp.

314{
315 return this->at(indice).type;
316}

◆ preprocessSpectrum()

void pappso::specpeptidoms::SpOMSSpectrum::preprocessSpectrum ( )
private

Preprocess the spectrum.

Definition at line 120 of file spomsspectrum.cpp.

121{
122 bool found;
123 uint8_t aa;
124 std::vector<double>::iterator iter1, iter2;
125 std::size_t peak1, peak2, next_l_peak;
126 std::vector<double> mass_list = getMassList();
127
128 peak1 = -1;
129 for(iter1 = mass_list.begin(); iter1 != mass_list.end(); iter1++)
130 {
131 peak1++;
132 peak2 = peak1;
133 for(iter2 = iter1 + 1; iter2 != mass_list.end(); iter2++)
134 {
135 peak2++;
136 aa = m_aaCode.getAaCodeByMass(*(iter2) - *(iter1), m_precision_ptr);
137 if(aa != 0)
138 {
139 next_l_peak = 0;
140 for(std::size_t iter = 1; iter < peak1;
141 iter++) // Search of the closer supported left peak.
142 // Possible optimization => search from the right
143 {
144 if(m_reindexed_peaks.at(iter) >= 0)
145 {
146 next_l_peak = iter;
147 }
148 }
149 if(m_reindexed_peaks.at(peak2) == -1)
150 {
151 addSupportedPeak(peak2);
152 m_supported_peaks.at(peak2)->push_back(aa);
153 }
154 if(m_reindexed_peaks.at(peak1) >= 0)
155 {
156 addAaPosition(aa, peak2, peak1, next_l_peak, true);
157 }
158 else
159 {
160 addAaPosition(aa, peak2, next_l_peak, next_l_peak, false);
161 }
162 }
163 }
164 }
165
168
169 // std::size_t i = 0;
170 // for(auto &data_point : *this)
171 // {
172 // data_point.indice = i;
173 // i++;
174 // }
175
177}
uint8_t getAaCodeByMass(double mass, PrecisionPtr precision) const
get the integer code of an amino acid given a mass and a precision
Definition: aacode.cpp:191
void addAaPosition(uint8_t aa, const std::size_t r_peak, const std::size_t l_peak, const std::size_t next_l_peak, bool l_support)
Adds an amino acid position to the data structure.
void removeUnsupportedMasses()
Removes the unsupported peaks (without an amino acid to the left) from the spectrum.
void correctPeakIndexes()
Reindexes the peaks after removal of the unsupported peaks.
void addSupportedPeak(std::size_t peak)
Add a peak to the supported peaks list.
void fillComplementaryPeakIndexes()
For each point of the spectrum, indicate the index of its complementary peak;.
std::vector< double > getMassList() const
Returns the spectrum's list of masses.

References pappso::specpeptidoms::found.

Referenced by SpOMSSpectrum().

◆ removeUnsupportedMasses()

void pappso::specpeptidoms::SpOMSSpectrum::removeUnsupportedMasses ( )
private

Removes the unsupported peaks (without an amino acid to the left) from the spectrum.

Definition at line 216 of file spomsspectrum.cpp.

217{
218 std::vector<specglob::ExperimentalSpectrumDataPoint> kept_peaks;
219 for(std::vector<specglob::ExperimentalSpectrumDataPoint>::iterator iter = this->begin();
220 iter != this->end();
221 iter++)
222 {
223 if(m_reindexed_peaks.at(iter->indice) >= 0)
224 {
225 kept_peaks.push_back(*iter);
226 }
227 }
228 this->clear();
229 this->assign(kept_peaks.begin(), kept_peaks.end());
230}

Member Data Documentation

◆ m_aaCode

const pappso::AaCode& pappso::specpeptidoms::SpOMSSpectrum::m_aaCode
private

Definition at line 165 of file spomsspectrum.h.

Referenced by SpOMSSpectrum().

◆ m_aapositions

std::vector<std::shared_ptr<std::vector<AaPosition> > > pappso::specpeptidoms::SpOMSSpectrum::m_aapositions
private

Definition at line 160 of file spomsspectrum.h.

Referenced by SpOMSSpectrum().

◆ m_complementary_peak_indexes

std::vector<std::size_t> pappso::specpeptidoms::SpOMSSpectrum::m_complementary_peak_indexes
private

Definition at line 166 of file spomsspectrum.h.

◆ m_precision_ptr

pappso::PrecisionPtr pappso::specpeptidoms::SpOMSSpectrum::m_precision_ptr
private

Definition at line 161 of file spomsspectrum.h.

◆ m_precursor_mass_error

double pappso::specpeptidoms::SpOMSSpectrum::m_precursor_mass_error
private

Definition at line 167 of file spomsspectrum.h.

◆ m_qualifiedMassSpectrum

pappso::QualifiedMassSpectrum pappso::specpeptidoms::SpOMSSpectrum::m_qualifiedMassSpectrum
private

Definition at line 159 of file spomsspectrum.h.

Referenced by SpOMSSpectrum().

◆ m_reindexed_peaks

std::vector<int> pappso::specpeptidoms::SpOMSSpectrum::m_reindexed_peaks
private

Definition at line 163 of file spomsspectrum.h.

Referenced by SpOMSSpectrum().

◆ m_supported_peaks

std::vector<std::shared_ptr<std::vector<uint8_t> > > pappso::specpeptidoms::SpOMSSpectrum::m_supported_peaks
private

Definition at line 162 of file spomsspectrum.h.

Referenced by SpOMSSpectrum().


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