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 #ifndef OPENMS_KERNEL_CONSENSUSFEATURE_H
36 #define OPENMS_KERNEL_CONSENSUSFEATURE_H
37 
41 
42 #include <OpenMS/CONCEPT/Types.h>
44 #include <OpenMS/OpenMSConfig.h>
45 
46 #include <set>
47 
48 namespace OpenMS
49 {
50  class FeatureMap;
51  class Peak2D;
52 
65  class OPENMS_DLLAPI ConsensusFeature :
66  public BaseFeature
67  {
68 public:
70 
71  typedef std::set<FeatureHandle, FeatureHandle::IndexLess> HandleSetType;
72  typedef HandleSetType::const_iterator const_iterator;
73  typedef HandleSetType::iterator iterator;
74  typedef HandleSetType::const_reverse_iterator const_reverse_iterator;
75  typedef HandleSetType::reverse_iterator reverse_iterator;
77 
79  struct SizeLess :
80  std::binary_function<ConsensusFeature, ConsensusFeature, bool>
81  {
82  inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
83  {
84  return left.size() < right.size();
85  }
86 
87  inline bool operator()(ConsensusFeature const& left, UInt64 const& right) const
88  {
89  return left.size() < right;
90  }
91 
92  inline bool operator()(UInt64 const& left, ConsensusFeature const& right) const
93  {
94  return left < right.size();
95  }
96 
97  inline bool operator()(const UInt64& left, const UInt64& right) const
98  {
99  return left < right;
100  }
101 
102  };
103 
105  struct MapsLess :
106  std::binary_function<ConsensusFeature, ConsensusFeature, bool>
107  {
108  inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
109  {
110  return std::lexicographical_compare(left.begin(), left.end(), right.begin(), right.end(), FeatureHandle::IndexLess());
111  }
112 
113  };
114 
116  struct Ratio
117  {
119  {
120  }
121 
122  Ratio(const Ratio& rhs)
123  {
124  ratio_value_ = rhs.ratio_value_;
125  denominator_ref_ = rhs.denominator_ref_;
126  numerator_ref_ = rhs.numerator_ref_;
127  description_ = rhs.description_;
128  }
129 
130  virtual ~Ratio()
131  {
132  }
133 
134  Ratio& operator=(const Ratio& rhs)
135  {
136  if (&rhs != this)
137  {
138  ratio_value_ = rhs.ratio_value_;
139  denominator_ref_ = rhs.denominator_ref_;
140  numerator_ref_ = rhs.numerator_ref_;
141  description_ = rhs.description_;
142  }
143  return *this;
144  }
145 
146  double ratio_value_;
149  std::vector<String> description_;
150  //TODO ratio cv info
151  };
152 
154 
157 
160 
162  explicit ConsensusFeature(const BaseFeature& feature);
163 
170  ConsensusFeature(UInt64 map_index, const Peak2D& element, UInt64 element_index);
171 
178  ConsensusFeature(UInt64 map_index, const BaseFeature& element);
179 
181  ConsensusFeature& operator=(const ConsensusFeature& rhs);
182 
184  virtual ~ConsensusFeature();
186 
187 
189 
190 
194  void insert(const ConsensusFeature& cf);
195 
202  void insert(const FeatureHandle& handle);
203 
205  void insert(const HandleSetType& handle_set);
206 
213  void insert(UInt64 map_index, const Peak2D& element, UInt64 element_index);
214 
221  void insert(UInt64 map_index, const BaseFeature& element);
222 
224  const HandleSetType& getFeatures() const;
225 
227  std::vector<FeatureHandle> getFeatureList() const;
229 
231 
232  DRange<2> getPositionRange() const;
235  DRange<1> getIntensityRange() const;
236 
238 
248  void computeConsensus();
249 
259  void computeMonoisotopicConsensus();
260 
274  void computeDechargeConsensus(const FeatureMap& fm, bool intensity_weighted_averaging = false);
275 
283  void addRatio(const Ratio& r);
284 
292  void setRatios(std::vector<Ratio>& rs);
293 
297  std::vector<Ratio> getRatios() const;
298 
302  std::vector<Ratio>& getRatios();
303 
305 
306  Size size() const;
307 
308  const_iterator begin() const;
309 
310  iterator begin();
311 
312  const_iterator end() const;
313 
314  iterator end();
315 
316  const_reverse_iterator rbegin() const;
317 
318  reverse_iterator rbegin();
319 
320  const_reverse_iterator rend() const;
321 
322  reverse_iterator rend();
323 
324  void clear();
325 
326  bool empty() const;
328 
329 private:
330  HandleSetType handles_;
331  std::vector<Ratio> ratios_;
332 
333  };
334 
336  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusFeature& cons);
337 
338 } // namespace OpenMS
339 
340 #endif // OPENMS_KERNEL_CONSENSUSFEATURE_H
virtual ~Ratio()
Definition: ConsensusFeature.h:130
const_iterator begin() const
A more convenient string class.
Definition: String.h:57
HandleSetType::const_reverse_iterator const_reverse_iterator
Definition: ConsensusFeature.h:74
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
Compare by size(), the number of consensus elements.
Definition: ConsensusFeature.h:79
A container for features.
Definition: FeatureMap.h:94
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:108
Compare by the sets of consensus elements (lexicographically)
Definition: ConsensusFeature.h:105
Comparator by map and unique id.
Definition: FeatureHandle.h:141
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
const_iterator end() const
HandleSetType handles_
Definition: ConsensusFeature.h:330
A basic LC-MS feature.
Definition: BaseFeature.h:56
String numerator_ref_
Definition: ConsensusFeature.h:148
bool operator()(const UInt64 &left, const UInt64 &right) const
Definition: ConsensusFeature.h:97
Ratio(const Ratio &rhs)
Definition: ConsensusFeature.h:122
std::vector< Ratio > ratios_
Definition: ConsensusFeature.h:331
double ratio_value_
Definition: ConsensusFeature.h:146
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
bool operator()(ConsensusFeature const &left, UInt64 const &right) const
Definition: ConsensusFeature.h:87
std::set< FeatureHandle, FeatureHandle::IndexLess > HandleSetType
Type definitions.
Definition: ConsensusFeature.h:71
slim struct to feed the need for systematically storing of ratios (
Definition: ConsensusFeature.h:116
Ratio & operator=(const Ratio &rhs)
Definition: ConsensusFeature.h:134
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:78
std::vector< String > description_
Definition: ConsensusFeature.h:149
bool operator()(UInt64 const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:92
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:58
HandleSetType::iterator iterator
Definition: ConsensusFeature.h:73
HandleSetType::const_iterator const_iterator
Definition: ConsensusFeature.h:72
String denominator_ref_
Definition: ConsensusFeature.h:147
HandleSetType::reverse_iterator reverse_iterator
Definition: ConsensusFeature.h:75
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:82
Ratio()
Definition: ConsensusFeature.h:118
A 2-dimensional consensus feature.
Definition: ConsensusFeature.h:65

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