OpenMS  2.6.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()),
179  peaks(new ExperimentType()),
184  {
185  annotations_1d.resize(1);
186  }
187 
190  {
191  return features;
192  }
193 
196  {
197  return features;
198  }
199 
202  {
203  return consensus;
204  }
205 
208  {
209  return consensus;
210  }
211 
222 
233 
238  {
239  peaks = p;
240  updateCache_();
241  }
242 
245  {
246  on_disc_peaks = p;
247  }
248 
251  {
252  return on_disc_peaks;
253  }
254 
257  {
258  return chromatograms;
259  }
260 
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 
452  {
453  String n = name;
454  if (flipped)
455  {
456  n += " [flipped]";
457  }
458  if (modified)
459  {
460  n += '*';
461  }
462  return n;
463  }
464 
465 private:
466 
467 
469  void updateCache_();
470 
473 
476 
479 
482 
485 
488 
491 
494 
495  };
496 
498  OPENMS_GUI_DLLAPI std::ostream & operator<<(std::ostream & os, const LayerData & rhs);
499 
500 } //namespace
501 
OpenMS::MultiGradient
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
OpenMS::LayerData::peptides
std::vector< PeptideIdentification > peptides
peptide identifications
Definition: LayerData.h:420
OpenMS::LayerData::name
String name
layer name
Definition: LayerData.h:414
OpenMS::LayerData::on_disc_peaks
ODExperimentSharedPtrType on_disc_peaks
on disc peak data
Definition: LayerData.h:484
OpenMS::LayerData::ExperimentSharedPtrType
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:149
OpenMS::LayerData::getDecoratedName
String getDecoratedName() const
get name augmented with attributes, e.g. [flipped], or '*' if modified
Definition: LayerData.h:451
OpenMS::LayerData::modified
bool modified
Flag that indicates that the layer data was modified since loading it.
Definition: LayerData.h:441
OpenMS::LayerData::NamesOfLabelType
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerData.h:131
OpenMS::LayerData::L_META_LABEL
The 'label' meta information is used.
Definition: LayerData.h:124
OpenMS::LayerData::features
FeatureMapSharedPtrType features
feature data
Definition: LayerData.h:475
OpenMS::LayerData::FeatureMapSharedPtrType
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:137
OpenMS::LayerData::DT_CONSENSUS
Consensus feature data.
Definition: LayerData.h:97
OpenMS::LayerData::ConsensusMapSharedPtrType
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:143
OpenMS::LayerData::P_PROJECTIONS
Peaks: Show projections.
Definition: LayerData.h:109
OpenMS::LayerData::sortCurrentSpectrumByPosition
void sortCurrentSpectrumByPosition()
Definition: LayerData.h:298
OpenMS::LayerData::getCurrentAnnotations
const Annotations1DContainer & getCurrentAnnotations() const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:268
OpenMS::LayerData::ConstExperimentSharedPtrType
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerData.h:151
OpenMS::LayerData::L_NONE
No label is displayed.
Definition: LayerData.h:122
OpenMS::LayerData::getOnDiscPeakData
const ODExperimentSharedPtrType & getOnDiscPeakData() const
Returns a mutable reference to the on-disc data.
Definition: LayerData.h:250
OpenMS::String
A more convenient string class.
Definition: String.h:59
ConsensusMap.h
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::LayerData::getFeatureMap
const FeatureMapSharedPtrType & getFeatureMap() const
Returns a const reference to the current feature data.
Definition: LayerData.h:189
OpenMS::LayerData::getAnnotations
Annotations1DContainer & getAnnotations(Size spectrum_index)
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:286
OpenMS::LayerData::filters
DataFilters filters
Filters to apply before painting.
Definition: LayerData.h:429
MultiGradient.h
OpenMS::LayerData::current_spectrum_
Size current_spectrum_
Index of the current spectrum.
Definition: LayerData.h:490
OpenMS::LayerData::peak_colors_1d
std::vector< QColor > peak_colors_1d
Peak colors of the currently shown spectrum.
Definition: LayerData.h:435
OpenMS::LayerData::ConsensusMapType
ConsensusMap ConsensusMapType
consensus features
Definition: LayerData.h:140
OpenMS::LayerData::flipped
bool flipped
if this layer is flipped (1d mirror view)
Definition: LayerData.h:408
OpenMS::LayerData::getChromatogramData
const ExperimentSharedPtrType & getChromatogramData() const
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:256
OpenMS::LayerData::Flags
Flags
Flags that determine which information is shown.
Definition: LayerData.h:103
OpenMS::LayerData::I_LABELS
Identifications: Show labels (not sequences)
Definition: LayerData.h:112
OpenMS::LayerData::setOnDiscPeakData
void setOnDiscPeakData(ODExperimentSharedPtrType p)
Set the current on-disc data.
Definition: LayerData.h:244
OpenMS::LayerData::LayerData
LayerData()
Default constructor.
Definition: LayerData.h:159
OpenMS::MSExperiment::SpectrumType
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:101
OpenMS::LayerData::DT_FEATURE
Feature data.
Definition: LayerData.h:96
OpenMS::LayerData::gradient
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerData.h:426
OpenMS::LayerData::L_INDEX
The element number is used.
Definition: LayerData.h:123
OpenMS::LayerData::set_chromatogram_flag
void set_chromatogram_flag()
set the chromatogram flag
Definition: LayerData.h:375
OpenMS::LayerData::getPeakData
const ConstExperimentSharedPtrType getPeakData() const
Returns a const reference to the current in-memory peak data.
OpenMS::LayerData::DT_UNKNOWN
Undefined data type indicating an error.
Definition: LayerData.h:99
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::LayerData::DT_PEAK
Spectrum profile or centroided data.
Definition: LayerData.h:94
OpenMS::LayerData::SIZE_OF_FLAGS
Definition: LayerData.h:113
OpenMS::LayerData::F_UNASSIGNED
Features: Unassigned peptide hits.
Definition: LayerData.h:107
OpenMS::LayerData::DT_IDENT
Peptide identification data.
Definition: LayerData.h:98
OpenMS::LayerData::filename
String filename
file name of the file the data comes from (if available)
Definition: LayerData.h:417
OpenMS::LayerData::remove_chromatogram_flag
void remove_chromatogram_flag()
remove the chromatogram flag
Definition: LayerData.h:381
OpenMS::LayerData::updateRanges
void updateRanges()
Update ranges of all data structures.
OpenMS::LayerData::getCurrentSpectrum
const ExperimentType::SpectrumType & getCurrentSpectrum() const
Returns a const reference to the current spectrum (1D view)
OpenMS::LayerData
Class that stores the data for one layer.
Definition: LayerData.h:85
OpenMS::LayerData::getConsensusMap
ConsensusMapSharedPtrType & getConsensusMap()
Returns current consensus map (mutable)
Definition: LayerData.h:207
OpenMS::OnDiscMSExperiment
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:68
FeatureMap.h
OpenMS::LayerData::getConsensusMap
const ConsensusMapSharedPtrType & getConsensusMap() const
Returns a const reference to the consensus feature data.
Definition: LayerData.h:201
OpenMS::LayerData::getChromatogramData
ExperimentSharedPtrType & getChromatogramData()
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:262
OpenMS::LayerData::updateCache_
void updateCache_()
Update current cached spectrum for easy retrieval.
DataFilters.h
OpenMS::LayerData::updatePeptideHitAnnotations_
void updatePeptideHitAnnotations_(PeptideHit &hit)
updates the PeakAnnotations in the current PeptideHit with manually changed annotations
OpenMS::LayerData::I_PEPTIDEMZ
Identifications: m/z source.
Definition: LayerData.h:111
OpenMS::LayerData::getPeakDataMuteable
const ExperimentSharedPtrType & getPeakDataMuteable()
Returns a mutable reference to the current in-memory peak data.
Definition: LayerData.h:232
OpenMS::LayerData::FeatureMapType
FeatureMap FeatureMapType
Features.
Definition: LayerData.h:134
OpenMS::LayerData::peaks
ExperimentSharedPtrType peaks
peak data
Definition: LayerData.h:481
OpenMS::LayerData::getSpectrum
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
OpenMS::LayerData::C_ELEMENTS
Consensus features: Show elements.
Definition: LayerData.h:110
OpenMS::LayerData::cached_spectrum_
ExperimentType::SpectrumType cached_spectrum_
Current cached spectrum.
Definition: LayerData.h:493
OpenMS::LayerData::getCurrentSpectrumIndex
Size getCurrentSpectrumIndex() const
Get the index of the current spectrum (1D view)
Definition: LayerData.h:320
OpenMS::LayerData::visible
bool visible
if this layer is visible
Definition: LayerData.h:405
OpenMS::LayerData::chromatogram_flag_set
bool chromatogram_flag_set() const
Check whether the current layer is a chromatogram.
Definition: LayerData.h:367
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::LayerData::modifiable
bool modifiable
Flag that indicates if the layer data can be modified (so far used for features only)
Definition: LayerData.h:438
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:80
OpenMS::MSSpectrum::sortByPosition
void sortByPosition()
Lexicographically sorts the peaks by their position.
OpenMS::LayerData::removePeakAnnotationsFromPeptideHit
void removePeakAnnotationsFromPeptideHit(const std::vector< Annotation1DItem * > &selected_annotations)
remove peak annotations in the given list from the currently active PeptideHit
OpenMS::LayerData::annotations_1d
std::vector< Annotations1DContainer > annotations_1d
Annotations of all spectra of the experiment (1D view)
Definition: LayerData.h:432
OpenMS::LayerData::peptide_id_index
int peptide_id_index
Selected peptide id and hit index (-1 if none is selected)
Definition: LayerData.h:447
OpenMS::LayerData::L_ID
The best peptide hit of the first identification run is used.
Definition: LayerData.h:125
OpenMS::LayerData::ExperimentType
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerData.h:146
MSExperiment.h
OpenMS::LayerData::param
Param param
Layer parameters.
Definition: LayerData.h:423
OpenMS::LayerData::F_HULLS
Features: Convex hulls of single mass traces.
Definition: LayerData.h:106
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:97
OpenMS::DataFilters
DataFilter array providing some convenience functions.
Definition: DataFilters.h:50
OpenMS::LayerData::isIonMobilityData
bool isIonMobilityData() const
Check whether the current layer should be represented as ion mobility.
Definition: LayerData.h:333
OpenMS::LayerData::getFeatureMap
FeatureMapSharedPtrType & getFeatureMap()
Returns a const reference to the current feature data.
Definition: LayerData.h:195
OpenMS::LayerData::labelAsDIAData
void labelAsDIAData()
Label the current layer as DIA (SWATH-MS) data.
Definition: LayerData.h:354
OpenMS::LayerData::L_ID_ALL
All peptide hits of the first identification run are used.
Definition: LayerData.h:126
Annotations1DContainer.h
OpenMS::LayerData::flags
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerData.h:117
OpenMS::LayerData::chromatograms
ExperimentSharedPtrType chromatograms
chromatogram data
Definition: LayerData.h:487
OpenMS::LayerData::peptide_hit_index
int peptide_hit_index
Definition: LayerData.h:448
OpenMS::LayerData::labelAsIonMobilityData
void labelAsIonMobilityData() const
Definition: LayerData.h:340
OpenMS::LayerData::label
LabelType label
Label type.
Definition: LayerData.h:444
String.h
OpenMS::LayerData::SIZE_OF_LABEL_TYPE
Definition: LayerData.h:127
OpenMS::LayerData::DataType
DataType
Definition: LayerData.h:92
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::LayerData::setCurrentSpectrumIndex
void setCurrentSpectrumIndex(Size index)
Set the index of the current spectrum (1D view)
Definition: LayerData.h:326
OpenMS::LayerData::setPeakData
void setPeakData(ExperimentSharedPtrType p)
Set the current in-memory peak data.
Definition: LayerData.h:237
OpenMS::LayerData::consensus
ConsensusMapSharedPtrType consensus
consensus feature data
Definition: LayerData.h:478
OpenMS::LayerData::type
DataType type
data type (peak or feature data)
Definition: LayerData.h:411
OpenMS::LayerData::LabelType
LabelType
Label used in visualization.
Definition: LayerData.h:120
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
OnDiscMSExperiment.h
OpenMS::LayerData::getAnnotations
const Annotations1DContainer & getAnnotations(Size spectrum_index) const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:280
OpenMS::LayerData::F_HULL
Features: Overall convex hull.
Definition: LayerData.h:105
OpenMS::LayerData::ODExperimentSharedPtrType
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:154
StandardTypes.h
OpenMS::LayerData::getCurrentAnnotations
Annotations1DContainer & getCurrentAnnotations()
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:274
OpenMS::LayerData::P_PRECURSORS
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerData.h:108
OpenMS::Annotations1DContainer
Container for annotations to content of Spectrum1DCanvas.
Definition: Annotations1DContainer.h:53
OpenMS::LayerData::isDIAData
bool isDIAData() const
Check whether the current layer contains DIA (SWATH-MS) data.
Definition: LayerData.h:346
OpenMS::LayerData::DT_CHROMATOGRAM
Chromatogram data.
Definition: LayerData.h:95
OpenMS::LayerData::synchronizePeakAnnotations
void synchronizePeakAnnotations()
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:55