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)),
45 m_qualifiedMassSpectrum(qmass_spectrum),
46 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, other.m_precision_ptr)),
72 m_qualifiedMassSpectrum(other.m_qualifiedMassSpectrum),
73 m_aapositions(other.m_aapositions),
74 m_precision_ptr(other.m_precision_ptr),
75 m_supported_peaks(other.m_supported_peaks),
76 m_reindexed_peaks(other.m_reindexed_peaks),
77 m_aaCode(other.m_aaCode),
78 m_complementary_peak_indexes(other.m_complementary_peak_indexes),
79 m_precursor_mass_error(other.m_precursor_mass_error)
84 double precursor_mass_error)
85 : std::vector<
pappso::specglob::ExperimentalSpectrumDataPoint>(
86 pappso::specglob::ExperimentalSpectrum(
87 other.m_qualifiedMassSpectrum, other.m_precision_ptr, precursor_mass_error)),
88 m_qualifiedMassSpectrum(other.m_qualifiedMassSpectrum),
89 m_precision_ptr(other.m_precision_ptr),
90 m_aaCode(other.m_aaCode),
91 m_precursor_mass_error(precursor_mass_error)
96 m_aapositions.push_back(std::make_shared<std::vector<AaPosition>>());
102 for(std::size_t iter = 1; iter < this->size(); iter++)
108 this->back().peak_mz =
123 std::vector<double>::iterator iter1, iter2;
124 std::size_t peak1, peak2, next_l_peak;
125 std::vector<double> mass_list = getMassList();
128 for(iter1 = mass_list.begin(); iter1 != mass_list.end(); iter1++)
132 for(iter2 = iter1 + 1; iter2 != mass_list.end(); iter2++)
135 aa = m_aaCode.getAaCodeByMass(*(iter2) - *(iter1), m_precision_ptr);
139 for(std::size_t iter = 1; iter < peak1;
143 if(m_reindexed_peaks.at(iter) >= 0)
148 if(m_reindexed_peaks.at(peak2) == -1)
150 addSupportedPeak(peak2);
151 m_supported_peaks.at(peak2)->push_back(aa);
153 if(m_reindexed_peaks.at(peak1) >= 0)
155 addAaPosition(aa, peak2, peak1, next_l_peak,
true);
159 addAaPosition(aa, peak2, next_l_peak, next_l_peak,
false);
165 removeUnsupportedMasses();
166 correctPeakIndexes();
175 fillComplementaryPeakIndexes();
217 std::vector<specglob::ExperimentalSpectrumDataPoint> kept_peaks;
218 for(std::vector<specglob::ExperimentalSpectrumDataPoint>::iterator iter = this->begin();
222 if(m_reindexed_peaks.at(iter->indice) >= 0)
224 kept_peaks.push_back(*iter);
228 this->assign(kept_peaks.begin(), kept_peaks.end());
233 const std::size_t r_peak,
234 const std::size_t l_peak,
235 const std::size_t next_l_peak,
242 m_aapositions.at(aa - 1)->push_back(
243 {r_peak, l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
247 m_aapositions.at(aa - 1)->push_back(
248 {r_peak, next_l_peak, next_l_peak, computeCondition(l_peak, l_support), l_support});
254 bool l_support)
const
268 for(std::vector<uint8_t>::iterator aa = m_supported_peaks.at(l_peak)->begin();
269 aa != m_supported_peaks.at(l_peak)->end();
272 condition += 2 << *(aa);
278std::vector<pappso::specpeptidoms::AaPosition> &
282 qDebug() <<
" m_aaCode.getAaCode(aa.getLetter()) - 1=" << m_aaCode.getAaCode(aa) - 1
283 <<
" m_aapositions.size()=" << m_aapositions.size();
284 return *m_aapositions.at(m_aaCode.getAaCode(aa) - 1);
287std::vector<pappso::specpeptidoms::AaPosition>
289 std::vector<std::size_t> peaks_to_remove)
const
291 std::vector<AaPosition> aa_positions;
292 for(
auto aap : *m_aapositions.at(m_aaCode.getAaCode(aa) - 1))
294 if(std::find(peaks_to_remove.begin(), peaks_to_remove.end(), aap.r_peak) ==
295 peaks_to_remove.end())
297 aa_positions.push_back(aap);
306 std::vector<double> mass_list;
309 mass_list.push_back(n.peak_mz);
317 return this->at(indice).type;
323 return m_qualifiedMassSpectrum.getPrecursorCharge();
329 return this->at(r_peak).peak_mz - this->at(l_peak).peak_mz;
335 return this->m_qualifiedMassSpectrum.getPrecursorMass() - m_precursor_mass_error -
336 this->at(peak).peak_mz +
MHPLUS;
342 std::size_t counter = 0;
343 for(std::size_t iter = 0; iter < peak; iter++)
345 if(m_reindexed_peaks.at(iter) >= 0)
350 m_reindexed_peaks.at(peak) = counter;
351 for(std::size_t iter = peak + 1; iter < m_reindexed_peaks.size(); iter++)
353 if(m_reindexed_peaks.at(iter) >= 0)
355 m_reindexed_peaks.at(iter)++;
363 for(
auto aa = m_aapositions.begin(); aa != m_aapositions.end(); aa++)
365 for(
auto aap = aa->get()->begin(); aap != aa->get()->end(); aap++)
367 aap->l_peak = m_reindexed_peaks.at(aap->l_peak);
368 aap->r_peak = m_reindexed_peaks.at(aap->r_peak);
369 aap->next_l_peak = m_reindexed_peaks.at(aap->next_l_peak);
377 std::size_t left_index, right_index;
379 m_complementary_peak_indexes.reserve(this->size());
380 while(m_complementary_peak_indexes.size() < this->size())
382 m_complementary_peak_indexes.push_back(0);
385 right_index = this->size() - 1;
386 double comp_mass = m_qualifiedMassSpectrum.getPrecursorMass() + 2 *
MHPLUS;
388 while(left_index < right_index)
390 pappso::MzRange mz_range(comp_mass - this->at(left_index).peak_mz, m_precision_ptr);
391 if(mz_range.
contains(this->at(right_index).peak_mz))
393 m_complementary_peak_indexes.at(left_index) = right_index;
394 m_complementary_peak_indexes.at(right_index) = left_index;
395 qDebug() << left_index << right_index;
397 if(comp_mass - this->at(left_index).peak_mz - this->at(right_index).peak_mz >= 0)
411 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)
std::vector< AaPosition > & getAaPositions(pappso::Enums::AminoAcidChar aa) const
Returns the list of aa_positions for a given amino acid.
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.
const pappso::AaCode & m_aaCode
ExperimentalSpectrumDataPointType
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)