OpenMS
BaseFeature.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: Hendrik Weisser $
6 // $Authors: Hendrik Weisser, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
14 
15 #include <optional>
16 
17 namespace OpenMS
18 {
19  class FeatureHandle;
20 
32  class OPENMS_DLLAPI BaseFeature : public RichPeak2D
33  {
34 public:
38  typedef float QualityType;
40  typedef Int ChargeType;
42  typedef float WidthType;
43 
46  {
51  SIZE_OF_ANNOTATIONSTATE
52  };
53 
54  static const std::string NamesOfAnnotationState[SIZE_OF_ANNOTATIONSTATE];
56 
61 
63  BaseFeature(const BaseFeature& feature) = default;
64 
68  BaseFeature(BaseFeature&& feature) noexcept
69  : RichPeak2D(std::move(feature))
70  {
71  quality_ = feature.quality_;
72  charge_ = feature.charge_;
73  width_ = feature.width_;
74  // Note: will terminate program if move assignment throws because of noexcept
75  // but we can't recover in that case anyways and we need to mark it noexcept for the move.
76  peptides_ = std::move(feature.peptides_);
77  primary_id_ = std::move(feature.primary_id_);
78  id_matches_ = std::move(feature.id_matches_);
79  }
80 
82  BaseFeature(const BaseFeature& rhs, UInt64 map_index);
83 
85  explicit BaseFeature(const Peak2D& point);
86 
88  explicit BaseFeature(const RichPeak2D& point);
89 
91  explicit BaseFeature(const FeatureHandle& fh);
92 
94  ~BaseFeature() override;
96 
104  struct QualityLess
105  {
106  bool operator()(const BaseFeature& left, const BaseFeature& right) const
107  {
108  return left.getQuality() < right.getQuality();
109  }
110 
111  bool operator()(const BaseFeature& left, const QualityType& right) const
112  {
113  return left.getQuality() < right;
114  }
115 
116  bool operator()(const QualityType& left, const BaseFeature& right) const
117  {
118  return left < right.getQuality();
119  }
120 
121  bool operator()(const QualityType& left, const QualityType& right) const
122  {
123  return left < right;
124  }
125 
126  };
128 
132  void setWidth(WidthType fwhm);
133 
135  const ChargeType& getCharge() const;
136 
138  void setCharge(const ChargeType& ch);
139 
141  BaseFeature& operator=(const BaseFeature& rhs) = default;
142 
144  BaseFeature& operator=(BaseFeature&& rhs) & = default;
145 
147  bool operator==(const BaseFeature& rhs) const;
148 
150  bool operator!=(const BaseFeature& rhs) const;
151 
155  const std::vector<PeptideIdentification>& getPeptideIdentifications() const;
156 
158  std::vector<PeptideIdentification>& getPeptideIdentifications();
159 
161  void setPeptideIdentifications(const std::vector<PeptideIdentification>& peptides);
162 
166 
169 
173  bool hasPrimaryID() const;
174 
181 
184 
187 
189  const std::set<IdentificationData::ObservationMatchRef>& getIDMatches() const;
190 
192  std::set<IdentificationData::ObservationMatchRef>& getIDMatches();
193 
196 
204 
205 protected:
206 
209 
212 
215 
217  std::vector<PeptideIdentification> peptides_;
218 
220  std::optional<IdentificationData::IdentifiedMolecule> primary_id_;
221 
223  std::set<IdentificationData::ObservationMatchRef> id_matches_;
224  };
225 
226 } // namespace OpenMS
A basic LC-MS feature.
Definition: BaseFeature.h:33
void setPeptideIdentifications(const std::vector< PeptideIdentification > &peptides)
sets the PeptideIdentification vector
std::optional< IdentificationData::IdentifiedMolecule > primary_id_
primary ID (peptide, RNA, compound) assigned to this feature
Definition: BaseFeature.h:220
void setQuality(QualityType q)
Set the overall quality.
BaseFeature & operator=(BaseFeature &&rhs) &=default
Move Assignment operator.
void sortPeptideIdentifications()
sorts PeptideIdentifications, assuming they have the same scoreType.
void clearPrimaryID()
clear any primary ID that was assigned
WidthType width_
Width (FWHM) for the feature. The default value is 0.0, a feature finding algorithm can compute this ...
Definition: BaseFeature.h:214
bool operator==(const BaseFeature &rhs) const
Equality operator.
QualityType getQuality() const
const ChargeType & getCharge() const
Non-mutable access to charge state.
AnnotationState getAnnotationState() const
state of peptide identifications attached to this feature. If one ID has multiple hits,...
BaseFeature(const BaseFeature &rhs, UInt64 map_index)
Copy constructor with a new map_index.
ChargeType charge_
Charge of the peptide represented by this feature. The default value is 0, which represents an unknow...
Definition: BaseFeature.h:211
bool hasPrimaryID() const
float QualityType
Definition: BaseFeature.h:38
float WidthType
Type of feature width/FWHM (RT)
Definition: BaseFeature.h:42
std::set< IdentificationData::ObservationMatchRef > & getIDMatches()
mutable access to the set of matches (e.g. PSMs) with IDs for this feature
BaseFeature(const BaseFeature &feature)=default
Copy constructor.
std::vector< PeptideIdentification > & getPeptideIdentifications()
returns a mutable reference to the PeptideIdentification vector
const std::set< IdentificationData::ObservationMatchRef > & getIDMatches() const
immutable access to the set of matches (e.g. PSMs) with IDs for this feature
WidthType getWidth() const
Non-mutable access to the features width (full width at half max, FWHM)
Int ChargeType
Type of charge values.
Definition: BaseFeature.h:40
void setWidth(WidthType fwhm)
Set the width of the feature (FWHM)
const IdentificationData::IdentifiedMolecule & getPrimaryID() const
Return the primary ID (peptide, RNA, compound) assigned to this feature.
const std::vector< PeptideIdentification > & getPeptideIdentifications() const
void addIDMatch(IdentificationData::ObservationMatchRef ref)
add an ID match (e.g. PSM) for this feature
bool operator!=(const BaseFeature &rhs) const
Inequality operator.
QualityType quality_
Overall quality measure of the feature.
Definition: BaseFeature.h:208
BaseFeature(const RichPeak2D &point)
Constructor from raw data point with meta information.
void setCharge(const ChargeType &ch)
Set charge state.
std::set< IdentificationData::ObservationMatchRef > id_matches_
set of observation matches (e.g. PSMs) with IDs for this feature
Definition: BaseFeature.h:223
BaseFeature(BaseFeature &&feature) noexcept
Definition: BaseFeature.h:68
~BaseFeature() override
Destructor.
AnnotationState
state of identification, use getAnnotationState() to query it
Definition: BaseFeature.h:46
@ FEATURE_ID_MULTIPLE_SAME
Definition: BaseFeature.h:49
@ FEATURE_ID_SINGLE
Definition: BaseFeature.h:48
@ FEATURE_ID_NONE
Definition: BaseFeature.h:47
@ FEATURE_ID_MULTIPLE_DIVERGENT
Definition: BaseFeature.h:50
std::vector< PeptideIdentification > peptides_
PeptideIdentifications belonging to the feature.
Definition: BaseFeature.h:217
BaseFeature & operator=(const BaseFeature &rhs)=default
Assignment operator.
void updateIDReferences(const IdentificationData::RefTranslator &trans)
Update ID references (primary ID, matches) for this feature.
BaseFeature(const Peak2D &point)
Constructor from raw data point.
BaseFeature(const FeatureHandle &fh)
Constructor from a featurehandle.
void setPrimaryID(const IdentificationData::IdentifiedMolecule &id)
set the primary ID (peptide, RNA, compound) for this feature
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:34
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:29
A 2-dimensional raw data point or peak with meta information.
Definition: RichPeak2D.h:30
int Int
Signed integer type.
Definition: Types.h:72
uint64_t UInt64
Unsigned integer type (64bit)
Definition: Types.h:47
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Compare by quality.
Definition: BaseFeature.h:105
bool operator()(const BaseFeature &left, const BaseFeature &right) const
Definition: BaseFeature.h:106
bool operator()(const QualityType &left, const QualityType &right) const
Definition: BaseFeature.h:121
bool operator()(const BaseFeature &left, const QualityType &right) const
Definition: BaseFeature.h:111
bool operator()(const QualityType &left, const BaseFeature &right) const
Definition: BaseFeature.h:116
Variant type holding Peptide/Compound/Oligo references and convenience functions.
Definition: IdentifiedMolecule.h:29
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:20
structure that maps references of corresponding objects after copying
Definition: IdentificationData.h:184