OpenMS
Loading...
Searching...
No Matches
ConsensusMap.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
15
21
26#include <OpenMS/OpenMSConfig.h>
27
28#include <map>
29#include <vector>
30#include <iosfwd>
31
32namespace OpenMS
33{
34 class PeptideIdentification;
35 class PeptideHit;
36 class ProteinIdentification;
37 class DataProcessing;
38 class MSExperiment;
39 namespace Logger
40 {
41 class LogStream;
42 }
43
59 class OPENMS_DLLAPI ConsensusMap :
60 public MetaInfoInterface,
61 public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
62 public DocumentIdentifier,
63 public ExposedVector<ConsensusFeature>,
64 public UniqueIdInterface,
65 public UniqueIdIndexer<ConsensusMap>,
66 public MapUtilities<ConsensusMap>
67 {
68public:
70
71 enum class SplitMeta
72 {
73 DISCARD,
74 COPY_ALL,
75 COPY_FIRST
76 };
77
79 struct OPENMS_DLLAPI ColumnHeader :
81 {
83 ColumnHeader() = default;
84
86 ColumnHeader(const ColumnHeader&) = default;
87
90
93
96
99 Size size = 0;
100
102 UInt64 unique_id = UniqueIdInterface::INVALID;
103
104 unsigned getLabelAsUInt(const String& experiment_type) const;
105 };
106
108
110 typedef std::map<UInt64, ColumnHeader> ColumnHeaders;
111
119
122
127
129 ~ConsensusMap() override;
130
133
137 ConsensusMap& operator=(ConsensusMap&& source) = default;
138
149
158
159
165 void clear(bool clear_meta_data = true);
166
169
172
174 void setColumnHeaders(const ColumnHeaders& column_description);
175
177 const String& getExperimentType() const;
178
180 void setExperimentType(const String& experiment_type);
181
190 void sortByIntensity(bool reverse = false);
191
193 void sortByRT();
194
196 void sortByMZ();
197
200
202 void sortByQuality(bool reverse = false);
203
206
209
213
214 // Docu in base class
215 void updateRanges() override;
216
218 void swap(ConsensusMap& from);
219
221 const std::vector<ProteinIdentification>& getProteinIdentifications() const;
222
224 std::vector<ProteinIdentification>& getProteinIdentifications();
225
227 void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
228
230 void setProteinIdentifications(std::vector<ProteinIdentification>&& protein_identifications);
231
234
237
240
243
245 void setUnassignedPeptideIdentifications(const PeptideIdentificationList& unassigned_peptide_identifications);
246
248 const std::vector<DataProcessing>& getDataProcessing() const;
249
251 std::vector<DataProcessing>& getDataProcessing();
252
254 void setDataProcessing(const std::vector<DataProcessing>& processing_method);
255
258
264
266 void getPrimaryMSRunPath(StringList& toFill) const;
267
269 bool operator==(const ConsensusMap& rhs) const;
270
272 bool operator!=(const ConsensusMap& rhs) const;
273
287 template <typename Type>
288 Size applyMemberFunction(Size (Type::* member_function)())
289 {
290 Size assignments = 0;
291 assignments += ((*this).*member_function)();
292 for (Iterator iter = this->begin(); iter != this->end(); ++iter)
293 {
294 assignments += ((*iter).*member_function)();
295 }
296 return assignments;
297 }
298
300 template <typename Type>
301 Size applyMemberFunction(Size (Type::* member_function)() const) const
302 {
303 Size assignments = 0;
304 assignments += ((*this).*member_function)();
305 for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
306 {
307 assignments += ((*iter).*member_function)();
308 }
309 return assignments;
310 }
311
324 bool isMapConsistent(Logger::LogStream* stream = nullptr) const;
325
339 std::vector<FeatureMap> split(SplitMeta mode = SplitMeta::DISCARD) const;
340
343
350 std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
351
354
358
359 protected:
362
364 String experiment_type_ = "label-free";
365
367 std::vector<ProteinIdentification> protein_identifications_;
368
371
373 std::vector<DataProcessing> data_processing_;
374
377 };
378
380 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusMap& cons_map);
381
382} // namespace OpenMS
#define EXPOSED_VECTOR_INTERFACE(InnerElement)
Macro to expose common dependent types, such as iterator in the derived class.
Definition ExposedVector.h:26
A consensus feature spanning multiple LC-MS/MS experiments.
Definition ConsensusFeature.h:45
A container for consensus elements.
Definition ConsensusMap.h:67
SplitMeta
Definition ConsensusMap.h:72
ProteinIdentification * findProteinIdentification(const String &identifier)
finds a protein identification by its identifier (returns nullptr if not found)
ConsensusMap(ConsensusMap &&source)
Move constructor.
const_reverse_iterator ConstReverseIterator
Definition ConsensusMap.h:117
void sortByRT()
Sorts the peaks to RT position.
std::vector< FeatureMap > split(SplitMeta mode=SplitMeta::DISCARD) const
splits ConsensusMap into its original FeatureMaps
void setUnassignedPeptideIdentifications(const PeptideIdentificationList &unassigned_peptide_identifications)
sets the unassigned peptide identifications
std::vector< DataProcessing > & getDataProcessing()
returns a mutable reference to the description of the applied data processing
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition ConsensusMap.h:113
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features....
Definition ConsensusMap.h:288
const PeptideIdentificationList & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
reverse_iterator ReverseIterator
Definition ConsensusMap.h:116
void setPrimaryMSRunPath(const StringList &s)
set the file paths to the primary MS run (stored in ColumnHeaders)
void sortByMaps()
Sorts with respect to the sets of maps covered by the consensus features (lexicographically).
ConsensusMap & operator=(const ConsensusMap &source)
Assignment operator.
bool isMapConsistent(Logger::LogStream *stream=nullptr) const
checks if the given maps are unique and all FeatureHandles actually refer to a registered map
std::vector< DataProcessing > data_processing_
applied data processing
Definition ConsensusMap.h:373
PeptideIdentificationList & getUnassignedPeptideIdentifications()
mutable access to the unassigned peptide identifications
iterator Iterator
Definition ConsensusMap.h:114
void sortPeptideIdentificationsByMapIndex()
Sorts PeptideIdentifications of consensus features with respect to their map index.
void sortByMZ()
Sorts the peaks to m/z position.
const_iterator ConstIterator
Definition ConsensusMap.h:115
bool operator!=(const ConsensusMap &rhs) const
Equality operator.
void setProteinIdentifications(const std::vector< ProteinIdentification > &protein_identifications)
sets the protein identifications
ConsensusMap(size_type n)
Creates a ConsensusMap with n elements.
IdentificationData id_data_
general identification results (peptides/proteins, RNA, compounds)
Definition ConsensusMap.h:376
bool operator==(const ConsensusMap &rhs) const
Equality operator.
ConsensusMap & appendColumns(const ConsensusMap &rhs)
Add consensus map entries as new columns.
void sortBySize()
Sorts with respect to the size (number of elements)
ConsensusFeature FeatureType
Definition ConsensusMap.h:109
void clear(bool clear_meta_data=true)
Clears all data and meta data.
ConsensusMap()
Default constructor.
ConsensusMap & operator=(ConsensusMap &&source)=default
MoveAssignment operator.
void setProteinIdentifications(std::vector< ProteinIdentification > &&protein_identifications)
sets the protein identifications by moving
ConsensusMap & appendRows(const ConsensusMap &rhs)
Add consensus map entries as new rows.
void sortByPosition()
Lexicographically sorts the peaks by their position (First RT then m/z).
void setDataProcessing(const std::vector< DataProcessing > &processing_method)
sets the description of the applied data processing
void sortByIntensity(bool reverse=false)
Sorts the peaks according to ascending intensity.
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity > RangeManagerContainerType
Definition ConsensusMap.h:112
const IdentificationData & getIdentificationData() const
Immutable access to the contained identification data.
void getPrimaryMSRunPath(StringList &toFill) const
returns the MS run path (stored in ColumnHeaders)
IdentificationData & getIdentificationData()
Mutable access to the contained identification data.
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
std::vector< ProteinIdentification > & getProteinIdentifications()
mutable access to the protein identifications
std::map< UInt64, ColumnHeader > ColumnHeaders
Definition ConsensusMap.h:110
~ConsensusMap() override
Destructor.
const ColumnHeaders & getColumnHeaders() const
Non-mutable access to the file descriptions.
void setColumnHeaders(const ColumnHeaders &column_description)
Mutable access to the file descriptions.
void sortByQuality(bool reverse=false)
Sorts the peaks according to ascending quality.
ColumnHeaders column_description_
Map from index to file description.
Definition ConsensusMap.h:361
ColumnHeaders & getColumnHeaders()
Mutable access to the file descriptions.
const ProteinIdentification * findProteinIdentification(const String &identifier) const
finds a protein identification by its identifier (returns nullptr if not found)
void swap(ConsensusMap &from)
Swaps the content of this map with the content of from.
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition ConsensusMap.h:367
std::set< IdentificationData::ObservationMatchRef > getUnassignedIDMatches() const
Return observation matches (e.g. PSMs) from the identification data that are not assigned to any feat...
ConsensusMap(const ConsensusMap &source)
Copy constructor.
const String & getExperimentType() const
Non-mutable access to the experiment type.
void updateRanges() override
void setPrimaryMSRunPath(const StringList &s, MSExperiment &e)
void setExperimentType(const String &experiment_type)
Mutable access to the experiment type.
PeptideIdentificationList unassigned_peptide_identifications_
unassigned peptide identifications (without feature)
Definition ConsensusMap.h:370
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition ConsensusMap.h:301
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
Manage source document information.
Definition DocumentIdentifier.h:30
Definition ExposedVector.h:62
typename VecMember::iterator iterator
Definition ExposedVector.h:68
typename VecMember::const_iterator const_iterator
Definition ExposedVector.h:69
typename VecMember::size_type size_type
Definition ExposedVector.h:72
typename VecMember::reverse_iterator reverse_iterator
Definition ExposedVector.h:70
typename VecMember::const_reverse_iterator const_reverse_iterator
Definition ExposedVector.h:71
Definition IdentificationData.h:87
Log Stream Class.
Definition LogStream.h:308
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
Utilities for Feature and ConsensusMap.
Definition MapUtilities.h:25
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:36
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Representation of a protein identification run.
Definition ProteinIdentification.h:55
Definition RangeManager.h:889
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition RangeManager.h:568
A more convenient string class.
Definition String.h:32
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
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::vector< String > StringList
Vector of String.
Definition ListUtils.h:44
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Description of the columns in a consensus map.
Definition ConsensusMap.h:81
ColumnHeader()=default
Default constructor.
ColumnHeader(const ColumnHeader &)=default
Copy constructor.
unsigned getLabelAsUInt(const String &experiment_type) const
String filename
File name of the mzML file.
Definition ConsensusMap.h:92
ColumnHeader & operator=(const ColumnHeader &)=default
Copy assignment.
String label
Label e.g. 'heavy' and 'light' for ICAT, or 'sample1' and 'sample2' for label-free quantitation.
Definition ConsensusMap.h:95