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