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
87 /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
88 * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
89 * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
90 * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
91 * @param[in] fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
92 * @param[in] fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
93 * @param[in] exp_spectrum measured spectrum
94 * @param[in] exp_charges charges of measured peaks
95 * @param[in] theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
96 * @param[in] theo_charges charges of theoretical peaks
97 */
98 static double compute(double fragment_mass_tolerance,
99 bool fragment_mass_tolerance_unit_ppm,
100 const PeakSpectrum& exp_spectrum,
101 const DataArrays::IntegerDataArray& exp_charges,
102 const PeakSpectrum& theo_spectrum,
103 const DataArrays::IntegerDataArray& theo_charges);
104
105 /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
106 * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
107 * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
108 * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
109 * @param[in] fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
110 * @param[in] fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
111 * @param[in] exp_spectrum measured spectrum
112 * @param[in] exp_charges charges of measured peaks
113 * @param[in] theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
114 * @param[in] theo_charges charges of theoretical peaks
115 * @param[in] intensity_sum summed intensity for observed bond indices (e.g., b3=123 -> intensity_sum[2]=123)
116 * Note: intensity_sum must be zeroed and of size #AA in peptide
117 */
118 static double compute(double fragment_mass_tolerance,
119 bool fragment_mass_tolerance_unit_ppm,
120 const PeakSpectrum& exp_spectrum,
121 const DataArrays::IntegerDataArray& exp_charges,
122 const PeakSpectrum& theo_spectrum,
123 const DataArrays::IntegerDataArray& theo_charges,
124 std::vector<double>& intensity_sum);
125
126 private:
128 static double logfactorial_(const int x, int base = 2);
129};
130
131}
132
133
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 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 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