OpenMS
RNPxlFragmentAnnotationHelper.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2023.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Timo Sachsenberg $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 
42 #include <set>
43 #include <map>
44 #include <vector>
45 #include <algorithm>
46 
47 namespace OpenMS
48 {
49 namespace Internal
50 {
51 
57 class OPENMS_DLLAPI RNPxlFragmentAnnotationHelper
58 {
59  public:
60 
62  struct OPENMS_DLLAPI FragmentAnnotationDetail_
63  {
64  FragmentAnnotationDetail_(String s, int z, double m, double i):
65  shift(s),
66  charge(z),
67  mz(m),
68  intensity(i)
69  {}
71  int charge;
72  double mz;
73  double intensity;
74 
75  bool operator<(const FragmentAnnotationDetail_& other) const
76  {
77  return std::tie(charge, shift, mz, intensity) <
78  std::tie(other.charge, other.shift, other.mz, other.intensity);
79  }
80 
81  bool operator==(const FragmentAnnotationDetail_& other) const
82  {
83  double mz_diff = fabs(mz - other.mz);
84  double intensity_diff = fabs(intensity - other.intensity);
85  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
86  }
87  };
88 
89  static String getAnnotatedImmoniumIon(char c, const String& fragment_shift_name);
90 
92  static std::vector<PeptideHit::PeakAnnotation> fragmentAnnotationDetailsToPHFA(
93  const String& ion_type,
94  const std::map<Size, std::vector<FragmentAnnotationDetail_> >& ion_annotation_details);
95 
96  static std::vector<PeptideHit::PeakAnnotation> shiftedToPHFA(
97  const std::map<String,
98  std::set<std::pair<String, double> > >& shifted_ions);
99 
100 
101  static String shiftedIonsToString(const std::vector<PeptideHit::PeakAnnotation>& as);
102 
103  static void addShiftedPeakFragmentAnnotation_(const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_b_ions,
104  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_y_ions,
105  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_a_ions,
106  const std::vector<PeptideHit::PeakAnnotation>& shifted_immonium_ions,
107  const std::vector<PeptideHit::PeakAnnotation>& annotated_marker_ions,
108  const std::vector<PeptideHit::PeakAnnotation>& annotated_precursor_ions,
109  std::vector<PeptideHit::PeakAnnotation>& fas);
110 };
111 } // namespace Internal
112 } // namespace OpenMS
113 
114 
Convenience functions to construct appealing fragment annotation strings and store them as PeptideHit...
Definition: RNPxlFragmentAnnotationHelper.h:58
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:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const double c
Definition: Constants.h:214
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
Single fragment annotation.
Definition: RNPxlFragmentAnnotationHelper.h:63
double intensity
Definition: RNPxlFragmentAnnotationHelper.h:73
double mz
Definition: RNPxlFragmentAnnotationHelper.h:72
String shift
Definition: RNPxlFragmentAnnotationHelper.h:70
bool operator==(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:81
FragmentAnnotationDetail_(String s, int z, double m, double i)
Definition: RNPxlFragmentAnnotationHelper.h:64
bool operator<(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:75
int charge
Definition: RNPxlFragmentAnnotationHelper.h:71