OpenMS  3.0.0
Feature.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-2022.
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 
39 
40 #include <OpenMS/CONCEPT/Types.h>
41 #include <OpenMS/OpenMSConfig.h>
42 
43 #include <vector>
44 
45 namespace OpenMS
46 {
47 
70  class OPENMS_DLLAPI Feature :
71  public BaseFeature
72  {
73 public:
77  Feature();
79 
81  explicit Feature(const BaseFeature& base);
82 
84  Feature(const Feature& feature);
85 
87  Feature(Feature&&) noexcept;
88 
90  ~Feature() override;
92 
94 
95  QualityType getOverallQuality() const;
97 
99  void setOverallQuality(QualityType q);
100 
102  QualityType getQuality(Size index) const;
104  void setQuality(Size index, QualityType q);
105 
108 
110 
112 
113  const std::vector<ConvexHull2D>& getConvexHulls() const;
116  std::vector<ConvexHull2D>& getConvexHulls();
118  void setConvexHulls(const std::vector<ConvexHull2D>& hulls);
119 
125  ConvexHull2D& getConvexHull() const;
126 
128  bool encloses(double rt, double mz) const;
130 
132  Feature& operator=(const Feature& rhs);
133 
135  Feature& operator=(Feature&&) & noexcept;
136 
138  bool operator==(const Feature& rhs) const;
139 
141  const std::vector<Feature>& getSubordinates() const;
142 
144  std::vector<Feature>& getSubordinates();
145 
147  void setSubordinates(const std::vector<Feature>& rhs);
148 
161  template <typename Type>
162  Size applyMemberFunction(Size (Type::* member_function)())
163  {
164  Size assignments = 0;
165  assignments += ((*this).*member_function)();
166  for (std::vector<Feature>::iterator iter = subordinates_.begin(); iter != subordinates_.end(); ++iter)
167  {
168  assignments += iter->applyMemberFunction(member_function);
169  }
170  return assignments;
171  }
172 
174  template <typename Type>
175  Size applyMemberFunction(Size (Type::* member_function)() const) const
176  {
177  Size assignments = 0;
178  assignments += ((*this).*member_function)();
179  for (std::vector<Feature>::const_iterator iter = subordinates_.begin(); iter != subordinates_.end(); ++iter)
180  {
181  assignments += iter->applyMemberFunction(member_function);
182  }
183  return assignments;
184  }
185 
191  void updateAllIDReferences(const IdentificationData::RefTranslator& trans);
192 
193 protected:
194 
196  QualityType qualities_[2];
197 
199  std::vector<ConvexHull2D> convex_hulls_;
200 
203 
206 
208  std::vector<Feature> subordinates_;
209 
210  };
211 
212 } // namespace OpenMS
OpenMS::Feature::OverallQualityLess
QualityLess OverallQualityLess
Compare by quality.
Definition: Feature.h:107
OpenMS::Feature::convex_hulls_modified_
bool convex_hulls_modified_
Flag that indicates if the overall convex hull needs to be recomputed (i.e. mass trace convex hulls w...
Definition: Feature.h:202
Types.h
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:58
OpenMS::Feature::subordinates_
std::vector< Feature > subordinates_
subordinate features (e.g. features that represent alternative explanations, usually with lower quali...
Definition: Feature.h:208
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Feature::applyMemberFunction
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: Feature.h:175
OpenMS::Feature::convex_hulls_
std::vector< ConvexHull2D > convex_hulls_
Array of convex hulls (one for each mass trace)
Definition: Feature.h:199
OpenMS::ConvexHull2D
A 2-dimensional hull representation in [counter]clockwise direction - depending on axis labelling.
Definition: ConvexHull2D.h:72
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ConvexHull2D.h
BaseFeature.h
OpenMS::Feature::convex_hull_
ConvexHull2D convex_hull_
Overall convex hull of the feature.
Definition: Feature.h:205
OpenMS::IdentificationData::RefTranslator
structure that maps references of corresponding objects after copying
Definition: IdentificationData.h:192
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::BaseFeature::QualityLess
Compare by quality.
Definition: BaseFeature.h:130
OpenMS::Feature::applyMemberFunction
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:162