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-2013.
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: Alexandra Zerck $
32 // $Authors: Alexandra Zerck, Chris Bielow $
33 // --------------------------------------------------------------------------
34 //
35 #ifndef OPENMS_ANALYSIS_TARGETED_INCLUSIONEXCLUSIONLIST_H
36 #define OPENMS_ANALYSIS_TARGETED_INCLUSIONEXCLUSIONLIST_H
37 
41 
42 namespace OpenMS
43 {
50  class OPENMS_DLLAPI InclusionExclusionList :
51  public DefaultParamHandler
52  {
53 protected:
54  struct IEWindow
55  {
56  IEWindow(const DoubleReal RTmin, const DoubleReal RTmax, const DoubleReal MZ) :
57  RTmin_(RTmin),
58  RTmax_(RTmax),
59  MZ_(MZ)
60  {
61  }
62 
66  };
67 
76  {
77 public:
78  WindowDistance_(const DoubleReal rt_bridge, const DoubleReal mz_max, const bool mz_as_ppm) :
79  rt_bridge_(rt_bridge),
80  mz_max_(mz_max),
81  mz_as_ppm_(mz_as_ppm)
82  {
83  }
84 
85  // measure of SIMILARITY (not distance, i.e. 1-distance)!!
86  double operator()(const IEWindow & first, const IEWindow & second) const
87  {
88  // get MZ distance:
89  DoubleReal d_mz = fabs(first.MZ_ - second.MZ_);
90  if (mz_as_ppm_)
91  {
92  d_mz = d_mz / first.MZ_ * 1e6;
93  }
94  if (d_mz > mz_max_) {return 0; }
95  // mz is close enough ...
96 
97  // is RT overlapping?
98  if (first.RTmin_ <= second.RTmin_ && second.RTmin_ <= first.RTmax_) return 1; // intersect #1
99 
100  if (first.RTmin_ <= second.RTmax_ && second.RTmax_ <= first.RTmax_) return 1; // intersect #2
101 
102  if (second.RTmin_ <= first.RTmin_ && first.RTmax_ <= second.RTmax_) return 1; // complete inclusion (only one case; the other is covered above)
103 
104  // when windows to not overlap at all:
105  // ... are they at least close?
106  if ((fabs(first.RTmin_ - second.RTmax_) <= rt_bridge_) ||
107  (fabs(first.RTmax_ - second.RTmin_) <= rt_bridge_))
108  {
109  return 1;
110  }
111 
112  // not overlapping...
113  return 0;
114  }
115 
116 protected:
117 
120  bool mz_as_ppm_;
121 
122  }; // end of WindowDistance_
123 
124 
125  typedef std::vector<IEWindow> WindowList;
126 
137  void mergeOverlappingWindows_(WindowList & list) const;
138 
139 
149  void writeToFile_(const String & out_path, const WindowList & windows) const;
150 
151 public:
157 
158 
160 
161 // void loadTargets(FeatureMap<>& map, std::vector<IncludeExcludeTarget>& targets,TargetedExperiment& exp);
162 
163 // void loadTargets(std::vector<FASTAFile::FASTAEntry>& fasta_entries, std::vector<IncludeExcludeTarget>& targets,
164 // TargetedExperiment& exp, Size missed_cleavages = 0);
165 
166 
172  void writeTargets(const std::vector<FASTAFile::FASTAEntry> & fasta_entries,
173  const String & out_path,
174  const IntList & charges,
175  const String rt_model_path);
176 
182  void writeTargets(const FeatureMap<> & map,
183  const String & out_path);
184 
192  void writeTargets(const std::vector<PeptideIdentification> & pep_ids,
193  const String & out_path,
194  const IntList & charges);
195 
196  };
197 
198 
199 }
200 
201 #endif
A more convenient string class.
Definition: String.h:56
IEWindow(const DoubleReal RTmin, const DoubleReal RTmax, const DoubleReal MZ)
Definition: InclusionExclusionList.h:56
Provides functionalty for writing inclusion or exclusion lists.
Definition: InclusionExclusionList.h:50
DoubleReal RTmax_
Definition: InclusionExclusionList.h:64
DoubleReal rt_bridge_
max rt distance between two windows in order to be considered overlapping
Definition: InclusionExclusionList.h:118
DoubleReal mz_max_
max m/z distance between two ...
Definition: InclusionExclusionList.h:119
DoubleReal RTmin_
Definition: InclusionExclusionList.h:63
double operator()(const IEWindow &first, const IEWindow &second) const
Definition: InclusionExclusionList.h:86
std::vector< IEWindow > WindowList
Definition: InclusionExclusionList.h:125
Determine distance between two spectra.
Definition: InclusionExclusionList.h:75
bool mz_as_ppm_
m/z distance unit
Definition: InclusionExclusionList.h:120
DoubleReal MZ_
Definition: InclusionExclusionList.h:65
WindowDistance_(const DoubleReal rt_bridge, const DoubleReal mz_max, const bool mz_as_ppm)
Definition: InclusionExclusionList.h:78
Definition: InclusionExclusionList.h:54
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:90
Int list.
Definition: IntList.h:56

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:15 using doxygen 1.8.5