OpenMS
FeatureMap.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Marc Sturm, Chris Bielow, Clemens Groepl $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/KERNEL/Feature.h>
14 
19 
20 #include <OpenMS/CONCEPT/Types.h>
25 
27 #include <OpenMS/OpenMSConfig.h>
28 
29 #include <exception>
30 
31 namespace OpenMS
32 {
33  class ProteinIdentification;
34  class PeptideIdentification;
35  class DataProcessing;
36 
39  struct OPENMS_DLLAPI AnnotationStatistics
40  {
41  std::vector<Size> states;
42 
44 
46 
48 
49  bool operator==(const AnnotationStatistics& rhs) const;
50 
52  };
53 
54 
56  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const AnnotationStatistics& ann);
57 
72  class OPENMS_DLLAPI FeatureMap :
73  public MetaInfoInterface,
74  public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
75  public DocumentIdentifier,
76  public ExposedVector<Feature>,
77  public UniqueIdInterface,
78  public UniqueIdIndexer<FeatureMap>,
79  public MapUtilities<FeatureMap>
80  {
81  public:
83 
84  //@{
87  typedef iterator Iterator;
92 
97 
100 
102  FeatureMap(const FeatureMap& source);
103 
106 
108  FeatureMap& operator=(const FeatureMap& rhs);
109 
111  //FeatureMap& FeatureMap::operator=(FeatureMap&&);
112 
114  ~FeatureMap() override;
116 
118  bool operator==(const FeatureMap& rhs) const;
119 
121  bool operator!=(const FeatureMap& rhs) const;
122 
128  FeatureMap operator+(const FeatureMap& rhs) const;
129 
142  FeatureMap& operator+=(const FeatureMap& rhs);
143 
151  void sortByIntensity(bool reverse = false);
152 
154  void sortByPosition();
155 
157  void sortByRT();
158 
160  void sortByMZ();
161 
163  void sortByOverallQuality(bool reverse = false);
164 
166 
167  // Docu in base class
168  void updateRanges() override;
169 
171  void swapFeaturesOnly(FeatureMap& from);
172 
173  void swap(FeatureMap& from);
174 
178  const std::vector<ProteinIdentification>& getProteinIdentifications() const;
179 
181  std::vector<ProteinIdentification>& getProteinIdentifications();
182 
184  void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
185 
187  const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
188 
190  std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
191 
193  void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
195 
197  const std::vector<DataProcessing>& getDataProcessing() const;
198 
200  std::vector<DataProcessing>& getDataProcessing();
201 
203  void setDataProcessing(const std::vector<DataProcessing>& processing_method);
204 
206  void setPrimaryMSRunPath(const StringList& s);
207 
210  void setPrimaryMSRunPath(const StringList& s, MSExperiment & e);
211 
213  void getPrimaryMSRunPath(StringList& toFill) const;
214 
220  void clear(bool clear_meta_data = true);
221 
234  template <typename Type>
235  Size applyMemberFunction(Size (Type::* member_function)())
236  {
237  Size assignments = 0;
238  assignments += ((*this).*member_function)();
239  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
240  {
241  assignments += iter->applyMemberFunction(member_function);
242  }
243  return assignments;
244  }
245 
247  template <typename Type>
248  Size applyMemberFunction(Size (Type::* member_function)() const) const
249  {
250  Size assignments = 0;
251  assignments += ((*this).*member_function)();
252  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
253  {
254  assignments += iter->applyMemberFunction(member_function);
255  }
256  return assignments;
257  }
258 
260 
263 
270  std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
271 
274 
278 
279 protected:
281  std::vector<ProteinIdentification> protein_identifications_;
282 
284  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
285 
287  std::vector<DataProcessing> data_processing_;
288 
291  };
292 
293  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const FeatureMap& map);
294 
295 } // namespace OpenMS
#define EXPOSED_VECTOR_INTERFACE(InnerElement)
Macro to expose common dependent types, such as iterator in the derived class.
Definition: ExposedVector.h:19
AnnotationState
state of identification, use getAnnotationState() to query it
Definition: BaseFeature.h:46
Description of the applied preprocessing steps.
Definition: DataProcessing.h:27
Manage source document information.
Definition: DocumentIdentifier.h:30
Makes a vector<VectorElement> available in the derived class and exposed commonly used vector member ...
Definition: ExposedVector.h:55
typename VecMember::iterator iterator
Definition: ExposedVector.h:61
typename VecMember::const_iterator const_iterator
Definition: ExposedVector.h:62
typename VecMember::reverse_iterator reverse_iterator
Definition: ExposedVector.h:63
typename VecMember::const_reverse_iterator const_reverse_iterator
Definition: ExposedVector.h:64
A container for features.
Definition: FeatureMap.h:80
const_reverse_iterator ConstReverseIterator
Definition: FeatureMap.h:90
reverse_iterator ReverseIterator
Definition: FeatureMap.h:89
std::vector< DataProcessing > data_processing_
applied data processing
Definition: FeatureMap.h:287
IdentificationData & getIdentificationData()
Mutable access to the contained identification data.
const_iterator ConstIterator
Definition: FeatureMap.h:88
IdentificationData id_data_
general identification results (peptides/proteins, RNA, compounds)
Definition: FeatureMap.h:290
AnnotationStatistics getAnnotationStatistics() const
std::vector< PeptideIdentification > unassigned_peptide_identifications_
peptide identifications not matched to a specific feature
Definition: FeatureMap.h:284
const IdentificationData & getIdentificationData() const
Immutable access to the contained identification data.
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: FeatureMap.h:281
std::set< IdentificationData::ObservationMatchRef > getUnassignedIDMatches() const
Return observation matches (e.g. PSMs) from the identification data that are not assigned to any feat...
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: FeatureMap.h:248
An LC-MS feature.
Definition: Feature.h:46
Definition: IdentificationData.h:87
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
Utilities for Feature and ConsensusMap.
Definition: MapUtilities.h:24
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:39
Representation of a protein identification run.
Definition: ProteinIdentification.h:50
Definition: RangeManager.h:872
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:540
A base class for containers with elements derived from UniqueIdInterface. This adds functionality to ...
Definition: UniqueIdIndexer.h:41
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:25
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:330
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: FeatureMap.h:40
AnnotationStatistics(const AnnotationStatistics &rhs)
std::vector< Size > states
count each state, indexing by BaseFeature::AnnotationState
Definition: FeatureMap.h:41
AnnotationStatistics & operator+=(BaseFeature::AnnotationState state)
AnnotationStatistics & operator=(const AnnotationStatistics &rhs)
bool operator==(const AnnotationStatistics &rhs) const
Definition: RangeManager.h:398
Definition: RangeManager.h:340
Definition: RangeManager.h:280