33#include <unordered_set>
36#include "../../pappsoexception.h"
37#include "../../amino_acid/aacode.h"
43 : std::vector<
pappso::specglob::ExperimentalSpectrumDataPoint>(
44 specglob::ExperimentalSpectrum(qmass_spectrum, precision_ptr)),
46 m_qualifiedMassSpectrum(qmass_spectrum),
47 m_precision_ptr(precision_ptr),
48 m_precursor_mass_error(0)
53 m_aapositions.push_back(std::make_shared<std::vector<AaPosition>>());
59 for(std::size_t iter = 1; iter < this->size(); iter++)
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)
85 double precursor_mass_error)
86 : std::vector<
pappso::specglob::ExperimentalSpectrumDataPoint>(
87 pappso::specglob::ExperimentalSpectrum(
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)
97 m_aapositions.push_back(std::make_shared<std::vector<AaPosition>>());
103 for(std::size_t iter = 1; iter < this->size(); iter++)
109 this->back().peak_mz =
124 std::vector<double>::iterator iter1, iter2;
125 std::size_t peak1, peak2, next_l_peak;
126 std::vector<double> mass_list = getMassList();
129 for(iter1 = mass_list.begin(); iter1 != mass_list.end(); iter1++)
133 for(iter2 = iter1 + 1; iter2 != mass_list.end(); iter2++)
136 aa = m_aaCode.getAaCodeByMass(*(iter2) - *(iter1), m_precision_ptr);
140 for(std::size_t iter = 1; iter < peak1;
144 if(m_reindexed_peaks.at(iter) >= 0)
149 if(m_reindexed_peaks.at(peak2) == -1)
151 addSupportedPeak(peak2);
152 m_supported_peaks.at(peak2)->push_back(aa);
154 if(m_reindexed_peaks.at(peak1) >= 0)
156 addAaPosition(aa, peak2, peak1, next_l_peak,
true);
160 addAaPosition(aa, peak2, next_l_peak, next_l_peak,
false);
166 removeUnsupportedMasses();
167 correctPeakIndexes();
176 fillComplementaryPeakIndexes();
218 std::vector<specglob::ExperimentalSpectrumDataPoint> kept_peaks;
219 for(std::vector<specglob::ExperimentalSpectrumDataPoint>::iterator iter = this->begin();
223 if(m_reindexed_peaks.at(iter->indice) >= 0)
225 kept_peaks.push_back(*iter);
229 this->assign(kept_peaks.begin(), kept_peaks.end());
234 const std::size_t r_peak,
235 const std::size_t l_peak,
236 const std::size_t next_l_peak,
243 m_aapositions.at(aa - 1)->push_back(
244 {r_peak, l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
248 m_aapositions.at(aa - 1)->push_back(
249 {r_peak, next_l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
255 bool l_support)
const
269 for(std::vector<uint8_t>::iterator aa = m_supported_peaks.at(l_peak)->begin();
270 aa != m_supported_peaks.at(l_peak)->end();
273 condition += 2 << *(aa);
279std::vector<pappso::specpeptidoms::AaPosition> &
282 return *m_aapositions.at(m_aaCode.getAaCode(aa.getLetter()) - 1);
285std::vector<pappso::specpeptidoms::AaPosition>
287 std::vector<std::size_t> peaks_to_remove)
const
289 std::vector<AaPosition> aa_positions;
290 for(
auto aap : *m_aapositions.at(m_aaCode.getAaCode(aa.getLetter()) - 1))
292 if(std::find(peaks_to_remove.begin(), peaks_to_remove.end(), aap.r_peak) ==
293 peaks_to_remove.end())
295 aa_positions.push_back(aap);
304 std::vector<double> mass_list;
307 mass_list.push_back(n.
peak_mz);
315 return this->at(indice).type;
321 return m_qualifiedMassSpectrum.getPrecursorCharge();
327 return this->at(r_peak).peak_mz - this->at(l_peak).peak_mz;
333 return this->m_qualifiedMassSpectrum.getPrecursorMass() - m_precursor_mass_error -
334 this->at(peak).peak_mz +
MHPLUS;
340 std::size_t counter = 0;
341 for(std::size_t iter = 0; iter < peak; iter++)
343 if(m_reindexed_peaks.at(iter) >= 0)
348 m_reindexed_peaks.at(peak) = counter;
349 for(std::size_t iter = peak + 1; iter < m_reindexed_peaks.size(); iter++)
351 if(m_reindexed_peaks.at(iter) >= 0)
353 m_reindexed_peaks.at(iter)++;
361 for(
auto aa = m_aapositions.begin(); aa != m_aapositions.end(); aa++)
363 for(
auto aap = aa->get()->begin(); aap != aa->get()->end(); aap++)
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);
375 std::size_t left_index, right_index;
377 m_complementary_peak_indexes.reserve(this->size());
378 while(m_complementary_peak_indexes.size() < this->size())
380 m_complementary_peak_indexes.push_back(0);
383 right_index = this->size() - 1;
384 double comp_mass = m_qualifiedMassSpectrum.getPrecursorMass() + 2 *
MHPLUS;
386 while(left_index < right_index)
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))
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;
395 if(comp_mass - this->at(left_index).peak_mz - this->at(right_index).peak_mz >= 0)
409 return m_complementary_peak_indexes.at(peak);
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
std::size_t getSize() const
bool contains(pappso_double) const
Class representing a fully specified mass spectrum.
double getPrecursorMass(bool *ok_p=nullptr) const
get precursor mass given the charge stats and precursor mz
void preprocessSpectrum()
Preprocess the spectrum.
double getMZShift(std::size_t l_peak, std::size_t r_peak) const
Returns the mz difference between two peaks.
uint getPrecursorCharge() const
Returns the spectrum's precursor's charge.
SpOMSSpectrum(pappso::QualifiedMassSpectrum &qmass_spectrum, pappso::PrecisionPtr precision_ptr, const pappso::AaCode &aaCode)
double getMissingMass(std::size_t peak) const
Returns the missing mass between a peak and the precursor's mass (shift at the end).
std::vector< std::shared_ptr< std::vector< uint8_t > > > m_supported_peaks
uint32_t computeCondition(const std::size_t l_peak, bool l_support) const
Computes the "condition" integer, used to apply the three peaks rule.
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.
pappso::QualifiedMassSpectrum m_qualifiedMassSpectrum
std::vector< std::shared_ptr< std::vector< AaPosition > > > m_aapositions
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< int > m_reindexed_peaks
std::size_t getComplementaryPeak(std::size_t peak) const
specglob::ExperimentalSpectrumDataPointType peakType(std::size_t indice) const
Returns the type of one of the spectrum's peaks.
std::vector< double > getMassList() const
Returns the spectrum's list of masses.
std::vector< AaPosition > & getAaPositions(const Aa &aa) const
Returns the list of aa_positions for a given amino acid.
const pappso::AaCode & m_aaCode
ExperimentalSpectrumDataPointType
std::shared_ptr< const SpOMSSpectrum > SpOMSSpectrumCsp
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
const pappso_double MHPLUS(1.007276466879)
const pappso_double MPROTIUM(1.007825032241)
const pappso_double MASSOXYGEN(15.99491461956)
This header contains all the type re-definitions and all the global variables definitions used in the...