OpenMS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
16 
22 
23 #include <OpenMS/CONCEPT/Types.h>
28 #include <OpenMS/OpenMSConfig.h>
29 
30 #include <map>
31 #include <vector>
32 #include <iosfwd>
33 
34 namespace OpenMS
35 {
36  class PeptideIdentification;
37  class PeptideHit;
38  class ProteinIdentification;
39  class DataProcessing;
40  namespace Logger
41  {
42  class LogStream;
43  }
44 
60  class OPENMS_DLLAPI ConsensusMap :
61  public MetaInfoInterface,
62  public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
63  public DocumentIdentifier,
64  public ExposedVector<ConsensusFeature>,
65  public UniqueIdInterface,
66  public UniqueIdIndexer<ConsensusMap>,
67  public MapUtilities<ConsensusMap>
68  {
69 public:
71 
72  enum class SplitMeta
73  {
74  DISCARD,
75  COPY_ALL,
76  COPY_FIRST
77  };
78 
80  struct ColumnHeader :
81  public MetaInfoInterface
82  {
84  ColumnHeader() = default;
85 
87  ColumnHeader(const ColumnHeader&) = default;
88 
90  ColumnHeader& operator=(const ColumnHeader&) = default;
91 
94 
97 
100  Size size = 0;
101 
104 
105  unsigned getLabelAsUInt(const String& experiment_type) const;
106  };
107 
109 
111  typedef std::map<UInt64, ColumnHeader> ColumnHeaders;
112 
120 
123 
125  ConsensusMap(const ConsensusMap& source);
128 
130  ~ConsensusMap() override;
131 
133  explicit ConsensusMap(size_type n);
134 
138  ConsensusMap& operator=(ConsensusMap&& source) = default;
139 
150 
159 
160 
166  void clear(bool clear_meta_data = true);
167 
170 
173 
175  void setColumnHeaders(const ColumnHeaders& column_description);
176 
178  const String& getExperimentType() const;
179 
181  void setExperimentType(const String& experiment_type);
182 
191  void sortByIntensity(bool reverse = false);
192 
194  void sortByRT();
195 
197  void sortByMZ();
198 
201 
203  void sortByQuality(bool reverse = false);
204 
206  void sortBySize();
207 
209  void sortByMaps();
210 
214 
215  // Docu in base class
216  void updateRanges() override;
217 
219  void swap(ConsensusMap& from);
220 
222  const std::vector<ProteinIdentification>& getProteinIdentifications() const;
223 
225  std::vector<ProteinIdentification>& getProteinIdentifications();
226 
228  void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
229 
231  void setProteinIdentifications(std::vector<ProteinIdentification>&& protein_identifications);
232 
235 
238 
240  void setUnassignedPeptideIdentifications(const PeptideIdentificationList& unassigned_peptide_identifications);
241 
243  const std::vector<DataProcessing>& getDataProcessing() const;
244 
246  std::vector<DataProcessing>& getDataProcessing();
247 
249  void setDataProcessing(const std::vector<DataProcessing>& processing_method);
250 
253 
259 
261  void getPrimaryMSRunPath(StringList& toFill) const;
262 
264  bool operator==(const ConsensusMap& rhs) const;
265 
267  bool operator!=(const ConsensusMap& rhs) const;
268 
282  template <typename Type>
283  Size applyMemberFunction(Size (Type::* member_function)())
284  {
285  Size assignments = 0;
286  assignments += ((*this).*member_function)();
287  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
288  {
289  assignments += ((*iter).*member_function)();
290  }
291  return assignments;
292  }
293 
295  template <typename Type>
296  Size applyMemberFunction(Size (Type::* member_function)() const) const
297  {
298  Size assignments = 0;
299  assignments += ((*this).*member_function)();
300  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
301  {
302  assignments += ((*iter).*member_function)();
303  }
304  return assignments;
305  }
306 
319  bool isMapConsistent(Logger::LogStream* stream = nullptr) const;
320 
334  std::vector<FeatureMap> split(SplitMeta mode = SplitMeta::DISCARD) const;
335 
338 
345  std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
346 
349 
353 
354  protected:
357 
359  String experiment_type_ = "label-free";
360 
362  std::vector<ProteinIdentification> protein_identifications_;
363 
366 
368  std::vector<DataProcessing> data_processing_;
369 
372  };
373 
375  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusMap& cons_map);
376 
377 } // 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:68
ConsensusMap & operator=(ConsensusMap &&source)=default
MoveAssignment operator.
SplitMeta
Definition: ConsensusMap.h:73
ConsensusMap(ConsensusMap &&source)
Move constructor.
const_reverse_iterator ConstReverseIterator
Definition: ConsensusMap.h:118
void sortByRT()
Sorts the peaks to RT position.
void setUnassignedPeptideIdentifications(const PeptideIdentificationList &unassigned_peptide_identifications)
sets the unassigned peptide identifications
const std::vector< DataProcessing > & getDataProcessing() const
returns a const reference to the description of the applied data processing
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition: ConsensusMap.h:114
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features....
Definition: ConsensusMap.h:283
ConsensusMap & operator=(const ConsensusMap &source)
Assignment operator.
reverse_iterator ReverseIterator
Definition: ConsensusMap.h:117
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:368
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:115
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:116
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:371
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:110
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:113
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:111
ConsensusMap & appendRows(const ConsensusMap &rhs)
Add consensus map entries as new rows.
~ConsensusMap() override
Destructor.
const std::vector< ProteinIdentification > & getProteinIdentifications() const
non-mutable access to the protein 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:356
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.
const PeptideIdentificationList & getUnassignedPeptideIdentifications() const
non-mutable access to the unassigned peptide identifications
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: ConsensusMap.h:362
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)
PeptideIdentificationList & getUnassignedPeptideIdentifications()
mutable access to the unassigned peptide identifications
void setExperimentType(const String &experiment_type)
Mutable access to the experiment type.
PeptideIdentificationList unassigned_peptide_identifications_
unassigned peptide identifications (without feature)
Definition: ConsensusMap.h:365
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: ConsensusMap.h:296
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:292
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:35
Container for peptide identifications from multiple spectra.
Definition: PeptideIdentificationList.h:66
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: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:82
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:93
String label
Label e.g. 'heavy' and 'light' for ICAT, or 'sample1' and 'sample2' for label-free quantitation.
Definition: ConsensusMap.h:96