All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
12 #include <OpenMS/CONCEPT/Types.h>
13 #include <OpenMS/CONCEPT/Macros.h>
15 #include <vector>
16 
17 namespace OpenMS
18 {
19 
24 struct 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_b_ions = 0;
50  size_t matched_y_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 
61  /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
62  * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
63  * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
64  * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
65  * @param fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
66  * @param fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
67  * @param exp_spectrum measured spectrum
68  * @param exp_charges charges of measured peaks
69  * @param theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
70  * @param theo_charges charges of theoretical peaks
71  */
72  static double compute(double fragment_mass_tolerance,
73  bool fragment_mass_tolerance_unit_ppm,
74  const PeakSpectrum& exp_spectrum,
75  const DataArrays::IntegerDataArray& exp_charges,
76  const PeakSpectrum& theo_spectrum,
77  const DataArrays::IntegerDataArray& theo_charges);
78 
79  /* @brief compute the (ln transformed) X!Tandem HyperScore only matching peaks that match in charge
80  * 1. the dot product of peak intensities between matching peaks in experimental and theoretical spectrum is calculated
81  * 2. the HyperScore is calculated from the dot product by multiplying by factorials of matching b- and y-ions
82  * @note Peak intensities of the theoretical spectrum are typically 1 or TIC normalized, but can also be e.g. ion probabilities
83  * @param fragment_mass_tolerance mass tolerance applied left and right of the theoretical spectrum peak position
84  * @param fragment_mass_tolerance_unit_ppm Unit of the mass tolerance is: Thomson if false, ppm if true
85  * @param exp_spectrum measured spectrum
86  * @param exp_charges charges of measured peaks
87  * @param theo_spectrum theoretical spectrum Peaks need to contain an ion annotation as provided by TheoreticalSpectrumGenerator.
88  * @param theo_charges charges of theoretical peaks
89  * @param intensity_sum summed intensity for observed bond indices (e.g., b3=123 -> intensity_sum[2]=123)
90  * Note: intensity_sum must be zeroed and of size #AA in peptide
91  */
92  static double compute(double fragment_mass_tolerance,
93  bool fragment_mass_tolerance_unit_ppm,
94  const PeakSpectrum& exp_spectrum,
95  const DataArrays::IntegerDataArray& exp_charges,
96  const PeakSpectrum& theo_spectrum,
97  const DataArrays::IntegerDataArray& theo_charges,
98  std::vector<double>& intensity_sum);
99 
100  private:
102  static double logfactorial_(const int x, int base = 2);
103 };
104 
105 }
106 
107 
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 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