| OpenMS 2.5.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-2020.
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
37 #include <OpenMS/KERNEL/StandardTypes.h>
38 #include <OpenMS/CONCEPT/Constants.h>
39 #include <OpenMS/DATASTRUCTURES/String.h>
40 #include <OpenMS/METADATA/PeptideHit.h>
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 {}
70 String shift;
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 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
Constants.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::charge
int charge
Definition: RNPxlFragmentAnnotationHelper.h:71
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::FragmentAnnotationDetail_
FragmentAnnotationDetail_(String s, int z, double m, double i)
Definition: RNPxlFragmentAnnotationHelper.h:64
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::operator==
bool operator==(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:81
StandardTypes.h
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_
Single fragment annotation.
Definition: RNPxlFragmentAnnotationHelper.h:62
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::operator<
bool operator<(const FragmentAnnotationDetail_ &other) const
Definition: RNPxlFragmentAnnotationHelper.h:75
OpenMS::Internal::RNPxlFragmentAnnotationHelper
Convenience functions to construct appealing fragment annotation strings and store them as PeptideHit...
Definition: RNPxlFragmentAnnotationHelper.h:57
PeptideHit.h
String.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::shift
String shift
Definition: RNPxlFragmentAnnotationHelper.h:70
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::intensity
double intensity
Definition: RNPxlFragmentAnnotationHelper.h:73
OpenMS::Constants::c
const double c
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Internal::RNPxlFragmentAnnotationHelper::FragmentAnnotationDetail_::mz
double mz
Definition: RNPxlFragmentAnnotationHelper.h:72