OpenMS
RNPxlFragmentAnnotationHelper.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 $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
15 
16 #include <set>
17 #include <map>
18 #include <vector>
19 #include <algorithm>
20 
21 namespace OpenMS
22 {
23 namespace Internal
24 {
25 
31 class OPENMS_DLLAPI RNPxlFragmentAnnotationHelper
32 {
33  public:
34 
36  struct OPENMS_DLLAPI FragmentAnnotationDetail_
37  {
38  FragmentAnnotationDetail_(String s, int z, double m, double i):
39  shift(s),
40  charge(z),
41  mz(m),
42  intensity(i)
43  {}
45  int charge;
46  double mz;
47  double intensity;
48 
49  bool operator<(const FragmentAnnotationDetail_& other) const
50  {
51  return std::tie(charge, shift, mz, intensity) <
52  std::tie(other.charge, other.shift, other.mz, other.intensity);
53  }
54 
55  bool operator==(const FragmentAnnotationDetail_& other) const
56  {
57  double mz_diff = fabs(mz - other.mz);
58  double intensity_diff = fabs(intensity - other.intensity);
59  return (charge == other.charge && shift == other.shift && mz_diff < 1e-6 && intensity_diff < 1e-6); // mz and intensity difference comparison actually not needed but kept for completeness
60  }
61  };
62 
63  static String getAnnotatedImmoniumIon(char c, const String& fragment_shift_name);
64 
66  static std::vector<PeptideHit::PeakAnnotation> fragmentAnnotationDetailsToPHFA(
67  const String& ion_type,
68  const std::map<Size, std::vector<FragmentAnnotationDetail_> >& ion_annotation_details);
69 
70  static std::vector<PeptideHit::PeakAnnotation> shiftedToPHFA(
71  const std::map<String,
72  std::set<std::pair<String, double> > >& shifted_ions);
73 
74 
75  static String shiftedIonsToString(const std::vector<PeptideHit::PeakAnnotation>& as);
76 
77  static void addShiftedPeakFragmentAnnotation_(const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_b_ions,
78  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_y_ions,
79  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_a_ions,
80  const std::vector<PeptideHit::PeakAnnotation>& shifted_immonium_ions,
81  const std::vector<PeptideHit::PeakAnnotation>& annotated_marker_ions,
82  const std::vector<PeptideHit::PeakAnnotation>& annotated_precursor_ions,
83  std::vector<PeptideHit::PeakAnnotation>& fas);
84 };
85 } // namespace Internal
86 } // namespace OpenMS
87 
88 
Convenience functions to construct appealing fragment annotation strings and store them as PeptideHit...
Definition: RNPxlFragmentAnnotationHelper.h:32
static String shiftedIonsToString(const std::vector< PeptideHit::PeakAnnotation > &as)
static std::vector< PeptideHit::PeakAnnotation > shiftedToPHFA(const std::map< String, std::set< std::pair< String, double > > > &shifted_ions)
static std::vector< PeptideHit::PeakAnnotation > fragmentAnnotationDetailsToPHFA(const String &ion_type, const std::map< Size, std::vector< FragmentAnnotationDetail_ > > &ion_annotation_details)
conversion of RNPxl annotations to PeptideHit::PeakAnnotation
static String getAnnotatedImmoniumIon(char c, const String &fragment_shift_name)
static void addShiftedPeakFragmentAnnotation_(const std::map< Size, std::vector< FragmentAnnotationDetail_ >> &shifted_b_ions, const std::map< Size, std::vector< FragmentAnnotationDetail_ >> &shifted_y_ions, const std::map< Size, std::vector< FragmentAnnotationDetail_ >> &shifted_a_ions, const std::vector< PeptideHit::PeakAnnotation > &shifted_immonium_ions, const std::vector< PeptideHit::PeakAnnotation > &annotated_marker_ions, const std::vector< PeptideHit::PeakAnnotation > &annotated_precursor_ions, std::vector< PeptideHit::PeakAnnotation > &fas)
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
const double c
Definition: Constants.h:188
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Single fragment annotation.
Definition: RNPxlFragmentAnnotationHelper.h:37
double intensity
Definition: RNPxlFragmentAnnotationHelper.h:47
double mz
Definition: RNPxlFragmentAnnotationHelper.h:46
String shift
Definition: RNPxlFragmentAnnotationHelper.h:44
bool operator==(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:55
FragmentAnnotationDetail_(String s, int z, double m, double i)
Definition: RNPxlFragmentAnnotationHelper.h:38
bool operator<(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:49
int charge
Definition: RNPxlFragmentAnnotationHelper.h:45