libpappsomspp
Library for mass spectrometry
ionisotoperatioscore.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/psm/experimental/ionisotoperatioscore.cpp
3 * \date 18/05/2019
4 * \author Olivier Langella
5 * \brief psm score computed using ion isotopes
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms++ is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
29#include "../peptideisotopespectrummatch.h"
30#include "../../trace/linearregression.h"
31
32using namespace pappso;
33
34IonIsotopeRatioScore::IonIsotopeRatioScore(const MassSpectrum &spectrum,
35 const PeptideSp &peptide_sp,
36 unsigned int parent_charge,
37 PrecisionPtr precision,
38 std::vector<PeptideIon> ion_vector)
39{
40 std::list<PeptideIon> ion_list(ion_vector.begin(), ion_vector.end());
42 spectrum, peptide_sp, parent_charge, precision, ion_list, 1, 1);
43
44 Trace scaterplot;
45
46 for(PeptideIon ion_type : ion_vector)
47 {
48 std::vector<double> mono_th_intensities(peptide_sp.get()->size(), 0);
49 std::vector<double> isotope_th_intensities(peptide_sp.get()->size(), 0);
50
51 std::vector<double> mono_exp_intensities(peptide_sp.get()->size(), 0);
52 std::vector<double> isotope_exp_intensities(peptide_sp.get()->size(), 0);
53 for(const PeakIonIsotopeMatch &peak_ion_match :
55 {
56 if(peak_ion_match.getPeptideIonType() == ion_type)
57 {
58 std::size_t vector_position =
59 peak_ion_match.getPeptideFragmentIonSp().get()->size() - 1;
60 PeptideNaturalIsotopeAverageSp iso_average_sp =
61 peak_ion_match.getPeptideNaturalIsotopeAverageSp();
62 if(iso_average_sp.get()->getIsotopeNumber() == 0)
63 {
64 mono_th_intensities[vector_position] =
65 iso_average_sp.get()->getIntensityRatio();
66 mono_exp_intensities[vector_position] =
67 peak_ion_match.getPeak().y;
68 }
69 else if(iso_average_sp.get()->getIsotopeNumber() == 1)
70 {
71 isotope_th_intensities[vector_position] =
72 iso_average_sp.get()->getIntensityRatio();
73 isotope_exp_intensities[vector_position] =
74 peak_ion_match.getPeak().y;
75 }
76 }
77 }
78
79 for(std::size_t i = 0; i < mono_th_intensities.size(); i++)
80 {
81 if((mono_th_intensities[i] != 0) && (isotope_th_intensities[i] != 0))
82 {
83 DataPoint xy(mono_th_intensities[i] / isotope_th_intensities[i],
84 mono_exp_intensities[i] /
85 isotope_exp_intensities[i]);
86 scaterplot.push_back(xy);
87 }
88 }
89 }
90
91 scaterplot.sortX();
92
93 LinearRegression linear_regression(scaterplot);
94
96 linear_regression.getCoefficientOfDetermination(scaterplot);
97}
98
99
101{
102}
103
106{
108}
pappso::pappso_double getIonIsotopeRatioScore() const
pappso::pappso_double m_ionIsotopeRatioScore
double getCoefficientOfDetermination(const Trace &data) const
get Coefficient of determination (R2)
Class to represent a mass spectrum.
Definition: massspectrum.h:71
const std::list< PeakIonIsotopeMatch > & getPeakIonIsotopeMatchList() const
A simple container of DataPoint instances.
Definition: trace.h:38
Q_INVOKABLE void sortX()
Definition: trace.cpp:983
psm score computed using ion isotopes
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
Definition: types.h:386
std::shared_ptr< const Peptide > PeptideSp
double pappso_double
A type definition for doubles.
Definition: types.h:49
std::shared_ptr< const PeptideNaturalIsotopeAverage > PeptideNaturalIsotopeAverageSp