libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
morpheusscore.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/psm/morpheusscore.cpp
3 * \date 16/7/2016
4 * \author Olivier Langella
5 * \brief computation of Morpheus score
6 * https://github.com/cwenger/Morpheus/blob/master/Morpheus/Morpheus/PeptideSpectrumMatch.cs
7 */
8
9/*******************************************************************************
10 * Copyright (c) 2016 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
11 *
12 * This file is part of the PAPPSOms++ library.
13 *
14 * PAPPSOms++ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * PAPPSOms++ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * Contributors:
28 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
29 *implementation
30 ******************************************************************************/
31
32#include "morpheusscore.h"
35
36
37namespace pappso
38{
40 pappso::PeptideSp peptide_sp,
41 unsigned int parent_charge,
42 PrecisionPtr precision,
43 std::vector<Enums::PeptideIon> ion_list,
44 RawFragmentationMode fragmentation_mode)
45{
46 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
47 PeptideRawFragmentMasses calc_mass_list_proline(*peptide_sp.get(), fragmentation_mode);
48
49 std::vector<pappso_double> ion_products;
50 unsigned int charge = parent_charge;
51 while(charge > 0)
52 {
53 for(Enums::PeptideIon &ion : ion_list)
54 {
55 calc_mass_list_proline.pushBackIonMz(ion_products, ion, charge);
56 }
57 charge--;
58 }
59
60
61 // compute the number of matched peaks
62 unsigned int number_of_matched_peaks = 0;
63
64 std::sort(ion_products.begin(), ion_products.end());
65
66
67 // compute ratio of matched peaks on total peaks
68 std::vector<pappso_double>::const_iterator it_theoretical = ion_products.begin();
69 std::vector<pappso_double>::const_iterator it_theoretical_end = ion_products.end();
70 std::vector<DataPoint>::const_iterator it_spectrum = spectrum.begin();
71 std::vector<DataPoint>::const_iterator it_spectrum_end = spectrum.end();
72 pappso::pappso_double sum_intensities = 0;
73 pappso::pappso_double sum_matched_intensities = 0;
74 // unsigned int peak_number = spectrum.size();
75 while((it_spectrum != it_spectrum_end) && (it_theoretical != it_theoretical_end))
76 {
77 sum_intensities += it_spectrum->y;
78 MzRange peak_range(it_spectrum->x, precision);
79
80 while((it_theoretical != it_theoretical_end) && (*it_theoretical < peak_range.lower()))
81 {
82 it_theoretical++;
83 }
84 while((it_theoretical != it_theoretical_end) && peak_range.contains(*it_theoretical))
85 {
86 sum_matched_intensities += it_spectrum->y;
87 number_of_matched_peaks++;
88 it_theoretical++;
89 }
90 it_spectrum++;
91 }
92 while(it_spectrum != it_spectrum_end)
93 {
94 sum_intensities += it_spectrum->y;
95 it_spectrum++;
96 }
97
98
99 // compute the sum of matching peak intensities
100
101 // morpheus score = number of matched peaks + matching intensities ratio
102
104 (pappso_double)number_of_matched_peaks + (sum_matched_intensities / sum_intensities);
105
106 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
107}
108
112
118} // namespace pappso
Class to represent a mass spectrum.
MorpheusScore(const MassSpectrum &spectrum, pappso::PeptideSp peptideSp, unsigned int parent_charge, PrecisionPtr precision, std::vector< Enums::PeptideIon > ion_list, RawFragmentationMode fragmentation_mode)
pappso::pappso_double _morpheus_score
pappso::pappso_double getMorpheusScore() const
pappso_double lower() const
Definition mzrange.h:71
bool contains(pappso_double) const
Definition mzrange.cpp:115
void pushBackIonMz(std::vector< pappso_double > &mass_list, Enums::PeptideIon ion_type, unsigned int charge) const
PeptideIon
Enums::PeptideIon enum defines all types of ions (Nter or Cter).
Definition types.h:286
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const Peptide > PeptideSp
double pappso_double
A type definition for doubles.
Definition types.h:60
const PrecisionBase * PrecisionPtr
Definition precision.h:122