Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
ConsensusFeature.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: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 #include <OpenMS/CONCEPT/Types.h>
43 #include <OpenMS/OpenMSConfig.h>
44 
45 #include <set>
46 
47 namespace OpenMS
48 {
49  class FeatureMap;
50  class Peak2D;
51 
64  class OPENMS_DLLAPI ConsensusFeature :
65  public BaseFeature
66  {
67 public:
69 
70  typedef std::set<FeatureHandle, FeatureHandle::IndexLess> HandleSetType;
71  typedef HandleSetType::const_iterator const_iterator;
72  typedef HandleSetType::iterator iterator;
73  typedef HandleSetType::const_reverse_iterator const_reverse_iterator;
74  typedef HandleSetType::reverse_iterator reverse_iterator;
76 
78  struct SizeLess :
79  std::binary_function<ConsensusFeature, ConsensusFeature, bool>
80  {
81  inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
82  {
83  return left.size() < right.size();
84  }
85 
86  inline bool operator()(ConsensusFeature const& left, UInt64 const& right) const
87  {
88  return left.size() < right;
89  }
90 
91  inline bool operator()(UInt64 const& left, ConsensusFeature const& right) const
92  {
93  return left < right.size();
94  }
95 
96  inline bool operator()(const UInt64& left, const UInt64& right) const
97  {
98  return left < right;
99  }
100 
101  };
102 
104  struct MapsLess :
105  std::binary_function<ConsensusFeature, ConsensusFeature, bool>
106  {
107  inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
108  {
109  return std::lexicographical_compare(left.begin(), left.end(), right.begin(), right.end(), FeatureHandle::IndexLess());
110  }
111 
112  };
113 
115  struct Ratio
116  {
118  {
119  }
120 
121  Ratio(const Ratio& rhs)
122  {
123  ratio_value_ = rhs.ratio_value_;
124  denominator_ref_ = rhs.denominator_ref_;
125  numerator_ref_ = rhs.numerator_ref_;
126  description_ = rhs.description_;
127  }
128 
129  virtual ~Ratio()
130  {
131  }
132 
133  Ratio& operator=(const Ratio& rhs)
134  {
135  if (&rhs != this)
136  {
137  ratio_value_ = rhs.ratio_value_;
138  denominator_ref_ = rhs.denominator_ref_;
139  numerator_ref_ = rhs.numerator_ref_;
140  description_ = rhs.description_;
141  }
142  return *this;
143  }
144 
145  double ratio_value_;
148  std::vector<String> description_;
149  //TODO ratio cv info
150  };
151 
153 
156 
159 
161  explicit ConsensusFeature(const BaseFeature& feature);
162 
169  ConsensusFeature(UInt64 map_index, const Peak2D& element, UInt64 element_index);
170 
177  ConsensusFeature(UInt64 map_index, const BaseFeature& element);
178 
180  ConsensusFeature& operator=(const ConsensusFeature& rhs);
181 
183  ~ConsensusFeature() override;
185 
186 
188 
189 
193  void insert(const ConsensusFeature& cf);
194 
201  void insert(const FeatureHandle& handle);
202 
204  void insert(const HandleSetType& handle_set);
205 
212  void insert(UInt64 map_index, const Peak2D& element, UInt64 element_index);
213 
220  void insert(UInt64 map_index, const BaseFeature& element);
221 
223  const HandleSetType& getFeatures() const;
224 
226  std::vector<FeatureHandle> getFeatureList() const;
228 
230 
231  DRange<2> getPositionRange() const;
234  DRange<1> getIntensityRange() const;
235 
237 
247  void computeConsensus();
248 
258  void computeMonoisotopicConsensus();
259 
273  void computeDechargeConsensus(const FeatureMap& fm, bool intensity_weighted_averaging = false);
274 
282  void addRatio(const Ratio& r);
283 
291  void setRatios(std::vector<Ratio>& rs);
292 
296  std::vector<Ratio> getRatios() const;
297 
301  std::vector<Ratio>& getRatios();
302 
304 
305  Size size() const;
306 
307  const_iterator begin() const;
308 
309  iterator begin();
310 
311  const_iterator end() const;
312 
313  iterator end();
314 
315  const_reverse_iterator rbegin() const;
316 
317  reverse_iterator rbegin();
318 
319  const_reverse_iterator rend() const;
320 
321  reverse_iterator rend();
322 
323  void clear();
324 
325  bool empty() const;
327 
328 private:
330  std::vector<Ratio> ratios_;
331 
332  };
333 
335  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusFeature& cons);
336 
337 } // namespace OpenMS
338 
virtual ~Ratio()
Definition: ConsensusFeature.h:129
const_iterator begin() const
A more convenient string class.
Definition: String.h:57
HandleSetType::const_reverse_iterator const_reverse_iterator
Definition: ConsensusFeature.h:73
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
Compare by size(), the number of consensus elements.
Definition: ConsensusFeature.h:78
A container for features.
Definition: FeatureMap.h:93
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:107
Compare by the sets of consensus elements (lexicographically)
Definition: ConsensusFeature.h:104
Comparator by map and unique id.
Definition: FeatureHandle.h:140
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
const_iterator end() const
HandleSetType handles_
Definition: ConsensusFeature.h:329
A basic LC-MS feature.
Definition: BaseFeature.h:55
String numerator_ref_
Definition: ConsensusFeature.h:147
bool operator()(const UInt64 &left, const UInt64 &right) const
Definition: ConsensusFeature.h:96
Ratio(const Ratio &rhs)
Definition: ConsensusFeature.h:121
std::vector< Ratio > ratios_
Definition: ConsensusFeature.h:330
double ratio_value_
Definition: ConsensusFeature.h:145
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
bool operator()(ConsensusFeature const &left, UInt64 const &right) const
Definition: ConsensusFeature.h:86
std::set< FeatureHandle, FeatureHandle::IndexLess > HandleSetType
Type definitions.
Definition: ConsensusFeature.h:70
slim struct to feed the need for systematically storing of ratios (
Definition: ConsensusFeature.h:115
Ratio & operator=(const Ratio &rhs)
Definition: ConsensusFeature.h:133
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
std::vector< String > description_
Definition: ConsensusFeature.h:148
bool operator()(UInt64 const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:91
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
HandleSetType::iterator iterator
Definition: ConsensusFeature.h:72
HandleSetType::const_iterator const_iterator
Definition: ConsensusFeature.h:71
String denominator_ref_
Definition: ConsensusFeature.h:146
HandleSetType::reverse_iterator reverse_iterator
Definition: ConsensusFeature.h:74
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:81
Ratio()
Definition: ConsensusFeature.h:117
A 2-dimensional consensus feature.
Definition: ConsensusFeature.h:64

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:04 using doxygen 1.8.14