OpenMS  2.5.0
LayerData.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-2020.
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: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
49 
50 #include <boost/shared_ptr.hpp>
51 
52 #include <vector>
53 #include <bitset>
54 
55 namespace OpenMS
56 {
85  class LayerData
86  {
87 public:
90  enum DataType
93  {
100  };
101 
103  enum Flags
104  {
114  };
115 
117  std::bitset<SIZE_OF_FLAGS> flags;
118 
121  {
128  };
129 
131  static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
132 
135 
137  typedef boost::shared_ptr<FeatureMap > FeatureMapSharedPtrType;
138 
141 
143  typedef boost::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
144 
147 
149  typedef boost::shared_ptr<ExperimentType> ExperimentSharedPtrType;
150 
151  typedef boost::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
152 
154  typedef boost::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
155 
157 
160  flags(),
161  visible(true),
162  flipped(false),
163  type(DT_UNKNOWN),
164  name(),
165  filename(),
166  peptides(),
167  param(),
168  gradient(),
169  filters(),
170  annotations_1d(),
171  peak_colors_1d(),
172  modifiable(false),
173  modified(false),
174  label(L_NONE),
175  peptide_id_index(-1),
176  peptide_hit_index(-1),
177  features(new FeatureMapType()),
178  consensus(new ConsensusMapType()),
179  peaks(new ExperimentType()),
181  chromatograms(new ExperimentType()),
184  {
185  annotations_1d.resize(1);
186  }
187 
189  const FeatureMapSharedPtrType & getFeatureMap() const
190  {
191  return features;
192  }
193 
195  FeatureMapSharedPtrType & getFeatureMap()
196  {
197  return features;
198  }
199 
201  const ConsensusMapSharedPtrType & getConsensusMap() const
202  {
203  return consensus;
204  }
205 
207  ConsensusMapSharedPtrType & getConsensusMap()
208  {
209  return consensus;
210  }
211 
221  const ConstExperimentSharedPtrType getPeakData() const;
222 
232  const ExperimentSharedPtrType & getPeakDataMuteable() {return peaks;}
233 
237  void setPeakData(ExperimentSharedPtrType p)
238  {
239  peaks = p;
240  updateCache_();
241  }
242 
244  void setOnDiscPeakData(ODExperimentSharedPtrType p)
245  {
246  on_disc_peaks = p;
247  }
248 
250  const ODExperimentSharedPtrType & getOnDiscPeakData() const
251  {
252  return on_disc_peaks;
253  }
254 
256  const ExperimentSharedPtrType & getChromatogramData() const
257  {
258  return chromatograms;
259  }
260 
262  ExperimentSharedPtrType & getChromatogramData()
263  {
264  return chromatograms;
265  }
266 
269  {
271  }
272 
275  {
277  }
278 
280  const Annotations1DContainer & getAnnotations(Size spectrum_index) const
281  {
282  return annotations_1d[spectrum_index];
283  }
284 
287  {
288  return annotations_1d[spectrum_index];
289  }
290 
297 
299  {
301  }
302 
305  {
306  if (spectrum_idx == current_spectrum_) return cached_spectrum_;
307 
308  if ((*peaks)[spectrum_idx].size() > 0)
309  {
310  return (*peaks)[spectrum_idx];
311  }
312  else if (!on_disc_peaks->empty())
313  {
314  return on_disc_peaks->getSpectrum(spectrum_idx);
315  }
316  return (*peaks)[spectrum_idx];
317  }
318 
321  {
322  return current_spectrum_;
323  }
324 
327  {
328  current_spectrum_ = index;
329  updateCache_();
330  }
331 
333  bool isIonMobilityData() const
334  {
335  return this->getPeakData()->size() > 0 &&
336  this->getPeakData()->metaValueExists("is_ion_mobility") &&
337  this->getPeakData()->getMetaValue("is_ion_mobility").toBool();
338  }
339 
341  {
342  peaks->setMetaValue("is_ion_mobility", "true");
343  }
344 
346  bool isDIAData() const
347  {
348  return this->getPeakData()->size() > 0 &&
349  this->getPeakData()->metaValueExists("is_dia_data") &&
350  this->getPeakData()->getMetaValue("is_dia_data").toBool();
351  }
352 
355  {
356  peaks->setMetaValue("is_dia_data", "true");
357  }
358 
368  {
369  return this->getPeakData()->size() > 0 &&
370  this->getPeakData()->metaValueExists("is_chromatogram") &&
371  this->getPeakData()->getMetaValue("is_chromatogram").toBool();
372  }
373 
376  {
377  peaks->setMetaValue("is_chromatogram", "true");
378  }
379 
382  {
383  if (this->chromatogram_flag_set())
384  {
385  peaks->removeMetaValue("is_chromatogram");
386  }
387  }
388 
395  void updateRanges();
396 
400 
402  void removePeakAnnotationsFromPeptideHit(const std::vector<Annotation1DItem*>& selected_annotations);
403 
405  bool visible;
406 
408  bool flipped;
409 
412 
415 
418 
420  std::vector<PeptideIdentification> peptides;
421 
424 
427 
430 
432  std::vector<Annotations1DContainer> annotations_1d;
433 
435  std::vector<QColor> peak_colors_1d;
436 
439 
441  bool modified;
442 
445 
449 
450 private:
451 
453  void updateCache_();
454 
457 
459  FeatureMapSharedPtrType features;
460 
462  ConsensusMapSharedPtrType consensus;
463 
465  ExperimentSharedPtrType peaks;
466 
468  ODExperimentSharedPtrType on_disc_peaks;
469 
471  ExperimentSharedPtrType chromatograms;
472 
475 
478 
479  };
480 
482  OPENMS_GUI_DLLAPI std::ostream & operator<<(std::ostream & os, const LayerData & rhs);
483 
484 } //namespace
485 
Container for annotations to content of Spectrum1DCanvas.
Definition: Annotations1DContainer.h:53
bool chromatogram_flag_set() const
Check whether the current layer is a chromatogram.
Definition: LayerData.h:367
std::vector< Annotations1DContainer > annotations_1d
Annotations of all spectra of the experiment (1D view)
Definition: LayerData.h:432
int peptide_id_index
Selected peptide id and hit index (-1 if none is selected)
Definition: LayerData.h:447
ConsensusMapSharedPtrType consensus
consensus feature data
Definition: LayerData.h:462
String name
layer name
Definition: LayerData.h:414
const ExperimentType::SpectrumType & getCurrentSpectrum() const
Returns a const reference to the current spectrum (1D view)
No label is displayed.
Definition: LayerData.h:122
Annotations1DContainer & getCurrentAnnotations()
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:274
LabelType label
Label type.
Definition: LayerData.h:444
Undefined data type indicating an error.
Definition: LayerData.h:99
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerData.h:131
void setOnDiscPeakData(ODExperimentSharedPtrType p)
Set the current on-disc data.
Definition: LayerData.h:244
FeatureMapSharedPtrType features
feature data
Definition: LayerData.h:459
ExperimentSharedPtrType & getChromatogramData()
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:262
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerData.h:117
Param param
Layer parameters.
Definition: LayerData.h:423
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerData.h:151
const ExperimentSharedPtrType & getPeakDataMuteable()
Returns a mutable reference to the current in-memory peak data.
Definition: LayerData.h:232
DataType type
data type (peak or feature data)
Definition: LayerData.h:411
Size current_spectrum_
Index of the current spectrum.
Definition: LayerData.h:474
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:143
const ConsensusMapSharedPtrType & getConsensusMap() const
Returns a const reference to the consensus feature data.
Definition: LayerData.h:201
const Annotations1DContainer & getAnnotations(Size spectrum_index) const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:280
DataFilters filters
Filters to apply before painting.
Definition: LayerData.h:429
ConsensusMapSharedPtrType & getConsensusMap()
Returns current consensus map (mutable)
Definition: LayerData.h:207
void remove_chromatogram_flag()
remove the chromatogram flag
Definition: LayerData.h:381
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerData.h:146
Definition: LayerData.h:127
std::vector< QColor > peak_colors_1d
Peak colors of the currently shown spectrum.
Definition: LayerData.h:435
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
const ODExperimentSharedPtrType & getOnDiscPeakData() const
Returns a mutable reference to the on-disc data.
Definition: LayerData.h:250
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
void sortByPosition()
Lexicographically sorts the peaks by their position.
Management and storage of parameters / INI files.
Definition: Param.h:73
const Annotations1DContainer & getCurrentAnnotations() const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:268
void updateRanges()
Update ranges of all data structures.
Identifications: m/z source.
Definition: LayerData.h:111
FeatureMap FeatureMapType
Features.
Definition: LayerData.h:134
const ConstExperimentSharedPtrType getPeakData() const
Returns a const reference to the current in-memory peak data.
The element number is used.
Definition: LayerData.h:123
bool isIonMobilityData() const
Check whether the current layer should be represented as ion mobility.
Definition: LayerData.h:333
bool visible
if this layer is visible
Definition: LayerData.h:405
FeatureMapSharedPtrType & getFeatureMap()
Returns a const reference to the current feature data.
Definition: LayerData.h:195
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerData.h:108
void labelAsIonMobilityData() const
Definition: LayerData.h:340
Feature data.
Definition: LayerData.h:96
void synchronizePeakAnnotations()
Annotations1DContainer & getAnnotations(Size spectrum_index)
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:286
DataType
Definition: LayerData.h:92
void setCurrentSpectrumIndex(Size index)
Set the index of the current spectrum (1D view)
Definition: LayerData.h:326
Spectrum profile or centroided data.
Definition: LayerData.h:94
A container for features.
Definition: FeatureMap.h:95
Peptide identification data.
Definition: LayerData.h:98
Size getCurrentSpectrumIndex() const
Get the index of the current spectrum (1D view)
Definition: LayerData.h:320
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:137
void labelAsDIAData()
Label the current layer as DIA (SWATH-MS) data.
Definition: LayerData.h:354
ExperimentType::SpectrumType cached_spectrum_
Current cached spectrum.
Definition: LayerData.h:477
void removePeakAnnotationsFromPeptideHit(const std::vector< Annotation1DItem *> &selected_annotations)
remove peak annotations in the given list from the currently active PeptideHit
void setPeakData(ExperimentSharedPtrType p)
Set the current in-memory peak data.
Definition: LayerData.h:237
std::vector< PeptideIdentification > peptides
peptide identifications
Definition: LayerData.h:420
String filename
file name of the file the data comes from (if available)
Definition: LayerData.h:417
bool modified
Flag that indicates that the layer data was modified since loading it.
Definition: LayerData.h:441
All peptide hits of the first identification run are used.
Definition: LayerData.h:126
const ExperimentSharedPtrType & getChromatogramData() const
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:256
int peptide_hit_index
Definition: LayerData.h:448
Consensus features: Show elements.
Definition: LayerData.h:110
bool flipped
if this layer is flipped (1d mirror view)
Definition: LayerData.h:408
Chromatogram data.
Definition: LayerData.h:95
bool modifiable
Flag that indicates if the layer data can be modified (so far used for features only) ...
Definition: LayerData.h:438
const FeatureMapSharedPtrType & getFeatureMap() const
Returns a const reference to the current feature data.
Definition: LayerData.h:189
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
Definition: LayerData.h:113
void updateCache_()
Update current cached spectrum for easy retrieval.
The &#39;label&#39; meta information is used.
Definition: LayerData.h:124
DataFilter array providing some convenience functions.
Definition: DataFilters.h:50
ExperimentSharedPtrType chromatograms
chromatogram data
Definition: LayerData.h:471
ExperimentSharedPtrType peaks
peak data
Definition: LayerData.h:465
The best peptide hit of the first identification run is used.
Definition: LayerData.h:125
ConsensusMap ConsensusMapType
consensus features
Definition: LayerData.h:140
LayerData()
Default constructor.
Definition: LayerData.h:159
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:154
Representation of a peptide hit.
Definition: PeptideHit.h:54
Peaks: Show projections.
Definition: LayerData.h:109
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:68
Identifications: Show labels (not sequences)
Definition: LayerData.h:112
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
void updatePeptideHitAnnotations_(PeptideHit &hit)
updates the PeakAnnotations in the current PeptideHit with manually changed annotations ...
Features: Convex hulls of single mass traces.
Definition: LayerData.h:106
A more convenient string class.
Definition: String.h:58
A container for consensus elements.
Definition: ConsensusMap.h:79
Class that stores the data for one layer.
Definition: LayerData.h:85
ODExperimentSharedPtrType on_disc_peaks
on disc peak data
Definition: LayerData.h:468
void sortCurrentSpectrumByPosition()
Definition: LayerData.h:298
Features: Overall convex hull.
Definition: LayerData.h:105
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:149
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerData.h:426
Features: Unassigned peptide hits.
Definition: LayerData.h:107
LabelType
Label used in visualization.
Definition: LayerData.h:120
Consensus feature data.
Definition: LayerData.h:97
Flags
Flags that determine which information is shown.
Definition: LayerData.h:103
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
const ExperimentType::SpectrumType getSpectrum(Size spectrum_idx) const
Returns a const-copy of the required spectrum which is guaranteed to be populated with raw data...
Definition: LayerData.h:304
bool isDIAData() const
Check whether the current layer contains DIA (SWATH-MS) data.
Definition: LayerData.h:346
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void set_chromatogram_flag()
set the chromatogram flag
Definition: LayerData.h:375