OpenMS
Loading...
Searching...
No Matches
HyperScore.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg, Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
15#include <vector>
16
17namespace OpenMS
18{
19
24struct OPENMS_DLLAPI HyperScore
25{
26 typedef std::pair<Size, double> IndexScorePair;
27
37// static double compute(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum& exp_spectrum, const RichPeakSpectrum& theo_spectrum);
38
39 static double compute(double fragment_mass_tolerance,
40 bool fragment_mass_tolerance_unit_ppm,
41 const PeakSpectrum& exp_spectrum,
42 const PeakSpectrum& theo_spectrum);
43
47 struct PSMDetail
48 {
49 size_t matched_prefix_ions = 0;
50 size_t matched_suffix_ions = 0;
51 double mean_error = 0.0;
52 };
53
54 static double computeWithDetail(double fragment_mass_tolerance,
55 bool fragment_mass_tolerance_unit_ppm,
56 const PeakSpectrum& exp_spectrum,
57 const PeakSpectrum& theo_spectrum,
58 PSMDetail& d
59 );
60
80 static double computeMassAccuracy(double fragment_mass_tolerance,
81 bool fragment_mass_tolerance_unit_ppm,
82 const PeakSpectrum& exp_spectrum,
83 const PeakSpectrum& theo_spectrum,
84 double mass_error_sd_ppm,
85 PSMDetail& detail);
86
95 static double computeWithDetail(double fragment_mass_tolerance,
96 bool fragment_mass_tolerance_unit_ppm,
97 const PeakSpectrum& exp_spectrum,
98 const PeakSpectrum& theo_spectrum,
99 const std::vector<uint8_t>& theo_ion_series,
100 PSMDetail& d);
101
103 static double computeMassAccuracy(double fragment_mass_tolerance,
104 bool fragment_mass_tolerance_unit_ppm,
105 const PeakSpectrum& exp_spectrum,
106 const PeakSpectrum& theo_spectrum,
107 const std::vector<uint8_t>& theo_ion_series,
108 double mass_error_sd_ppm,
109 PSMDetail& detail);
110
111 /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
112 * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
113 * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
114 * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
115 * @param[in] fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
116 * @param[in] fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
117 * @param[in] exp_spectrum measured spectrum
118 * @param[in] exp_charges charges of measured peaks
119 * @param[in] theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
120 * @param[in] theo_charges charges of theoretical peaks
121 */
122 static double compute(double fragment_mass_tolerance,
123 bool fragment_mass_tolerance_unit_ppm,
124 const PeakSpectrum& exp_spectrum,
125 const DataArrays::IntegerDataArray& exp_charges,
126 const PeakSpectrum& theo_spectrum,
127 const DataArrays::IntegerDataArray& theo_charges);
128
129 /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
130 * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
131 * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
132 * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
133 * @param[in] fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
134 * @param[in] fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
135 * @param[in] exp_spectrum measured spectrum
136 * @param[in] exp_charges charges of measured peaks
137 * @param[in] theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
138 * @param[in] theo_charges charges of theoretical peaks
139 * @param[in] intensity_sum summed intensity for observed bond indices (e.g., b3=123 -> intensity_sum[2]=123)
140 * Note: intensity_sum must be zeroed and of size #AA in peptide
141 */
142 static double compute(double fragment_mass_tolerance,
143 bool fragment_mass_tolerance_unit_ppm,
144 const PeakSpectrum& exp_spectrum,
145 const DataArrays::IntegerDataArray& exp_charges,
146 const PeakSpectrum& theo_spectrum,
147 const DataArrays::IntegerDataArray& theo_charges,
148 std::vector<double>& intensity_sum);
149
150 private:
152 static double logfactorial_(const int x, int base = 2);
153};
154
155}
156
157
Integer data array class.
Definition DataArrays.h:75
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
An implementation of the X!Tandem HyperScore PSM scoring function.
Definition HyperScore.h:25
static double computeWithDetail(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const PeakSpectrum &theo_spectrum, PSMDetail &d)
static double compute(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const DataArrays::IntegerDataArray &exp_charges, const PeakSpectrum &theo_spectrum, const DataArrays::IntegerDataArray &theo_charges)
static double logfactorial_(const int x, int base=2)
helper to compute the log factorial
std::pair< Size, double > IndexScorePair
Definition HyperScore.h:26
static double computeMassAccuracy(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const PeakSpectrum &theo_spectrum, const std::vector< uint8_t > &theo_ion_series, double mass_error_sd_ppm, PSMDetail &detail)
computeWithDetail() and computeMassAccuracy() for a theoretical spectrum without ion names
static double compute(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const DataArrays::IntegerDataArray &exp_charges, const PeakSpectrum &theo_spectrum, const DataArrays::IntegerDataArray &theo_charges, std::vector< double > &intensity_sum)
static double computeWithDetail(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const PeakSpectrum &theo_spectrum, const std::vector< uint8_t > &theo_ion_series, PSMDetail &d)
computeWithDetail() and computeMassAccuracy() for a theoretical spectrum without ion names
static double computeMassAccuracy(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const PeakSpectrum &theo_spectrum, double mass_error_sd_ppm, PSMDetail &detail)
HyperScore with mass-accuracy-weighted fragment evidence.
static double compute(double fragment_mass_tolerance, bool fragment_mass_tolerance_unit_ppm, const PeakSpectrum &exp_spectrum, const PeakSpectrum &theo_spectrum)
compute the (ln transformed) X!Tandem HyperScore
compute the (ln transformed) X!Tandem HyperScore overload that returns some additional information on...
Definition HyperScore.h:48