OpenMS  3.0.0
BaseFeature.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: Hendrik Weisser $
32 // $Authors: Hendrik Weisser, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 #include <optional>
42 
43 namespace OpenMS
44 {
45  class FeatureHandle;
46 
58  class OPENMS_DLLAPI BaseFeature : public RichPeak2D
59  {
60 public:
64  typedef float QualityType;
66  typedef Int ChargeType;
68  typedef float WidthType;
69 
72  {
77  SIZE_OF_ANNOTATIONSTATE
78  };
79 
80  static const std::string NamesOfAnnotationState[SIZE_OF_ANNOTATIONSTATE];
82 
86  BaseFeature();
87 
89  BaseFeature(const BaseFeature& feature) = default;
90 
94  BaseFeature(BaseFeature&& feature) noexcept
95  : RichPeak2D(std::move(feature))
96  {
97  quality_ = feature.quality_;
98  charge_ = feature.charge_;
99  width_ = feature.width_;
100  // Note: will terminate program if move assignment throws because of noexcept
101  // but we can't recover in that case anyways and we need to mark it noexcept for the move.
102  peptides_ = std::move(feature.peptides_);
103  primary_id_ = std::move(feature.primary_id_);
104  id_matches_ = std::move(feature.id_matches_);
105  }
106 
108  BaseFeature(const BaseFeature& rhs, UInt64 map_index);
109 
111  explicit BaseFeature(const Peak2D& point);
112 
114  explicit BaseFeature(const RichPeak2D& point);
115 
117  explicit BaseFeature(const FeatureHandle& fh);
118 
120  ~BaseFeature() override;
122 
126  QualityType getQuality() const;
128  void setQuality(QualityType q);
130  struct QualityLess
131  {
132  bool operator()(const BaseFeature& left, const BaseFeature& right) const
133  {
134  return left.getQuality() < right.getQuality();
135  }
136 
137  bool operator()(const BaseFeature& left, const QualityType& right) const
138  {
139  return left.getQuality() < right;
140  }
141 
142  bool operator()(const QualityType& left, const BaseFeature& right) const
143  {
144  return left < right.getQuality();
145  }
146 
147  bool operator()(const QualityType& left, const QualityType& right) const
148  {
149  return left < right;
150  }
151 
152  };
154 
156  WidthType getWidth() const;
158  void setWidth(WidthType fwhm);
159 
161  const ChargeType& getCharge() const;
162 
164  void setCharge(const ChargeType& ch);
165 
167  BaseFeature& operator=(const BaseFeature& rhs) = default;
168 
170  BaseFeature& operator=(BaseFeature&& rhs) & = default;
171 
173  bool operator==(const BaseFeature& rhs) const;
174 
176  bool operator!=(const BaseFeature& rhs) const;
177 
181  const std::vector<PeptideIdentification>& getPeptideIdentifications() const;
182 
184  std::vector<PeptideIdentification>& getPeptideIdentifications();
185 
187  void setPeptideIdentifications(const std::vector<PeptideIdentification>& peptides);
188 
190  void sortPeptideIdentifications();
192 
194  AnnotationState getAnnotationState() const;
195 
199  bool hasPrimaryID() const;
200 
206  const IdentificationData::IdentifiedMolecule& getPrimaryID() const;
207 
209  void clearPrimaryID();
210 
212  void setPrimaryID(const IdentificationData::IdentifiedMolecule& id);
213 
215  const std::set<IdentificationData::ObservationMatchRef>& getIDMatches() const;
216 
218  std::set<IdentificationData::ObservationMatchRef>& getIDMatches();
219 
221  void addIDMatch(IdentificationData::ObservationMatchRef ref);
222 
228  void updateIDReferences(const IdentificationData::RefTranslator& trans);
230 
231 protected:
232 
235 
238 
241 
243  std::vector<PeptideIdentification> peptides_;
244 
246  std::optional<IdentificationData::IdentifiedMolecule> primary_id_;
247 
249  std::set<IdentificationData::ObservationMatchRef> id_matches_;
250  };
251 
252 } // namespace OpenMS
OpenMS::BaseFeature::width_
WidthType width_
Width (FWHM) for the feature. The default value is 0.0, a feature finding algorithm can compute this ...
Definition: BaseFeature.h:240
OpenMS::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
OpenMS::BaseFeature::ChargeType
Int ChargeType
Type of charge values.
Definition: BaseFeature.h:66
OpenMS::BaseFeature::FEATURE_ID_MULTIPLE_DIVERGENT
Definition: BaseFeature.h:76
OpenMS::BaseFeature::FEATURE_ID_NONE
Definition: BaseFeature.h:73
OpenMS::BaseFeature::AnnotationState
AnnotationState
state of identification, use getAnnotationState() to query it
Definition: BaseFeature.h:71
OpenMS::BaseFeature::id_matches_
std::set< IdentificationData::ObservationMatchRef > id_matches_
set of observation matches (e.g. PSMs) with IDs for this feature
Definition: BaseFeature.h:249
OpenMS::Peak2D
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
OpenMS::BaseFeature::FEATURE_ID_SINGLE
Definition: BaseFeature.h:74
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:58
KDTree::operator!=
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
OpenMS::IdentificationDataInternal::IdentifiedMolecule
Variant type holding Peptide/Compound/Oligo references and convenience functions.
Definition: IdentifiedMolecule.h:54
OpenMS::RichPeak2D
A 2-dimensional raw data point or peak with meta information.
Definition: RichPeak2D.h:52
OpenMS::BaseFeature::WidthType
float WidthType
Type of feature width/FWHM (RT)
Definition: BaseFeature.h:68
OpenMS::BaseFeature::FEATURE_ID_MULTIPLE_SAME
Definition: BaseFeature.h:75
OpenMS::BaseFeature::quality_
QualityType quality_
Overall quality measure of the feature.
Definition: BaseFeature.h:234
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::BaseFeature::QualityLess::operator()
bool operator()(const QualityType &left, const QualityType &right) const
Definition: BaseFeature.h:147
OpenMS::BaseFeature::QualityLess::operator()
bool operator()(const QualityType &left, const BaseFeature &right) const
Definition: BaseFeature.h:142
OpenMS::IdentificationDataInternal::IteratorWrapper
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:45
RichPeak2D.h
OpenMS::BaseFeature::primary_id_
std::optional< IdentificationData::IdentifiedMolecule > primary_id_
primary ID (peptide, RNA, compound) assigned to this feature
Definition: BaseFeature.h:246
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::FeatureHandle
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
OpenMS::BaseFeature::peptides_
std::vector< PeptideIdentification > peptides_
PeptideIdentifications belonging to the feature.
Definition: BaseFeature.h:243
float
IdentificationData.h
OpenMS::BaseFeature::QualityLess::operator()
bool operator()(const BaseFeature &left, const BaseFeature &right) const
Definition: BaseFeature.h:132
OpenMS::BaseFeature::charge_
ChargeType charge_
Charge of the peptide represented by this feature. The default value is 0, which represents an unknow...
Definition: BaseFeature.h:237
OpenMS::BaseFeature::QualityLess
Compare by quality.
Definition: BaseFeature.h:130
OpenMS::BaseFeature::BaseFeature
BaseFeature(BaseFeature &&feature) noexcept
Definition: BaseFeature.h:94
OpenMS::BaseFeature::QualityType
float QualityType
Definition: BaseFeature.h:64
PeptideIdentification.h
OpenMS::BaseFeature::QualityLess::operator()
bool operator()(const BaseFeature &left, const QualityType &right) const
Definition: BaseFeature.h:137
OpenMS::BaseFeature::getQuality
QualityType getQuality() const