OpenMS
Feature.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
14 #include <OpenMS/CONCEPT/Types.h>
15 #include <OpenMS/OpenMSConfig.h>
16 
17 #include <vector>
18 
19 namespace OpenMS
20 {
21 
44  class OPENMS_DLLAPI Feature :
45  public BaseFeature
46  {
47 public:
53 
55  explicit Feature(const BaseFeature& base);
56 
58  Feature(const Feature& feature);
59 
61  Feature(Feature&&) noexcept;
62 
64  ~Feature() override;
66 
68 
69  QualityType getOverallQuality() const;
71 
73  void setOverallQuality(QualityType q);
74 
76  QualityType getQuality(Size index) const;
78  void setQuality(Size index, QualityType q);
79 
82 
84 
86 
87  const std::vector<ConvexHull2D>& getConvexHulls() const;
90  std::vector<ConvexHull2D>& getConvexHulls();
92  void setConvexHulls(const std::vector<ConvexHull2D>& hulls);
93 
99  ConvexHull2D& getConvexHull() const;
100 
102  bool encloses(double rt, double mz) const;
104 
106  Feature& operator=(const Feature& rhs);
107 
109  Feature& operator=(Feature&&) & noexcept;
110 
112  bool operator==(const Feature& rhs) const;
113 
115  const std::vector<Feature>& getSubordinates() const;
116 
118  std::vector<Feature>& getSubordinates();
119 
121  void setSubordinates(const std::vector<Feature>& rhs);
122 
135  template <typename Type>
136  Size applyMemberFunction(Size (Type::* member_function)())
137  {
138  Size assignments = 0;
139  assignments += ((*this).*member_function)();
140  for (std::vector<Feature>::iterator iter = subordinates_.begin(); iter != subordinates_.end(); ++iter)
141  {
142  assignments += iter->applyMemberFunction(member_function);
143  }
144  return assignments;
145  }
146 
148  template <typename Type>
149  Size applyMemberFunction(Size (Type::* member_function)() const) const
150  {
151  Size assignments = 0;
152  assignments += ((*this).*member_function)();
153  for (std::vector<Feature>::const_iterator iter = subordinates_.begin(); iter != subordinates_.end(); ++iter)
154  {
155  assignments += iter->applyMemberFunction(member_function);
156  }
157  return assignments;
158  }
159 
166 
167 protected:
168 
170  QualityType qualities_[2];
171 
173  std::vector<ConvexHull2D> convex_hulls_;
174 
176  mutable bool convex_hulls_modified_{};
177 
180 
182  std::vector<Feature> subordinates_;
183 
184  };
185 
186 } // namespace OpenMS
A basic LC-MS feature.
Definition: BaseFeature.h:33
float QualityType
Definition: BaseFeature.h:38
Definition: ConvexHull2D.h:47
An LC-MS feature.
Definition: Feature.h:46
Feature(const BaseFeature &base)
explicit C'tor from BaseFeature
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the feature (including subordinates). The returned values are ac...
Definition: Feature.h:136
Feature(const Feature &feature)
Copy constructor.
void updateAllIDReferences(const IdentificationData::RefTranslator &trans)
Update ID references (primary ID, input matches) for this feature and any subfeatures.
ConvexHull2D convex_hull_
Overall convex hull of the feature.
Definition: Feature.h:179
Feature()
Default constructor.
std::vector< ConvexHull2D > convex_hulls_
Array of convex hulls (one for each mass trace)
Definition: Feature.h:173
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: Feature.h:149
std::vector< Feature > subordinates_
subordinate features (e.g. features that represent alternative explanations, usually with lower quali...
Definition: Feature.h:182
Feature(Feature &&) noexcept
Move constructor.
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Compare by quality.
Definition: BaseFeature.h:105
structure that maps references of corresponding objects after copying
Definition: IdentificationData.h:184