| OpenMS 2.5.0

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-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: $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/DATASTRUCTURES/DRange.h>
38 #include <OpenMS/KERNEL/BaseFeature.h>
39 #include <OpenMS/KERNEL/FeatureHandle.h>
40
41 #include <OpenMS/CONCEPT/Types.h>
42 #include <OpenMS/DATASTRUCTURES/String.h>
43 #include <OpenMS/OpenMSConfig.h>
44
45 #include <set>
46
47 namespace OpenMS
48 {
49 class FeatureMap;
50 class Peak2D;
51
69 class OPENMS_DLLAPI ConsensusFeature :
70 public BaseFeature
71 {
72 public:
74
75 typedef std::set<FeatureHandle, FeatureHandle::IndexLess> HandleSetType;
76 typedef HandleSetType::const_iterator const_iterator;
77 typedef HandleSetType::iterator iterator;
78 typedef HandleSetType::const_reverse_iterator const_reverse_iterator;
79 typedef HandleSetType::reverse_iterator reverse_iterator;
81
83 struct SizeLess :
84 std::binary_function<ConsensusFeature, ConsensusFeature, bool>
85 {
86 inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
87 {
88 return left.size() < right.size();
89 }
90
91 inline bool operator()(ConsensusFeature const& left, UInt64 const& right) const
92 {
93 return left.size() < right;
94 }
95
96 inline bool operator()(UInt64 const& left, ConsensusFeature const& right) const
97 {
98 return left < right.size();
99 }
100
101 inline bool operator()(const UInt64& left, const UInt64& right) const
102 {
103 return left < right;
104 }
105
106 };
107
109 struct MapsLess :
110 std::binary_function<ConsensusFeature, ConsensusFeature, bool>
111 {
112 inline bool operator()(ConsensusFeature const& left, ConsensusFeature const& right) const
113 {
114 return std::lexicographical_compare(left.begin(), left.end(), right.begin(), right.end(), FeatureHandle::IndexLess());
115 }
116
117 };
118
120 struct Ratio
121 {
122 Ratio()
123 {
124 }
125
126 Ratio(const Ratio& rhs)
127 {
128 ratio_value_ = rhs.ratio_value_;
129 denominator_ref_ = rhs.denominator_ref_;
130 numerator_ref_ = rhs.numerator_ref_;
131 description_ = rhs.description_;
132 }
133
134 virtual ~Ratio()
135 {
136 }
137
138 Ratio& operator=(const Ratio& rhs)
139 {
140 if (&rhs != this)
141 {
142 ratio_value_ = rhs.ratio_value_;
143 denominator_ref_ = rhs.denominator_ref_;
144 numerator_ref_ = rhs.numerator_ref_;
145 description_ = rhs.description_;
146 }
147 return *this;
148 }
149
150 double ratio_value_;
151 String denominator_ref_;
152 String numerator_ref_;
153 std::vector<String> description_;
154 //TODO ratio cv info
155 };
156
158
159 ConsensusFeature();
161
163 ConsensusFeature(const ConsensusFeature& rhs) = default;
164
166 ConsensusFeature(ConsensusFeature&& rhs) = default;
167
169 explicit ConsensusFeature(const BaseFeature& feature);
170
177 ConsensusFeature(UInt64 map_index, const Peak2D& element, UInt64 element_index);
178
185 ConsensusFeature(UInt64 map_index, const BaseFeature& element);
186
188 ConsensusFeature& operator=(const ConsensusFeature& rhs) = default;
189
191 ConsensusFeature& operator=(ConsensusFeature&& rhs) = default;
192
194 ~ConsensusFeature() override;
196
197
199
200
204 void insert(const ConsensusFeature& cf);
205
212 void insert(const FeatureHandle& handle);
213
215 void insert(const HandleSetType& handle_set);
216
223 void insert(UInt64 map_index, const Peak2D& element, UInt64 element_index);
224
231 void insert(UInt64 map_index, const BaseFeature& element);
232
234 const HandleSetType& getFeatures() const;
235
237 std::vector<FeatureHandle> getFeatureList() const;
238
240 void setFeatures(HandleSetType h);
242
244
245 DRange<2> getPositionRange() const;
248 DRange<1> getIntensityRange() const;
249
251
261 void computeConsensus();
262
272 void computeMonoisotopicConsensus();
273
287 void computeDechargeConsensus(const FeatureMap& fm, bool intensity_weighted_averaging = false);
288
296 void addRatio(const Ratio& r);
297
305 void setRatios(std::vector<Ratio>& rs);
306
310 std::vector<Ratio> getRatios() const;
311
315 std::vector<Ratio>& getRatios();
316
318
319 Size size() const;
320
321 const_iterator begin() const;
322
323 iterator begin();
324
325 const_iterator end() const;
326
327 iterator end();
328
329 const_reverse_iterator rbegin() const;
330
331 reverse_iterator rbegin();
332
333 const_reverse_iterator rend() const;
334
335 reverse_iterator rend();
336
337 void clear();
338
339 bool empty() const;
341
342 private:
343
344 HandleSetType handles_;
345 std::vector<Ratio> ratios_;
346
347
348 };
349
351 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusFeature& cons);
352
353 } // namespace OpenMS
354
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::ConsensusFeature::iterator
HandleSetType::iterator iterator
Definition: ConsensusFeature.h:77
OpenMS::Peak2D
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
OpenMS::ConsensusFeature::ratios_
std::vector< Ratio > ratios_
Definition: ConsensusFeature.h:345
OpenMS::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
DRange.h
OpenMS::ConsensusFeature::handles_
HandleSetType handles_
Definition: ConsensusFeature.h:344
OpenMS::ConsensusFeature::HandleSetType
std::set< FeatureHandle, FeatureHandle::IndexLess > HandleSetType
Type definitions.
Definition: ConsensusFeature.h:75
OpenMS::ConsensusFeature::const_iterator
HandleSetType::const_iterator const_iterator
Definition: ConsensusFeature.h:76
OpenMS::ConsensusFeature::SizeLess::operator()
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:86
OpenMS::ConsensusFeature::begin
const_iterator begin() const
OpenMS::ConsensusFeature::SizeLess::operator()
bool operator()(ConsensusFeature const &left, UInt64 const &right) const
Definition: ConsensusFeature.h:91
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:95
Types.h
OpenMS::ConsensusFeature::Ratio::Ratio
Ratio(const Ratio &rhs)
Definition: ConsensusFeature.h:126
OpenMS::ConsensusFeature
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:69
FeatureHandle.h
OpenMS::ConsensusFeature::size
Size size() const
OpenMS::ConsensusFeature::SizeLess::operator()
bool operator()(UInt64 const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:96
OpenMS::ConsensusFeature::Ratio::Ratio
Ratio()
Definition: ConsensusFeature.h:122
OpenMS::ConsensusFeature::Ratio::denominator_ref_
String denominator_ref_
Definition: ConsensusFeature.h:151
String.h
OpenMS::ConsensusFeature::Ratio::~Ratio
virtual ~Ratio()
Definition: ConsensusFeature.h:134
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::DRange< 2 >
OpenMS::ConsensusFeature::const_reverse_iterator
HandleSetType::const_reverse_iterator const_reverse_iterator
Definition: ConsensusFeature.h:78
OpenMS::ConsensusFeature::MapsLess::operator()
bool operator()(ConsensusFeature const &left, ConsensusFeature const &right) const
Definition: ConsensusFeature.h:112
OpenMS::ConsensusFeature::MapsLess
Compare by the sets of consensus elements (lexicographically)
Definition: ConsensusFeature.h:109
OpenMS::ConsensusFeature::Ratio::ratio_value_
double ratio_value_
Definition: ConsensusFeature.h:150
OpenMS::ConsensusFeature::reverse_iterator
HandleSetType::reverse_iterator reverse_iterator
Definition: ConsensusFeature.h:79
OpenMS::FeatureHandle::IndexLess
Comparator by map and unique id.
Definition: FeatureHandle.h:140
OpenMS::ConsensusFeature::Ratio::operator=
Ratio & operator=(const Ratio &rhs)
Definition: ConsensusFeature.h:138
OpenMS::ConsensusFeature::SizeLess
Compare by size(), the number of consensus elements.
Definition: ConsensusFeature.h:83
OpenMS::ConsensusFeature::Ratio::numerator_ref_
String numerator_ref_
Definition: ConsensusFeature.h:152
BaseFeature.h
OpenMS::FeatureHandle
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
OpenMS::ConsensusFeature::Ratio
slim struct to feed the need for systematically storing of ratios (
Definition: ConsensusFeature.h:120
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::ConsensusFeature::end
const_iterator end() const
OpenMS::Constants::h
const double h
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:56
OpenMS::ConsensusFeature::SizeLess::operator()
bool operator()(const UInt64 &left, const UInt64 &right) const
Definition: ConsensusFeature.h:101
OpenMS::ConsensusFeature::Ratio::description_
std::vector< String > description_
Definition: ConsensusFeature.h:153