| OpenMS 2.5.0

InclusionExclusionList.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: Alexandra Zerck, Chris Bielow $
33 // --------------------------------------------------------------------------
34 //
35 #pragma once
36
37 #include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h>
38 #include <OpenMS/FORMAT/FASTAFile.h>
39 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
40 #include <OpenMS/METADATA/PeptideIdentification.h>
41
42 namespace OpenMS
43 {
44 class FeatureMap;
45
52 class OPENMS_DLLAPI InclusionExclusionList :
53 public DefaultParamHandler
54 {
55 protected:
56 struct IEWindow
57 {
58 IEWindow(const double RTmin, const double RTmax, const double MZ) :
59 RTmin_(RTmin),
60 RTmax_(RTmax),
61 MZ_(MZ)
62 {
63 }
64
65 double RTmin_;
66 double RTmax_;
67 double MZ_;
68 };
69
77 class WindowDistance_
78 {
79 public:
80 WindowDistance_(const double rt_bridge, const double mz_max, const bool mz_as_ppm) :
81 rt_bridge_(rt_bridge),
82 mz_max_(mz_max),
83 mz_as_ppm_(mz_as_ppm)
84 {
85 }
86
87 // measure of SIMILARITY (not distance, i.e. 1-distance)!!
88 double operator()(const IEWindow& first, const IEWindow& second) const
89 {
90 // get MZ distance:
91 double d_mz = fabs(first.MZ_ - second.MZ_);
92 if (mz_as_ppm_)
93 {
94 d_mz = d_mz / first.MZ_ * 1e6;
95 }
96 if (d_mz > mz_max_) {return 0; }
97 // mz is close enough ...
98
99 // is RT overlapping?
100 if (first.RTmin_ <= second.RTmin_ && second.RTmin_ <= first.RTmax_) return 1; // intersect #1
101
102 if (first.RTmin_ <= second.RTmax_ && second.RTmax_ <= first.RTmax_) return 1; // intersect #2
103
104 if (second.RTmin_ <= first.RTmin_ && first.RTmax_ <= second.RTmax_) return 1; // complete inclusion (only one case; the other is covered above)
105
106 // when windows to not overlap at all:
107 // ... are they at least close?
108 if ((fabs(first.RTmin_ - second.RTmax_) <= rt_bridge_) ||
109 (fabs(first.RTmax_ - second.RTmin_) <= rt_bridge_))
110 {
111 return 1;
112 }
113
114 // not overlapping...
115 return 0;
116 }
117
118 protected:
119
120 double rt_bridge_;
121 double mz_max_;
122 bool mz_as_ppm_;
123
124 }; // end of WindowDistance_
125
126
127 typedef std::vector<IEWindow> WindowList;
128
139 void mergeOverlappingWindows_(WindowList& list) const;
140
141
151 void writeToFile_(const String& out_path, const WindowList& windows) const;
152
153 public:
157 InclusionExclusionList();
159
160
162
163 // void loadTargets(FeatureMap& map, std::vector<IncludeExcludeTarget>& targets,TargetedExperiment& exp);
164
165 // void loadTargets(std::vector<FASTAFile::FASTAEntry>& fasta_entries, std::vector<IncludeExcludeTarget>& targets,
166 // TargetedExperiment& exp, Size missed_cleavages = 0);
167
168
174 void writeTargets(const std::vector<FASTAFile::FASTAEntry>& fasta_entries,
175 const String& out_path,
176 const IntList& charges,
177 const String rt_model_path);
178
184 void writeTargets(const FeatureMap& map,
185 const String& out_path);
186
194 void writeTargets(const std::vector<PeptideIdentification>& pep_ids,
195 const String& out_path,
196 const IntList& charges);
197
198 };
199
200
201 }
202
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::InclusionExclusionList::WindowDistance_::operator()
double operator()(const IEWindow &first, const IEWindow &second) const
Definition: InclusionExclusionList.h:88
OpenMS::IntList
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:55
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
TargetedExperiment.h
OpenMS::InclusionExclusionList::IEWindow::RTmax_
double RTmax_
Definition: InclusionExclusionList.h:66
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:95
OpenMS::InclusionExclusionList::IEWindow
Definition: InclusionExclusionList.h:56
FASTAFile.h
OpenMS::InclusionExclusionList::WindowList
std::vector< IEWindow > WindowList
Definition: InclusionExclusionList.h:127
OpenMS::InclusionExclusionList::WindowDistance_::mz_as_ppm_
bool mz_as_ppm_
m/z distance unit
Definition: InclusionExclusionList.h:122
PeptideIdentification.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::InclusionExclusionList
Provides functionality for writing inclusion or exclusion lists.
Definition: InclusionExclusionList.h:52
DefaultParamHandler.h
OpenMS::InclusionExclusionList::IEWindow::RTmin_
double RTmin_
Definition: InclusionExclusionList.h:65
OpenMS::InclusionExclusionList::WindowDistance_::mz_max_
double mz_max_
max m/z distance between two ...
Definition: InclusionExclusionList.h:121
OpenMS::InclusionExclusionList::WindowDistance_
Determine distance between two spectra.
Definition: InclusionExclusionList.h:77
OpenMS::InclusionExclusionList::IEWindow::MZ_
double MZ_
Definition: InclusionExclusionList.h:67
OpenMS::InclusionExclusionList::WindowDistance_::WindowDistance_
WindowDistance_(const double rt_bridge, const double mz_max, const bool mz_as_ppm)
Definition: InclusionExclusionList.h:80
OpenMS::InclusionExclusionList::WindowDistance_::rt_bridge_
double rt_bridge_
max rt distance between two windows in order to be considered overlapping
Definition: InclusionExclusionList.h:120
OpenMS::InclusionExclusionList::IEWindow::IEWindow
IEWindow(const double RTmin, const double RTmax, const double MZ)
Definition: InclusionExclusionList.h:58