OpenMS  2.4.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-2018.
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
92  {
99  };
100 
102  enum Flags
103  {
113  };
114 
116  std::bitset<SIZE_OF_FLAGS> flags;
117 
120  {
127  };
128 
130  static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
131 
134 
136  typedef boost::shared_ptr<FeatureMap > FeatureMapSharedPtrType;
137 
140 
142  typedef boost::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
143 
146 
148  typedef boost::shared_ptr<ExperimentType> ExperimentSharedPtrType;
149 
150  typedef boost::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
151 
153  typedef boost::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
154 
156 
159  flags(),
160  visible(true),
161  flipped(false),
162  type(DT_UNKNOWN),
163  name(),
164  filename(),
165  peptides(),
166  param(),
167  gradient(),
168  filters(),
169  annotations_1d(),
170  peak_colors_1d(),
171  modifiable(false),
172  modified(false),
173  label(L_NONE),
174  peptide_id_index(-1),
175  peptide_hit_index(-1),
176  features(new FeatureMapType()),
178  peaks(new ExperimentType()),
183  {
184  annotations_1d.resize(1);
185  }
186 
189  {
190  return features;
191  }
192 
195  {
196  return features;
197  }
198 
201  {
202  return consensus;
203  }
204 
207  {
208  return consensus;
209  }
210 
221 
232 
237  {
238  peaks = p;
239  updateCache_();
240  }
241 
244  {
245  on_disc_peaks = p;
246  }
247 
250  {
251  return on_disc_peaks;
252  }
253 
256  {
257  return chromatograms;
258  }
259 
262  {
263  return chromatograms;
264  }
265 
268  {
270  }
271 
274  {
276  }
277 
279  const Annotations1DContainer & getAnnotations(Size spectrum_index) const
280  {
281  return annotations_1d[spectrum_index];
282  }
283 
286  {
287  return annotations_1d[spectrum_index];
288  }
289 
296 
298  {
300  }
301 
304  {
305  if (spectrum_idx == current_spectrum_) return cached_spectrum_;
306 
307  if ((*peaks)[spectrum_idx].size() > 0)
308  {
309  return (*peaks)[spectrum_idx];
310  }
311  else if (!on_disc_peaks->empty())
312  {
313  return on_disc_peaks->getSpectrum(spectrum_idx);
314  }
315  return (*peaks)[spectrum_idx];
316  }
317 
320  {
321  return current_spectrum_;
322  }
323 
326  {
327  current_spectrum_ = index;
328  updateCache_();
329  }
330 
332  bool isIonMobilityData() const
333  {
334  return this->getPeakData()->size() > 0 &&
335  this->getPeakData()->metaValueExists("is_ion_mobility") &&
336  this->getPeakData()->getMetaValue("is_ion_mobility").toBool();
337  }
338 
340  {
341  peaks->setMetaValue("is_ion_mobility", "true");
342  }
343 
345  bool isDIAData() const
346  {
347  return this->getPeakData()->size() > 0 &&
348  this->getPeakData()->metaValueExists("is_dia_data") &&
349  this->getPeakData()->getMetaValue("is_dia_data").toBool();
350  }
351 
354  {
355  peaks->setMetaValue("is_dia_data", "true");
356  }
357 
367  {
368  return this->getPeakData()->size() > 0 &&
369  this->getPeakData()->metaValueExists("is_chromatogram") &&
370  this->getPeakData()->getMetaValue("is_chromatogram").toBool();
371  }
372 
375  {
376  peaks->setMetaValue("is_chromatogram", "true");
377  }
378 
381  {
382  if (this->chromatogram_flag_set())
383  {
384  peaks->removeMetaValue("is_chromatogram");
385  }
386  }
387 
394  void updateRanges();
395 
399 
401  void removePeakAnnotationsFromPeptideHit(const std::vector<Annotation1DItem*>& selected_annotations);
402 
404  bool visible;
405 
407  bool flipped;
408 
411 
414 
417 
419  std::vector<PeptideIdentification> peptides;
420 
423 
426 
429 
431  std::vector<Annotations1DContainer> annotations_1d;
432 
434  std::vector<QColor> peak_colors_1d;
435 
438 
440  bool modified;
441 
444 
448 
449 private:
450 
452  void updateCache_();
453 
456 
459 
462 
465 
468 
471 
474 
477 
478  };
479 
481  OPENMS_GUI_DLLAPI std::ostream & operator<<(std::ostream & os, const LayerData & rhs);
482 
483 } //namespace
484 
Flags
Flags that determine which information is shown.
Definition: LayerData.h:102
const Annotations1DContainer & getAnnotations(Size spectrum_index) const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:279
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:136
void removePeakAnnotationsFromPeptideHit(const std::vector< Annotation1DItem *> &selected_annotations)
remove peak annotations in the given list from the currently active PeptideHit
Consensus features: Show elements.
Definition: LayerData.h:109
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerData.h:130
Features: Convex hulls of single mass traces.
Definition: LayerData.h:105
FeatureMapSharedPtrType features
feature data
Definition: LayerData.h:458
bool isDIAData() const
Check whether the current layer contains DIA (SWATH-MS) data.
Definition: LayerData.h:345
ExperimentType::SpectrumType cached_spectrum_
Current cached spectrum.
Definition: LayerData.h:476
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerData.h:116
Features: Overall convex hull.
Definition: LayerData.h:104
Definition: LayerData.h:112
A more convenient string class.
Definition: String.h:58
LabelType label
Label type.
Definition: LayerData.h:443
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerData.h:145
void sortByPosition()
Lexicographically sorts the peaks by their position.
const ExperimentType::SpectrumType & getCurrentSpectrum() const
Returns a const reference to the current spectrum (1D view)
void synchronizePeakAnnotations()
DataType
Dataset types.
Definition: LayerData.h:91
bool modified
Flag that indicates that the layer data was modified since loading it.
Definition: LayerData.h:440
A container for features.
Definition: FeatureMap.h:93
FeatureMapSharedPtrType & getFeatureMap()
Returns a const reference to the current feature data.
Definition: LayerData.h:194
void updateRanges()
Update ranges of all data structures.
void remove_chromatogram_flag()
remove the chromatogram flag
Definition: LayerData.h:380
bool isIonMobilityData() const
Check whether the current layer should be represented as ion mobility.
Definition: LayerData.h:332
All peptide hits of the first identification run are used.
Definition: LayerData.h:125
A container for consensus elements.
Definition: ConsensusMap.h:75
Undefined data type indicating an error.
Definition: LayerData.h:98
void setOnDiscPeakData(ODExperimentSharedPtrType p)
Set the current on-disc data.
Definition: LayerData.h:243
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerData.h:150
Peptide identification data.
Definition: LayerData.h:97
void updateCache_()
Update current cached spectrum for easy retrieval.
ODExperimentSharedPtrType on_disc_peaks
on disc peak data
Definition: LayerData.h:467
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void labelAsDIAData()
Label the current layer as DIA (SWATH-MS) data.
Definition: LayerData.h:353
Annotations1DContainer & getCurrentAnnotations()
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:273
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:148
bool chromatogram_flag_set() const
Check whether the current layer is a chromatogram.
Definition: LayerData.h:366
Chromatogram data.
Definition: LayerData.h:96
std::vector< Annotations1DContainer > annotations_1d
Annotations of all spectra of the experiment (1D view)
Definition: LayerData.h:431
const ExperimentSharedPtrType & getChromatogramData() const
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:255
MSSpectrum SpectrumType
Spectrum Type.
Definition: MSExperiment.h:101
The &#39;label&#39; meta information is used.
Definition: LayerData.h:123
String name
layer name
Definition: LayerData.h:413
bool flipped
if this layer is flipped (1d mirror view)
Definition: LayerData.h:407
ExperimentSharedPtrType & getChromatogramData()
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:261
const Annotations1DContainer & getCurrentAnnotations() const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:267
ExperimentSharedPtrType chromatograms
chromatogram data
Definition: LayerData.h:470
Representation of a mass spectrometry experiment on disk.
Definition: OnDiscMSExperiment.h:68
Param param
Layer parameters.
Definition: LayerData.h:422
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
const FeatureMapSharedPtrType & getFeatureMap() const
Returns a const reference to the current feature data.
Definition: LayerData.h:188
Feature data.
Definition: LayerData.h:94
Annotations1DContainer & getAnnotations(Size spectrum_index)
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:285
const ConstExperimentSharedPtrType getPeakData() const
Returns a const reference to the current in-memory peak data.
void labelAsIonMobilityData() const
Definition: LayerData.h:339
Representation of a peptide hit.
Definition: PeptideHit.h:54
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:142
Consensus feature data.
Definition: LayerData.h:95
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
ConsensusMapSharedPtrType & getConsensusMap()
Returns current consensus map (mutable)
Definition: LayerData.h:206
std::vector< QColor > peak_colors_1d
Peak colors of the currently shown spectrum.
Definition: LayerData.h:434
String filename
file name of the file the data comes from (if available)
Definition: LayerData.h:416
Size current_spectrum_
Index of the current spectrum.
Definition: LayerData.h:473
void set_chromatogram_flag()
set the chromatogram flag
Definition: LayerData.h:374
ExperimentSharedPtrType peaks
peak data
Definition: LayerData.h:464
ConsensusMap ConsensusMapType
consensus features
Definition: LayerData.h:139
Management and storage of parameters / INI files.
Definition: Param.h:74
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
Peaks: Show projections.
Definition: LayerData.h:108
bool modifiable
Flag that indicates if the layer data can be modified (so far used for features only) ...
Definition: LayerData.h:437
int peptide_hit_index
Definition: LayerData.h:447
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerData.h:107
void setCurrentSpectrumIndex(Size index)
Set the index of the current spectrum (1D view)
Definition: LayerData.h:325
int peptide_id_index
Selected peptide id and hit index (-1 if none is selected)
Definition: LayerData.h:446
void setPeakData(ExperimentSharedPtrType p)
Set the current in-memory peak data.
Definition: LayerData.h:236
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:153
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< PeptideIdentification > peptides
peptide identifications
Definition: LayerData.h:419
const ConsensusMapSharedPtrType & getConsensusMap() const
Returns a const reference to the consensus feature data.
Definition: LayerData.h:200
DataFilters filters
Filters to apply before painting.
Definition: LayerData.h:428
LayerData()
Default constructor.
Definition: LayerData.h:158
DataType type
data type (peak or feature data)
Definition: LayerData.h:410
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:303
LabelType
Label used in visualization.
Definition: LayerData.h:119
const ODExperimentSharedPtrType & getOnDiscPeakData() const
Returns a mutable reference to the on-disc data.
Definition: LayerData.h:249
const ExperimentSharedPtrType & getPeakDataMuteable()
Returns a mutable reference to the current in-memory peak data.
Definition: LayerData.h:231
The best peptide hit of the first identification run is used.
Definition: LayerData.h:124
Spectrum profile or centroided data.
Definition: LayerData.h:93
DataFilter array providing some convenience functions.
Definition: DataFilters.h:50
void sortCurrentSpectrumByPosition()
Definition: LayerData.h:297
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
The element number is used.
Definition: LayerData.h:122
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerData.h:425
Size getCurrentSpectrumIndex() const
Get the index of the current spectrum (1D view)
Definition: LayerData.h:319
Container for annotations to content of Spectrum1DCanvas.
Definition: Annotations1DContainer.h:53
No label is displayed.
Definition: LayerData.h:121
ConsensusMapSharedPtrType consensus
consensus feature data
Definition: LayerData.h:461
Features: Unassigned peptide hits.
Definition: LayerData.h:106
Identifications: Show labels (not sequences)
Definition: LayerData.h:111
bool visible
if this layer is visible
Definition: LayerData.h:404
Definition: LayerData.h:126
Class that stores the data for one layer.
Definition: LayerData.h:85
void updatePeptideHitAnnotations_(PeptideHit &hit)
updates the PeakAnnotations in the current PeptideHit with manually changed annotations ...
Identifications: m/z source.
Definition: LayerData.h:110
FeatureMap FeatureMapType
Features.
Definition: LayerData.h:133