OpenMS
ConsensusMap.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: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
42 
46 
47 #include <OpenMS/CONCEPT/Types.h>
52 #include <OpenMS/OpenMSConfig.h>
53 
54 #include <map>
55 #include <vector>
56 #include <iosfwd>
57 
58 namespace OpenMS
59 {
60  class PeptideIdentification;
61  class PeptideHit;
62  class ProteinIdentification;
63  class DataProcessing;
64  namespace Logger
65  {
66  class LogStream;
67  }
68 
84  class OPENMS_DLLAPI ConsensusMap :
85  public MetaInfoInterface,
86  public RangeManagerContainer<RangeRT, RangeMZ, RangeIntensity>,
87  public DocumentIdentifier,
88  public ExposedVector<ConsensusFeature>,
89  public UniqueIdInterface,
90  public UniqueIdIndexer<ConsensusMap>,
91  public MapUtilities<ConsensusMap>
92  {
93 public:
95 
96  enum class SplitMeta
97  {
98  DISCARD,
99  COPY_ALL,
100  COPY_FIRST
101  };
102 
104  struct ColumnHeader :
105  public MetaInfoInterface
106  {
108  ColumnHeader() = default;
109 
111  ColumnHeader(const ColumnHeader&) = default;
112 
114  ColumnHeader& operator=(const ColumnHeader&) = default;
115 
118 
121 
124  Size size = 0;
125 
128 
129  unsigned getLabelAsUInt(const String& experiment_type) const;
130  };
131 
133 
135  typedef std::map<UInt64, ColumnHeader> ColumnHeaders;
136 
144 
146  ConsensusMap();
147 
149  ConsensusMap(const ConsensusMap& source);
151  ConsensusMap(ConsensusMap&& source);
152 
154  ~ConsensusMap() override;
155 
157  explicit ConsensusMap(size_type n);
158 
160  ConsensusMap& operator=(const ConsensusMap& source);
162  ConsensusMap& operator=(ConsensusMap&& source) = default;
163 
173  ConsensusMap& appendRows(const ConsensusMap& rhs);
174 
182  ConsensusMap& appendColumns(const ConsensusMap& rhs);
183 
184 
190  void clear(bool clear_meta_data = true);
191 
193  const ColumnHeaders& getColumnHeaders() const;
194 
196  ColumnHeaders& getColumnHeaders();
197 
199  void setColumnHeaders(const ColumnHeaders& column_description);
200 
202  const String& getExperimentType() const;
203 
205  void setExperimentType(const String& experiment_type);
206 
214  void sortByIntensity(bool reverse = false);
216 
218  void sortByRT();
219 
221  void sortByMZ();
222 
224  void sortByPosition();
225 
227  void sortByQuality(bool reverse = false);
228 
230  void sortBySize();
231 
233  void sortByMaps();
234 
236  void sortPeptideIdentificationsByMapIndex();
238 
239  // Docu in base class
240  void updateRanges() override;
241 
243  void swap(ConsensusMap& from);
244 
246  const std::vector<ProteinIdentification>& getProteinIdentifications() const;
247 
249  std::vector<ProteinIdentification>& getProteinIdentifications();
250 
252  void setProteinIdentifications(const std::vector<ProteinIdentification>& protein_identifications);
253 
255  void setProteinIdentifications(std::vector<ProteinIdentification>&& protein_identifications);
256 
258  const std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications() const;
259 
261  std::vector<PeptideIdentification>& getUnassignedPeptideIdentifications();
262 
264  void setUnassignedPeptideIdentifications(const std::vector<PeptideIdentification>& unassigned_peptide_identifications);
265 
267  const std::vector<DataProcessing>& getDataProcessing() const;
268 
270  std::vector<DataProcessing>& getDataProcessing();
271 
273  void setDataProcessing(const std::vector<DataProcessing>& processing_method);
274 
276  void setPrimaryMSRunPath(const StringList& s);
277 
282  void setPrimaryMSRunPath(const StringList& s, MSExperiment & e);
283 
285  void getPrimaryMSRunPath(StringList& toFill) const;
286 
288  bool operator==(const ConsensusMap& rhs) const;
289 
291  bool operator!=(const ConsensusMap& rhs) const;
292 
306  template <typename Type>
307  Size applyMemberFunction(Size (Type::* member_function)())
308  {
309  Size assignments = 0;
310  assignments += ((*this).*member_function)();
311  for (Iterator iter = this->begin(); iter != this->end(); ++iter)
312  {
313  assignments += ((*iter).*member_function)();
314  }
315  return assignments;
316  }
317 
319  template <typename Type>
320  Size applyMemberFunction(Size (Type::* member_function)() const) const
321  {
322  Size assignments = 0;
323  assignments += ((*this).*member_function)();
324  for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
325  {
326  assignments += ((*iter).*member_function)();
327  }
328  return assignments;
329  }
330 
343  bool isMapConsistent(Logger::LogStream* stream = nullptr) const;
344 
358  std::vector<FeatureMap> split(SplitMeta mode = SplitMeta::DISCARD) const;
359 
362 
369  std::set<IdentificationData::ObservationMatchRef> getUnassignedIDMatches() const;
370 
372  const IdentificationData& getIdentificationData() const;
373 
375  IdentificationData& getIdentificationData();
377 
378  protected:
381 
383  String experiment_type_ = "label-free";
384 
386  std::vector<ProteinIdentification> protein_identifications_;
387 
389  std::vector<PeptideIdentification> unassigned_peptide_identifications_;
390 
392  std::vector<DataProcessing> data_processing_;
393 
396  };
397 
399  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ConsensusMap& cons_map);
400 
401 } // namespace OpenMS
reverse_iterator ReverseIterator
Definition: ConsensusMap.h:141
IdentificationData id_data_
general identification results (peptides/proteins, RNA, compounds)
Definition: ConsensusMap.h:395
A more convenient string class.
Definition: String.h:58
typename VecMember::const_reverse_iterator const_reverse_iterator
Definition: ExposedVector.h:90
const_reverse_iterator ConstReverseIterator
Definition: ConsensusMap.h:142
RangeManagerContainer< RangeRT, RangeMZ, RangeIntensity > RangeManagerContainerType
Definition: ConsensusMap.h:137
std::vector< PeptideIdentification > unassigned_peptide_identifications_
unassigned peptide identifications (without feature)
Definition: ConsensusMap.h:389
RangeManager< RangeRT, RangeMZ, RangeIntensity > RangeManagerType
Definition: ConsensusMap.h:138
Definition: IdentificationData.h:112
A container for consensus elements.
Definition: ConsensusMap.h:84
ColumnHeaders column_description_
Map from index to file description.
Definition: ConsensusMap.h:380
const_iterator ConstIterator
Definition: ConsensusMap.h:140
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Size applyMemberFunction(Size(Type::*member_function)())
Applies a member function of Type to the container itself and all consensus features. The returned values are accumulated.
Definition: ConsensusMap.h:307
static bool split(const String &this_s, const char splitter, std::vector< String > &substrings, bool quote_protect)
Definition: StringUtilsSimple.h:365
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::vector< DataProcessing > data_processing_
applied data processing
Definition: ConsensusMap.h:392
Log Stream Class.
Definition: LogStream.h:316
#define EXPOSED_VECTOR_INTERFACE(InnerElement)
Macro to expose common dependent types, such as iterator in the derived class.
Definition: ExposedVector.h:45
iterator Iterator
Definition: ConsensusMap.h:139
Utilities for Feature and ConsensusMap.
Definition: MapUtilities.h:49
typename VecMember::const_iterator const_iterator
Definition: ExposedVector.h:88
String label
Label e.g. &#39;heavy&#39; and &#39;light&#39; for ICAT, or &#39;sample1&#39; and &#39;sample2&#39; for label-free quantitation...
Definition: ConsensusMap.h:120
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
A base class for containers with elements derived from UniqueIdInterface. This adds functionality to ...
Definition: UniqueIdIndexer.h:66
static String & reverse(String &this_s)
Definition: StringUtilsSimple.h:355
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
std::map< UInt64, ColumnHeader > ColumnHeaders
Definition: ConsensusMap.h:135
typename VecMember::iterator iterator
Definition: ExposedVector.h:87
A base class defining a common interface for all classes having a unique id.
Definition: UniqueIdInterface.h:50
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Definition: UniqueIdInterface.h:60
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
typename VecMember::size_type size_type
Definition: ExposedVector.h:91
std::vector< ProteinIdentification > protein_identifications_
protein identifications
Definition: ConsensusMap.h:386
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
ConsensusFeature FeatureType
Definition: ConsensusMap.h:134
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
typename VecMember::reverse_iterator reverse_iterator
Definition: ExposedVector.h:89
Size applyMemberFunction(Size(Type::*member_function)() const) const
The "const" variant.
Definition: ConsensusMap.h:320
Description of the columns in a consensus map.
Definition: ConsensusMap.h:104
String filename
File name of the mzML file.
Definition: ConsensusMap.h:117
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra...
Definition: RangeManager.h:565
Definition: RangeManager.h:896
SplitMeta
Definition: ConsensusMap.h:96
Makes a vector<VectorElement> available in the derived class and exposed commonly used vector member ...
Definition: ExposedVector.h:80
Manage source document information.
Definition: DocumentIdentifier.h:55
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:69