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

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:01 using doxygen 1.8.13