OpenMS
ConsensusMap.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: Timo Sachsenberg $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
16 
20 
21 #include <OpenMS/CONCEPT/Types.h>
26 #include <OpenMS/OpenMSConfig.h>
27 
28 #include <map>
29 #include <vector>
30 #include <iosfwd>
31 
32 namespace OpenMS
33 {
34  class PeptideIdentification;
35  class PeptideHit;
36  class ProteinIdentification;
37  class DataProcessing;
38  namespace Logger
39  {
40  class LogStream;
41  }
42 
58  class OPENMS_DLLAPI ConsensusMap :
59  public MetaInfoInterface,
60  public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
61  public DocumentIdentifier,
62  public ExposedVector<ConsensusFeature>,
63  public UniqueIdInterface,
64  public UniqueIdIndexer<ConsensusMap>,
65  public MapUtilities<ConsensusMap>
66  {
67 public:
69 
70  enum class SplitMeta
71  {
72  DISCARD,
73  COPY_ALL,
74  COPY_FIRST
75  };
76 
78  struct ColumnHeader :
79  public MetaInfoInterface
80  {
82  ColumnHeader() = default;
83 
85  ColumnHeader(const ColumnHeader&) = default;
86 
88  ColumnHeader& operator=(const ColumnHeader&) = default;
89 
92 
95 
98  Size size = 0;
99 
102 
103  unsigned getLabelAsUInt(const String& experiment_type) const;
104  };
105 
107 
109  typedef std::map<UInt64, ColumnHeader> ColumnHeaders;
110 
118 
121 
123  ConsensusMap(const ConsensusMap& source);
126 
128  ~ConsensusMap() override;
129 
131  explicit ConsensusMap(size_type n);
132 
136  ConsensusMap& operator=(ConsensusMap&& source) = default;
137 
148 
157 
158 
164  void clear(bool clear_meta_data = true);
165 
168 
171 
173  void setColumnHeaders(const ColumnHeaders& column_description);
174 
176  const String& getExperimentType() const;
177 
179  void setExperimentType(const String& experiment_type);
180 
189  void sortByIntensity(bool reverse = false);
190 
192  void sortByRT();
193 
195  void sortByMZ();
196 
199 
201  void sortByQuality(bool reverse = false);
202 
204  void sortBySize();
205 
207  void sortByMaps();
208 
212 
213  // Docu in base class
214  void updateRanges() override;
215 
217  void swap(ConsensusMap& from);
218 
220  const std::vector<ProteinIdentification>& getProteinIdentifications() const;
221 
223  std::vector<ProteinIdentification>& getProteinIdentifications();
224 
226  void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
227 
229  void setProteinIdentifications(std::vector<ProteinIdentification>&& protein_identifications);
230 
232  const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
233 
235  std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
236 
238  void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
239 
241  const std::vector<DataProcessing>& getDataProcessing() const;
242 
244  std::vector<DataProcessing>& getDataProcessing();
245 
247  void setDataProcessing(const std::vector<DataProcessing>& processing_method);
248 
251 
257 
259  void getPrimaryMSRunPath(StringList& toFill) const;
260 
262  bool operator==(const ConsensusMap& rhs) const;
263 
265  bool operator!=(const ConsensusMap& rhs) const;
266 
280  template <typename Type>
281  Size applyMemberFunction(Size (Type::* member_function)())
282  {
283  Size assignments = 0;
284  assignments += ((*this).*member_function)();
285  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
286  {
287  assignments += ((*iter).*member_function)();
288  }
289  return assignments;
290  }
291 
293  template <typename Type>
294  Size applyMemberFunction(Size (Type::* member_function)() const) const
295  {
296  Size assignments = 0;
297  assignments += ((*this).*member_function)();
298  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
299  {
300  assignments += ((*iter).*member_function)();
301  }
302  return assignments;
303  }
304 
317  bool isMapConsistent(Logger::LogStream* stream = nullptr) const;
318 
332  std::vector<FeatureMap> split(SplitMeta mode = SplitMeta::DISCARD) const;
333 
336 
343  std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
344 
347 
351 
352  protected:
355 
357  String experiment_type_ = "label-free";
358 
360  std::vector<ProteinIdentification> protein_identifications_;
361 
363  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
364 
366  std::vector<DataProcessing> data_processing_;
367 
370  };
371 
373  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusMap& cons_map);
374 
375 } // namespace OpenMS
#define EXPOSED_VECTOR_INTERFACE(InnerElement)
Macro to expose common dependent types, such as iterator in the derived class.
Definition: ExposedVector.h:19
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:45
A container for consensus elements.
Definition: ConsensusMap.h:66
ConsensusMap & operator=(ConsensusMap &&source)=default
MoveAssignment operator.
SplitMeta
Definition: ConsensusMap.h:71
ConsensusMap(ConsensusMap &&source)
Move constructor.
const_reverse_iterator ConstReverseIterator
Definition: ConsensusMap.h:116
void sortByRT()
Sorts the peaks to RT position.
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications()
mutable access to the unassigned peptide identifications
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition: ConsensusMap.h:112
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features....
Definition: ConsensusMap.h:281
ConsensusMap & operator=(const ConsensusMap &source)
Assignment operator.
void setUnassignedPeptideIdentifications(const std::vector< PeptideIdentification > &unassigned_peptide_identifications)
sets the unassigned peptide identifications
reverse_iterator ReverseIterator
Definition: ConsensusMap.h:115
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).
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:366
ConsensusMap & appendColumns(const ConsensusMap &rhs)
Add consensus map entries as new columns.
IdentificationData & getIdentificationData()
Mutable access to the contained identification data.
iterator Iterator
Definition: ConsensusMap.h:113
void sortPeptideIdentificationsByMapIndex()
Sorts PeptideIdentifications of consensus features with respect to their map index.
void sortByMZ()
Sorts the peaks to m/z position.
std::vector< ProteinIdentification > & getProteinIdentifications()
mutable access to the protein identifications
const_iterator ConstIterator
Definition: ConsensusMap.h:114
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:369
const ColumnHeaders & getColumnHeaders() const
Non-mutable access to the file descriptions.
bool operator==(const ConsensusMap &rhs) const
Equality operator.
void sortBySize()
Sorts with respect to the size (number of elements)
ConsensusFeature FeatureType
Definition: ConsensusMap.h:108
void clear(bool clear_meta_data=true)
Clears all data and meta data.
ConsensusMap()
Default constructor.
std::vector< FeatureMap > split(SplitMeta mode=SplitMeta::DISCARD) const
splits ConsensusMap into its original FeatureMaps
void setProteinIdentifications(std::vector< ProteinIdentification > &&protein_identifications)
sets the protein identifications by moving
void sortByPosition()
Lexicographically sorts the peaks by their position (First RT then m/z).
const String & getExperimentType() const
Non-mutable access to the experiment type.
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:111
std::vector< DataProcessing > & getDataProcessing()
returns a mutable reference to the description of the applied data processing
void getPrimaryMSRunPath(StringList &toFill) const
returns the MS run path (stored in ColumnHeaders)
std::map< UInt64, ColumnHeader > ColumnHeaders
Definition: ConsensusMap.h:109
ConsensusMap & appendRows(const ConsensusMap &rhs)
Add consensus map entries as new rows.
std::vector< PeptideIdentification > unassigned_peptide_identifications_
unassigned peptide identifications (without feature)
Definition: ConsensusMap.h:363
~ConsensusMap() override
Destructor.
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein identifications
const std::vector< PeptideIdentification > & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
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:354
const IdentificationData & getIdentificationData() const
Immutable access to the contained identification data.
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:360
ColumnHeaders & getColumnHeaders()
Mutable access to the file descriptions.
ConsensusMap(const ConsensusMap &source)
Copy constructor.
std::set< IdentificationData::ObservationMatchRef > getUnassignedIDMatches() const
Return observation matches (e.g. PSMs) from the identification data that are not assigned to any feat...
void updateRanges() override
void setPrimaryMSRunPath(const StringList &s, MSExperiment &e)
void setExperimentType(const String &experiment_type)
Mutable access to the experiment type.
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: ConsensusMap.h:294
Manage source document information.
Definition: DocumentIdentifier.h:30
Definition: ExposedVector.h:55
typename VecMember::iterator iterator
Definition: ExposedVector.h:61
typename VecMember::const_iterator const_iterator
Definition: ExposedVector.h:62
typename VecMember::size_type size_type
Definition: ExposedVector.h:65
typename VecMember::reverse_iterator reverse_iterator
Definition: ExposedVector.h:63
typename VecMember::const_reverse_iterator const_reverse_iterator
Definition: ExposedVector.h:64
Definition: IdentificationData.h:87
Log Stream Class.
Definition: LogStream.h:292
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:45
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
Definition: RangeManager.h:867
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:546
A more convenient string class.
Definition: String.h:34
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
@ INVALID
Definition: UniqueIdInterface.h:34
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
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:330
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:80
ColumnHeader & operator=(const ColumnHeader &)=default
Copy assignment.
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:91
String label
Label e.g. 'heavy' and 'light' for ICAT, or 'sample1' and 'sample2' for label-free quantitation.
Definition: ConsensusMap.h:94