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<PeptideIon> ion_list,
44 RawFragmentationMode fragmentation_mode)
45{
46 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
47 PeptideRawFragmentMasses calc_mass_list_proline(*peptide_sp.get(),
48 fragmentation_mode);
49
50 std::vector<pappso_double> ion_products;
51 unsigned int charge = parent_charge;
52 while(charge > 0)
53 {
54 for(PeptideIon &ion : ion_list)
55 {
56 calc_mass_list_proline.pushBackIonMz(ion_products, ion, charge);
57 }
58 charge--;
59 }
60
61
62 // compute the number of matched peaks
63 unsigned int number_of_matched_peaks = 0;
64
65 std::sort(ion_products.begin(), ion_products.end());
66
67
68 // compute ratio of matched peaks on total peaks
69 std::vector<pappso_double>::const_iterator it_theoretical =
70 ion_products.begin();
71 std::vector<pappso_double>::const_iterator it_theoretical_end =
72 ion_products.end();
73 std::vector<DataPoint>::const_iterator it_spectrum = spectrum.begin();
74 std::vector<DataPoint>::const_iterator it_spectrum_end = spectrum.end();
75 pappso::pappso_double sum_intensities = 0;
76 pappso::pappso_double sum_matched_intensities = 0;
77 // unsigned int peak_number = spectrum.size();
78 while((it_spectrum != it_spectrum_end) &&
79 (it_theoretical != it_theoretical_end))
80 {
81 sum_intensities += it_spectrum->y;
82 MzRange peak_range(it_spectrum->x, precision);
83
84 while((it_theoretical != it_theoretical_end) &&
85 (*it_theoretical < peak_range.lower()))
86 {
87 it_theoretical++;
88 }
89 while((it_theoretical != it_theoretical_end) &&
90 peak_range.contains(*it_theoretical))
91 {
92 sum_matched_intensities += it_spectrum->y;
93 number_of_matched_peaks++;
94 it_theoretical++;
95 }
96 it_spectrum++;
97 }
98 while(it_spectrum != it_spectrum_end)
99 {
100 sum_intensities += it_spectrum->y;
101 it_spectrum++;
102 }
103
104
105 // compute the sum of matching peak intensities
106
107 // morpheus score = number of matched peaks + matching intensities ratio
108
109 _morpheus_score = (pappso_double)number_of_matched_peaks +
110 (sum_matched_intensities / sum_intensities);
111
112 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
113}
114
118
124} // namespace pappso
Class to represent a mass spectrum.
pappso::pappso_double _morpheus_score
pappso::pappso_double getMorpheusScore() const
MorpheusScore(const MassSpectrum &spectrum, pappso::PeptideSp peptideSp, unsigned int parent_charge, PrecisionPtr precision, std::vector< PeptideIon > ion_list, RawFragmentationMode fragmentation_mode)
pappso_double lower() const
Definition mzrange.h:71
bool contains(pappso_double) const
Definition mzrange.cpp:120
void pushBackIonMz(std::vector< pappso_double > &mass_list, PeptideIon ion_type, unsigned int charge) const
basic mass spectrum
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:432
std::shared_ptr< const Peptide > PeptideSp
double pappso_double
A type definition for doubles.
Definition types.h:50