35PsmFeatures::PsmFeatures(
PrecisionPtr ms2precision,
double minimumMz)
45 std::make_shared<FilterResampleKeepGreater>(minimumMz);
60 unsigned int parent_charge,
61 unsigned int max_isotope_number)
71 std::make_shared<PeptideIsotopeSpectrumMatch>(spectrum,
83 qDebug() <<
" accumulate";
84 std::vector<double> delta_list;
101 delta_list.push_back(
102 peak_ion.getPeptideFragmentIonSp().get()->getMz(peak_ion.getCharge()) -
103 peak_ion.getPeak().x);
106 std::accumulate(delta_list.begin(), delta_list.end(), 0);
108 qDebug() <<
" delta_list.size()=" << delta_list.size();
112 if(delta_list.size() > 0)
116 std::sort(delta_list.begin(), delta_list.end());
142 if(peak_ion_match.getPeptideIonType() == ion_type)
144 sum += peak_ion_match.getPeak().y;
155 sum += peak_ion_match.getPeak().y;
169 return m_peakIonPairs.size();
173 std::pair<pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch>> &
176 return m_peakIonPairs;
184 for(
auto &peak_pairs : m_peakIonPairs)
186 sum += peak_pairs.first.getPeak().y;
187 sum += peak_pairs.second.getPeak().y;
195 return m_matchedMzDiffSd;
201 return m_matchedMzDiffMean;
208 return msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList().size();
215 auto peak_ion_match_list =
216 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList();
218 peak_ion_match_list.erase(
220 peak_ion_match_list.begin(),
221 peak_ion_match_list.end(),
223 if(a.getPeptideIonType() != ion_type)
225 if(a.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber() > 0)
229 peak_ion_match_list.end());
231 peak_ion_match_list.sort(
233 if(
a.getCharge() <
b.getCharge())
235 if(
a.getPeptideIonType() <
b.getPeptideIonType())
237 if(
a.getPeptideFragmentIonSp().get()->size() <
238 b.getPeptideFragmentIonSp().get()->size())
243 unsigned int charge = 0;
244 std::size_t size = 0;
245 std::size_t count = 0;
246 for(std::list<PeakIonIsotopeMatch>::iterator it = peak_ion_match_list.begin();
247 it != peak_ion_match_list.end();
251 << it->toString() <<
max <<
" " << it->getPeak().x <<
" "
252 << it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber();
254 if((charge != it->getCharge()) ||
255 (size != (it->getPeptideFragmentIonSp().get()->size() - 1)))
258 charge = it->getCharge();
263 size = it->getPeptideFragmentIonSp().get()->size();
272 std::vector<bool> covered;
273 covered.resize(msp_peptide.get()->size(),
false);
275 for(
auto &peak : msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList())
277 if(peak.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber() ==
280 if(peak.getPeptideIonType() == ion_type)
282 covered[peak.getPeptideFragmentIonSp().get()->size() - 1] =
true;
286 return std::count(covered.begin(), covered.end(),
true);
293 std::vector<bool> covered;
294 covered.resize(msp_peptide.get()->size(),
false);
296 for(
auto &peak_pair : m_peakIonPairs)
299 peak_pair.first.getPeptideFragmentIonSp().get()->size() - 1;
301 covered[pos + 1] =
true;
303 return std::count(covered.begin(), covered.end(),
true);
311 std::list<pappso::PeakIonIsotopeMatch> peak_ion_type =
312 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList();
315 return (
a.getPeptideIonType() != ion_type);
317 auto peak_it = std::max_element(
318 peak_ion_type.begin(),
321 return (a.getPeak().y < b.getPeak().y);
324 if(peak_it == peak_ion_type.end())
326 return peak_it->getPeak().y;
333 auto peak_it = std::max_element(
334 m_peakIonPairs.begin(),
335 m_peakIonPairs.end(),
336 [](
const std::pair<pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch>
338 const std::pair<pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch>
340 return ((a.first.getPeak().y + a.second.getPeak().y) <
341 (b.first.getPeak().y + b.second.getPeak().y));
344 if(peak_it == m_peakIonPairs.end())
347 return getIonPairPrecursorMassDelta(*peak_it);
352 const std::pair<pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch>
355 qDebug() << m_precursorTheoreticalMz <<
" " << ion_pair.first.getPeak().x
356 <<
" " << ion_pair.second.getPeak().x <<
" "
357 << ion_pair.second.getCharge() <<
" " << ion_pair.first.getCharge()
358 <<
" " << m_parentCharge;
360 (m_precursorTheoreticalMass + (
MHPLUS * ion_pair.first.getCharge())) /
361 ion_pair.first.getCharge();
364 return (diff - (ion_pair.first.getPeak().x + ion_pair.second.getPeak().x -
365 ((
MHPLUS * ion_pair.first.getCharge())) /
366 ion_pair.first.getCharge()));
373 std::size_t peptide_size = peptideSp.get()->size();
374 std::vector<PeakIonIsotopeMatch> ion_isotope_list(
375 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList().begin(),
376 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList().end());
382 ion_isotope_list.end(),
385 if(it != ion_isotope_list.end())
387 m_peakIonPairs.push_back({peak_ion_ext, *it});
397 std::size_t peptide_size = msp_peptide.get()->size();
398 std::vector<PeakIonIsotopeMatch> ion_isotope_list(
399 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList().begin(),
400 msp_peptideSpectrumMatch.get()->getPeakIonIsotopeMatchList().end());
407 std::vector<double> mono_th_intensities(peptide_size, 0);
408 std::vector<double> isotope_th_intensities(peptide_size, 0);
410 std::vector<double> mono_exp_intensities(peptide_size, 0);
411 std::vector<double> isotope_exp_intensities(peptide_size, 0);
414 if(peak_ion_match.getPeptideIonType() == ion_type)
416 std::size_t vector_position =
417 peak_ion_match.getPeptideFragmentIonSp().get()->size() - 1;
419 peak_ion_match.getPeptideNaturalIsotopeAverageSp();
420 if(iso_average_sp.get()->getIsotopeNumber() == 0)
422 mono_th_intensities[vector_position] =
423 iso_average_sp.get()->getIntensityRatio();
424 mono_exp_intensities[vector_position] =
425 peak_ion_match.getPeak().y;
427 else if(iso_average_sp.get()->getIsotopeNumber() == 1)
429 isotope_th_intensities[vector_position] =
430 iso_average_sp.get()->getIntensityRatio();
431 isotope_exp_intensities[vector_position] =
432 peak_ion_match.getPeak().y;
437 for(std::size_t i = 0; i < mono_th_intensities.size(); i++)
439 if((mono_th_intensities[i] != 0) && (isotope_th_intensities[i] != 0))
441 DataPoint xy(mono_th_intensities[i] / isotope_th_intensities[i],
442 mono_exp_intensities[i] /
443 isotope_exp_intensities[i]);
444 scaterplot.push_back(
xy);
453 return linear_regression;
Class to represent a mass spectrum.
static PrecisionPtr getPrecisionPtrFractionInstance(PrecisionPtr origin, double fraction)
get the fraction of an existing precision pointer
std::size_t getNumberOfMatchedIons() const
number of matched ions (peaks)
void findComplementIonPairs(const pappso::PeptideSp &peptideSp)
double getTotalIntensity() const
sum of all peak intensities (matched or not)
double getMatchedMzDiffMean() const
get mean deviation of matched peak mass delta
double getTotalIntensityOfMatchedIonComplementPairs() const
intensity of matched ion complement
std::vector< std::pair< pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch > > m_peakIonPairs
std::shared_ptr< FilterChargeDeconvolution > msp_filterChargeDeconvolution
const std::vector< std::pair< pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch > > & getPeakIonPairs() const
std::shared_ptr< FilterResampleKeepGreater > msp_filterKeepGreater
std::shared_ptr< FilterMzExclusion > msp_filterMzExclusion
double getIonPairPrecursorMassDelta(const std::pair< pappso::PeakIonIsotopeMatch, pappso::PeakIonIsotopeMatch > &ion_pair) const
double m_precursorTheoreticalMz
double getMaxIntensityMatchedIonComplementPairPrecursorMassDelta() const
get the precursor mass delta of the maximum intensity pair of complement ions
std::size_t countMatchedIonComplementPairs() const
count the number of matched ion complement
std::size_t getComplementPairsAaSequenceCoverage()
number of amino acid covered by matched complement pairs of ions
double m_matchedMzDiffMean
double getTotalIntensityOfMatchedIons() const
sum of matched peak intensities
LinearRegression getIonIsotopeLinearRegression() const
unsigned int m_parentCharge
double getMaxIntensityPeakIonMatch(PeptideIon ion_type) const
std::list< PeptideIon > m_ionList
double m_matchedMzDiffMedian
std::shared_ptr< PeptideIsotopeSpectrumMatch > msp_peptideSpectrumMatch
std::size_t getMaxConsecutiveIon(PeptideIon ion_type)
get the maximum consecutive fragments of one ion type
void setPeptideSpectrumCharge(const pappso::PeptideSp peptideSp, const MassSpectrum *p_spectrum, unsigned int parent_charge, unsigned int max_isotope_number)
PrecisionPtr m_ms2precision
double getIntensityOfMatchedIon(PeptideIon ion_type)
get the sum of intensity of a specific ion
pappso::PeptideSp msp_peptide
double m_precursorTheoreticalMass
double getMatchedMzDiffSd() const
get standard deviation of matched peak mass delta
double m_spectrumSumIntensity
std::size_t getAaSequenceCoverage(PeptideIon ion_type)
number of amino acid covered by matched ions
A simple container of DataPoint instances.
void sortX(SortOrder sort_order=SortOrder::ascending)
pappso_double sumY() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
std::shared_ptr< const Peptide > PeptideSp
const pappso_double MHPLUS(1.007276466879)
double pappso_double
A type definition for doubles.
std::shared_ptr< const PeptideNaturalIsotopeAverage > PeptideNaturalIsotopeAverageSp
std::vector< PeakIonIsotopeMatch >::iterator findComplementIonType(std::vector< PeakIonIsotopeMatch >::iterator begin, std::vector< PeakIonIsotopeMatch >::iterator end, const PeakIonIsotopeMatch &peak_ion, std::size_t peptide_size)
find the first element containing the complementary ion complementary ion of y1 is b(n-1) for instanc...
bool peptideIonIsNter(PeptideIon ion_type)
tells if an ion is Nter
@ max
maximum of intensities
comutes various PSM (Peptide Spectrum Match) features