OpenMS  3.0.0
NuXLFragmentAnnotationHelper.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-2022.
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 
55 class OPENMS_DLLAPI NuXLFragmentAnnotationHelper
56 {
57  public:
58 
60  struct OPENMS_DLLAPI FragmentAnnotationDetail_
61  {
62  FragmentAnnotationDetail_(String s, int z, double m, double i):
63  shift(s),
64  charge(z),
65  mz(m),
66  intensity(i)
67  {}
69  int charge;
70  double mz;
71  double intensity;
72 
73  bool operator<(const FragmentAnnotationDetail_& other) const
74  {
75  return std::tie(charge, shift, mz, intensity) <
76  std::tie(other.charge, other.shift, other.mz, other.intensity);
77  }
78 
79  bool operator==(const FragmentAnnotationDetail_& other) const
80  {
81  double mz_diff = fabs(mz - other.mz);
82  double intensity_diff = fabs(intensity - other.intensity);
83  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
84  }
85  };
86 
87  static String getAnnotatedImmoniumIon(char c, const String& fragment_shift_name);
88 
90  static std::vector<PeptideHit::PeakAnnotation> fragmentAnnotationDetailsToPHFA(
91  const String& ion_type,
92  const std::map<Size, std::vector<FragmentAnnotationDetail_> >& ion_annotation_details);
93 
94  static std::vector<PeptideHit::PeakAnnotation> shiftedToPHFA(
95  const std::map<String,
96  std::set<std::pair<String, double> > >& shifted_ions);
97 
98 
99  static String shiftedIonsToString(const std::vector<PeptideHit::PeakAnnotation>& as);
100 
101  static void addShiftedPeakFragmentAnnotation_(const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_b_ions,
102  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_y_ions,
103  const std::map<Size, std::vector<FragmentAnnotationDetail_>>& shifted_a_ions,
104  const std::vector<PeptideHit::PeakAnnotation>& shifted_immonium_ions,
105  const std::vector<PeptideHit::PeakAnnotation>& annotated_marker_ions,
106  const std::vector<PeptideHit::PeakAnnotation>& annotated_precursor_ions,
107  std::vector<PeptideHit::PeakAnnotation>& fas);
108 };
109 } // namespace OpenMS
110 
111 
A more convenient string class.
Definition: String.h:58
int charge
Definition: NuXLFragmentAnnotationHelper.h:69
bool operator==(const FragmentAnnotationDetail_ &other) const
Definition: NuXLFragmentAnnotationHelper.h:79
double mz
Definition: NuXLFragmentAnnotationHelper.h:70
String shift
Definition: NuXLFragmentAnnotationHelper.h:68
FragmentAnnotationDetail_(String s, int z, double m, double i)
Definition: NuXLFragmentAnnotationHelper.h:62
const double c
Definition: Constants.h:214
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
double intensity
Definition: NuXLFragmentAnnotationHelper.h:71
Convenience functions to construct appealing fragment annotation strings and store them as PeptideHit...
Definition: NuXLFragmentAnnotationHelper.h:55
Single fragment annotation.
Definition: NuXLFragmentAnnotationHelper.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
bool operator<(const FragmentAnnotationDetail_ &other) const
Definition: NuXLFragmentAnnotationHelper.h:73