OpenMS  3.0.0
LayerDataPeak.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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
42 
43 #include <vector>
44 
45 namespace OpenMS
46 {
47  class Annotation1DItem;
48 
54  class OPENMS_GUI_DLLAPI LayerDataPeak : public virtual LayerDataBase
55  {
56  public:
57 
60 
62  LayerDataPeak();
64  LayerDataPeak(const LayerDataPeak& ld) = default;
66  LayerDataPeak& operator=(const LayerDataPeak& ld) = delete;
68  LayerDataPeak(LayerDataPeak&& ld) = default;
70  LayerDataPeak& operator=(LayerDataPeak&& ld) = default;
71 
72  std::unique_ptr<Painter2DBase> getPainter2D() const override;
73 
74  std::unique_ptr<LayerData1DBase> to1DLayer() const override;
75 
76  std::unique_ptr<LayerStoreData> storeVisibleData(const RangeAllType& visible_range, const DataFilters& layer_filters) const override;
77 
78  std::unique_ptr<LayerStoreData> storeFullData() const override;
79 
80  ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType& area) const override;
81 
82  PeakIndex findHighestDataPoint(const RangeAllType& area) const override;
83 
84  void updateRanges() override
85  {
86  peak_map_->updateRanges();
87  // on_disc_peaks_->updateRanges(); // note: this is not going to work since its on disk! We currently don't have a good way to access these ranges
88  }
89 
90  RangeAllType getRange() const override
91  {
92  RangeAllType r;
93  r.assign(*peak_map_);
94  return r;
95  }
96 
97  PointXYType peakIndexToXY(const PeakIndex& peak, const DimMapper<2>& mapper) const override;
98 
99  String getDataArrayDescription(const PeakIndex& peak_index) override;
100 
101  std::unique_ptr<LayerStatistics> getStats() const override;
102 
103  bool annotate(const std::vector<PeptideIdentification>& identifications, const std::vector<ProteinIdentification>& protein_identifications) override;
104 
105  const ExperimentType::SpectrumType& getSpectrum(Size spectrum_idx) const
106  {
107  if ((*peak_map_)[spectrum_idx].size() > 0)
108  {
109  return (*peak_map_)[spectrum_idx];
110  }
111  if (!on_disc_peaks_->empty())
112  {
113  static MSSpectrum local_spec;
114  local_spec = on_disc_peaks_->getSpectrum(spectrum_idx);
115  return local_spec;
116  }
117  return (*peak_map_)[spectrum_idx];
118  }
119 
129  const ConstExperimentSharedPtrType getPeakData() const;
130 
140  const ExperimentSharedPtrType& getPeakDataMuteable()
141  {
142  return peak_map_;
143  }
144 
148  void setPeakData(ExperimentSharedPtrType p)
149  {
150  peak_map_ = p;
151  }
152 
154  void setOnDiscPeakData(ODExperimentSharedPtrType p)
155  {
156  on_disc_peaks_ = p;
157  }
158 
160  const ODExperimentSharedPtrType& getOnDiscPeakData() const
161  {
162  return on_disc_peaks_;
163  }
164 
165 
166 
168  bool isIonMobilityData() const
169  {
170  return this->getPeakData()->size() > 0 && this->getPeakData()->metaValueExists("is_ion_mobility") && this->getPeakData()->getMetaValue("is_ion_mobility").toBool();
171  }
172 
174  {
175  peak_map_->setMetaValue("is_ion_mobility", "true");
176  }
177 
179  bool isDIAData() const
180  {
181  return this->getPeakData()->size() > 0 && this->getPeakData()->metaValueExists("is_dia_data") && this->getPeakData()->getMetaValue("is_dia_data").toBool();
182  }
183 
186  {
187  peak_map_->setMetaValue("is_dia_data", "true");
188  }
189 
199  {
200  return this->getPeakData()->size() > 0 && this->getPeakData()->metaValueExists("is_chromatogram") && this->getPeakData()->getMetaValue("is_chromatogram").toBool();
201  }
202 
205  {
206  peak_map_->setMetaValue("is_chromatogram", "true");
207  }
208 
211  {
212  if (this->chromatogram_flag_set())
213  {
214  peak_map_->removeMetaValue("is_chromatogram");
215  }
216  }
217 
218 
219  protected:
221  ExperimentSharedPtrType peak_map_ = ExperimentSharedPtrType(new ExperimentType());
222 
224  ODExperimentSharedPtrType on_disc_peaks_ = ODExperimentSharedPtrType(new OnDiscMSExperiment());
225  };
226 
227 }// namespace OpenMS
bool isDIAData() const
Check whether the current layer contains DIA (SWATH-MS) data.
Definition: LayerDataPeak.h:179
A more convenient string class.
Definition: String.h:58
RangeAllType getRange() const override
Definition: LayerDataPeak.h:90
Class that stores the data for one layer of type PeakMap.
Definition: LayerDataPeak.h:54
OpenMS::Peak1D PeakType
Peak type.
Definition: MSSpectrum.h:110
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
DIM_UNIT
Definition: CommonEnums.h:45
void remove_chromatogram_flag()
remove the chromatogram flag
Definition: LayerDataPeak.h:210
Result of computing a projection on X and Y axis in a 2D Canvas; see LayerDataBase::getProjection() ...
Definition: LayerDataBase.h:76
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:66
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:612
void setPeakData(ExperimentSharedPtrType p)
Set the current in-memory peak data.
Definition: LayerDataPeak.h:148
const ExperimentType::SpectrumType & getSpectrum(Size spectrum_idx) const
Definition: LayerDataPeak.h:105
void set_chromatogram_flag()
set the chromatogram flag
Definition: LayerDataPeak.h:204
bool isIonMobilityData() const
Check whether the current layer should be represented as ion mobility.
Definition: LayerDataPeak.h:168
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
void setOnDiscPeakData(ODExperimentSharedPtrType p)
Set the current on-disc data.
Definition: LayerDataPeak.h:154
bool chromatogram_flag_set() const
Check whether the current layer is a chromatogram.
Definition: LayerDataPeak.h:198
const ExperimentSharedPtrType & getPeakDataMuteable()
Returns a mutable reference to the current in-memory peak data.
Definition: LayerDataPeak.h:140
void labelAsDIAData()
Label the current layer as DIA (SWATH-MS) data.
Definition: LayerDataPeak.h:185
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
const ODExperimentSharedPtrType & getOnDiscPeakData() const
Returns a mutable reference to the on-disc data.
Definition: LayerDataPeak.h:160
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
void updateRanges() override
Update ranges of the underlying data.
Definition: LayerDataPeak.h:84
DataFilter array providing some convenience functions.
Definition: DataFilters.h:52
Class that stores the data for one layer.
Definition: LayerDataBase.h:191
void labelAsIonMobilityData() const
Definition: LayerDataPeak.h:173
Index of a peak or feature.
Definition: PeakIndex.h:50
MSSpectrum SpectrumType
Definition: MzDataHandler.h:60