OpenMS  2.7.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-2021.
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 
41 
44 
53 
54 #include <boost/shared_ptr.hpp>
55 
56 #include <vector>
57 #include <bitset>
58 
59 class QWidget;
60 
61 namespace OpenMS
62 {
63 
64  class OnDiscMSExperiment;
65  class OSWData;
66 
95  class OPENMS_GUI_DLLAPI LayerData
96  {
97 public:
102  enum DataType
103  {
109  DT_UNKNOWN
110  };
111 
113  enum Flags
114  {
123  SIZE_OF_FLAGS
124  };
125 
127  std::bitset<SIZE_OF_FLAGS> flags;
128 
131  {
137  SIZE_OF_LABEL_TYPE
138  };
139 
141  static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
142 
145 
147  typedef boost::shared_ptr<FeatureMap > FeatureMapSharedPtrType;
148 
151 
153  typedef boost::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
154 
157 
159  typedef boost::shared_ptr<ExperimentType> ExperimentSharedPtrType;
160 
161  typedef boost::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
162 
164  typedef boost::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
165 
167  typedef boost::shared_ptr<OSWData> OSWDataSharedPtrType;
168 
170 
173 
175  LayerData(const LayerData& ld) = delete;
177  LayerData& operator=(const LayerData& ld) = delete;
178 
180  LayerData(LayerData&& ld) = default;
181 
183  LayerData& operator=(LayerData&& ld) = default;
184 
187  {
188  return features_;
189  }
190 
193  {
194  return features_;
195  }
196 
199  {
200  return consensus_map_;
201  }
202 
205  {
206  return consensus_map_;
207  }
208 
219 
229  const ExperimentSharedPtrType & getPeakDataMuteable() {return peak_map_;}
230 
235  {
236  peak_map_ = p;
237  updateCache_();
238  }
239 
242  {
243  on_disc_peaks = p;
244  }
245 
248  {
249  return on_disc_peaks;
250  }
251 
254  {
255  return chromatogram_map_;
256  }
257 
260  {
261  return chromatogram_map_;
262  }
263 
267 
271 
274 
278  bool annotate(const std::vector<PeptideIdentification>& identifications,
279  const std::vector<ProteinIdentification>& protein_identifications);
280 
281 
284  {
285  return annotations_1d[current_spectrum_idx_];
286  }
287 
290  {
291  return annotations_1d[current_spectrum_idx_];
292  }
293 
295  const Annotations1DContainer & getAnnotations(Size spectrum_index) const
296  {
297  return annotations_1d[spectrum_index];
298  }
299 
302  {
303  return annotations_1d[spectrum_index];
304  }
305 
312 
314  {
315  cached_spectrum_.sortByPosition();
316  }
317 
319  const ExperimentType::SpectrumType getSpectrum(Size spectrum_idx) const;
320 
323  {
324  return current_spectrum_idx_;
325  }
326 
329  {
330  current_spectrum_idx_ = index;
331  updateCache_();
332  }
333 
334 
339  {
340  ExperimentSharedPtrType exp_sptr(getChromatogramData().get() == nullptr ||
341  getChromatogramData().get()->getNrChromatograms() == 0
342  ? getPeakDataMuteable() : getChromatogramData());
343  return exp_sptr;
344  }
345 
347  bool isIonMobilityData() const
348  {
349  return this->getPeakData()->size() > 0 &&
350  this->getPeakData()->metaValueExists("is_ion_mobility") &&
351  this->getPeakData()->getMetaValue("is_ion_mobility").toBool();
352  }
353 
355  {
356  peak_map_->setMetaValue("is_ion_mobility", "true");
357  }
358 
360  bool isDIAData() const
361  {
362  return this->getPeakData()->size() > 0 &&
363  this->getPeakData()->metaValueExists("is_dia_data") &&
364  this->getPeakData()->getMetaValue("is_dia_data").toBool();
365  }
366 
369  {
370  peak_map_->setMetaValue("is_dia_data", "true");
371  }
372 
382  {
383  return this->getPeakData()->size() > 0 &&
384  this->getPeakData()->metaValueExists("is_chromatogram") &&
385  this->getPeakData()->getMetaValue("is_chromatogram").toBool();
386  }
387 
390  {
391  peak_map_->setMetaValue("is_chromatogram", "true");
392  }
393 
396  {
397  if (this->chromatogram_flag_set())
398  {
399  peak_map_->removeMetaValue("is_chromatogram");
400  }
401  }
402 
409  void updateRanges();
410 
412  float getMinIntensity() const;
413 
415  float getMaxIntensity() const;
416 
420 
422  void removePeakAnnotationsFromPeptideHit(const std::vector<Annotation1DItem*>& selected_annotations);
423 
425  bool visible;
426 
428  bool flipped;
429 
432 
433  private:
436 
437  public:
438  const String& getName() const
439  {
440  return name_;
441  }
442  void setName(const String& new_name)
443  {
444  name_ = new_name;
445  }
446 
449 
451  std::vector<PeptideIdentification> peptides;
452 
455 
458 
461 
463  std::vector<Annotations1DContainer> annotations_1d;
464 
466  std::vector<QColor> peak_colors_1d;
467 
470 
472  bool modified;
473 
476 
480 
483 
484 private:
486  void updateCache_();
487 
490 
493 
496 
499 
502 
505 
508 
511 
514  };
515 
519  {
520  public:
528  LayerAnnotatorBase(const FileTypes::FileTypeList& supported_types, const String& file_dialog_text, QWidget* gui_lock);
529 
534  bool annotateWithFileDialog(LayerData& layer, LogWindow& log, const String& current_path) const;
535 
539  bool annotateWithFilename(LayerData& layer, LogWindow& log, const String& filename) const;
540 
544  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const FileTypes::Type& type);
545 
547  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const String& filename);
548 
549  protected:
552  virtual bool annotateWorker_(LayerData& layer, const String& filename, LogWindow& log) const = 0;
553 
556  QWidget* gui_lock_ = nullptr;
557  };
558 
562  : public LayerAnnotatorBase
563  {
564  public:
567  "Select peptide identification data", gui_lock)
568  {}
569 
570  protected:
573  virtual bool annotateWorker_(LayerData& layer, const String& filename, LogWindow& log) const;
574  };
575 
579  : public LayerAnnotatorBase
580  {
581  public:
583  : LayerAnnotatorBase(std::vector<FileTypes::Type>{ FileTypes::FEATUREXML },
584  "Select AccurateMassSearch's featureXML file", gui_lock)
585  {}
586 
587  protected:
590  virtual bool annotateWorker_(LayerData& layer, const String& filename, LogWindow& log) const;
591  };
592 
596  : public LayerAnnotatorBase
597  {
598  public:
600  : LayerAnnotatorBase(std::vector<FileTypes::Type>{ FileTypes::OSW },
601  "Select OpenSwath/pyProphet output file", gui_lock)
602  {}
603 
604  protected:
607  virtual bool annotateWorker_(LayerData& layer, const String& filename, LogWindow& log) const;
608  };
609 
611  OPENMS_GUI_DLLAPI std::ostream& operator<<(std::ostream & os, const LayerData & rhs);
612 
613 } //namespace
614 
Container for annotations to content of Plot1DCanvas.
Definition: Annotations1DContainer.h:55
A container for consensus elements.
Definition: ConsensusMap.h:88
DataFilter array providing some convenience functions.
Definition: DataFilters.h:51
A container for features.
Definition: FeatureMap.h:105
holds a vector of known file types, e.g. as a way to specify supported input formats
Definition: FileTypes.h:134
Definition: LayerData.h:580
virtual bool annotateWorker_(LayerData &layer, const String &filename, LogWindow &log) const
LayerAnnotatorAMS(QWidget *gui_lock)
Definition: LayerData.h:582
Definition: LayerData.h:519
QWidget * gui_lock_
optional widget which will be locked when calling annotateWorker_() in child-classes
Definition: LayerData.h:556
const FileTypes::FileTypeList supported_types_
Definition: LayerData.h:554
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const FileTypes::Type &type)
bool annotateWithFileDialog(LayerData &layer, LogWindow &log, const String &current_path) const
virtual bool annotateWorker_(LayerData &layer, const String &filename, LogWindow &log) const =0
bool annotateWithFilename(LayerData &layer, LogWindow &log, const String &filename) const
LayerAnnotatorBase(const FileTypes::FileTypeList &supported_types, const String &file_dialog_text, QWidget *gui_lock)
C'tor with params.
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const String &filename)
see getAnnotatorWhichSupports(const FileTypes::Type& type). Filetype is queried from filename
const String file_dialog_text_
Definition: LayerData.h:555
Definition: LayerData.h:597
LayerAnnotatorOSW(QWidget *gui_lock)
Definition: LayerData.h:599
virtual bool annotateWorker_(LayerData &layer, const String &filename, LogWindow &log) const
Definition: LayerData.h:563
virtual bool annotateWorker_(LayerData &layer, const String &filename, LogWindow &log) const
LayerAnnotatorPeptideID(QWidget *gui_lock)
Definition: LayerData.h:565
Class that stores the data for one layer.
Definition: LayerData.h:96
void remove_chromatogram_flag()
remove the chromatogram flag
Definition: LayerData.h:395
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerData.h:159
const OSWDataSharedPtrType & getChromatogramAnnotation() const
const Annotations1DContainer & getAnnotations(Size spectrum_index) const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:295
const ExperimentSharedPtrType & getChromatogramData() const
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:253
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerData.h:156
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerData.h:164
LayerData & operator=(const LayerData &ld)=delete
no assignment operator (should not be needed)
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.
Size getCurrentSpectrumIndex() const
Get the index of the current spectrum (1D view)
Definition: LayerData.h:322
bool annotate(const std::vector< PeptideIdentification > &identifications, const std::vector< ProteinIdentification > &protein_identifications)
LabelType
Label used in visualization.
Definition: LayerData.h:131
@ L_ID_ALL
All peptide hits of the first identification run are used.
Definition: LayerData.h:136
@ L_ID
The best peptide hit of the first identification run is used.
Definition: LayerData.h:135
@ L_NONE
No label is displayed.
Definition: LayerData.h:132
@ L_META_LABEL
The 'label' meta information is used.
Definition: LayerData.h:134
@ L_INDEX
The element number is used.
Definition: LayerData.h:133
float getMaxIntensity() const
Returns the maximum intensity of the internal data, depending on type.
float getMinIntensity() const
Returns the minimum intensity of the internal data, depending on type.
void setCurrentSpectrumIndex(Size index)
Set the index of the current spectrum (1D view)
Definition: LayerData.h:328
bool isDIAData() const
Check whether the current layer contains DIA (SWATH-MS) data.
Definition: LayerData.h:360
void set_chromatogram_flag()
set the chromatogram flag
Definition: LayerData.h:389
std::vector< PeptideIdentification > peptides
peptide identifications
Definition: LayerData.h:451
std::vector< Annotations1DContainer > annotations_1d
Annotations of all spectra of the experiment (1D view)
Definition: LayerData.h:463
String name_
layer name
Definition: LayerData.h:435
ExperimentSharedPtrType peak_map_
peak data
Definition: LayerData.h:498
void setOnDiscPeakData(ODExperimentSharedPtrType p)
Set the current on-disc data.
Definition: LayerData.h:241
bool modified
Flag that indicates that the layer data was modified since loading it.
Definition: LayerData.h:472
void removePeakAnnotationsFromPeptideHit(const std::vector< Annotation1DItem * > &selected_annotations)
remove peak annotations in the given list from the currently active PeptideHit
const ConstExperimentSharedPtrType getPeakData() const
Returns a const reference to the current in-memory peak data.
bool isIonMobilityData() const
Check whether the current layer should be represented as ion mobility.
Definition: LayerData.h:347
void setChromatogramAnnotation(OSWData &&data)
add annotation from an OSW sqlite file.
ConsensusMap ConsensusMapType
consensus features
Definition: LayerData.h:150
const FeatureMapSharedPtrType & getFeatureMap() const
Returns a const reference to the current feature data.
Definition: LayerData.h:186
OSWDataSharedPtrType & getChromatogramAnnotation()
DataFilters filters
Filters to apply before painting.
Definition: LayerData.h:460
const ExperimentSharedPtrType & getPeakDataMuteable()
Returns a mutable reference to the current in-memory peak data.
Definition: LayerData.h:229
bool chromatogram_flag_set() const
Check whether the current layer is a chromatogram.
Definition: LayerData.h:381
void setPeakData(ExperimentSharedPtrType p)
Set the current in-memory peak data.
Definition: LayerData.h:234
ExperimentSharedPtrType chromatogram_map_
chromatogram data
Definition: LayerData.h:504
FeatureMapSharedPtrType features_
feature data
Definition: LayerData.h:492
ODExperimentSharedPtrType on_disc_peaks
on disc peak data
Definition: LayerData.h:501
LayerData(LayerData &&ld)=default
move Ctor
const ODExperimentSharedPtrType & getOnDiscPeakData() const
Returns a mutable reference to the on-disc data.
Definition: LayerData.h:247
Size current_spectrum_idx_
Index of the current spectrum.
Definition: LayerData.h:510
void labelAsIonMobilityData() const
Definition: LayerData.h:354
const ConsensusMapSharedPtrType & getConsensusMap() const
Returns a const reference to the consensus feature data.
Definition: LayerData.h:198
void sortCurrentSpectrumByPosition()
Definition: LayerData.h:313
ConsensusMapSharedPtrType consensus_map_
consensus feature data
Definition: LayerData.h:495
FeatureMapSharedPtrType & getFeatureMap()
Returns a const reference to the current feature data.
Definition: LayerData.h:192
void synchronizePeakAnnotations()
bool modifiable
Flag that indicates if the layer data can be modified (so far used for features only)
Definition: LayerData.h:469
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerData.h:127
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerData.h:161
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerData.h:153
ExperimentSharedPtrType & getChromatogramData()
Returns a mutable reference to the current chromatogram data.
Definition: LayerData.h:259
void updatePeptideHitAnnotations_(PeptideHit &hit)
updates the PeakAnnotations in the current PeptideHit with manually changed annotations
bool visible
if this layer is visible
Definition: LayerData.h:425
Flags
Flags that determine which information is shown.
Definition: LayerData.h:114
@ I_PEPTIDEMZ
Identifications: m/z source.
Definition: LayerData.h:121
@ F_HULL
Features: Overall convex hull.
Definition: LayerData.h:115
@ F_UNASSIGNED
Features: Unassigned peptide hits.
Definition: LayerData.h:117
@ P_PRECURSORS
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerData.h:118
@ I_LABELS
Identifications: Show labels (not sequences)
Definition: LayerData.h:122
@ P_PROJECTIONS
Peaks: Show projections.
Definition: LayerData.h:119
@ C_ELEMENTS
Consensus features: Show elements.
Definition: LayerData.h:120
@ F_HULLS
Features: Convex hulls of single mass traces.
Definition: LayerData.h:116
LayerData(const LayerData &ld)=delete
no Copy-ctor (should not be needed)
LayerData()
Default constructor.
const String & getName() const
Definition: LayerData.h:438
LabelType label
Label type.
Definition: LayerData.h:475
void updateCache_()
Update current cached spectrum for easy retrieval.
DataType type
data type (peak or feature data)
Definition: LayerData.h:431
Annotations1DContainer & getCurrentAnnotations()
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:289
ConsensusMapSharedPtrType & getConsensusMap()
Returns current consensus map (mutable)
Definition: LayerData.h:204
OSWDataSharedPtrType chrom_annotation_
Chromatogram annotation data.
Definition: LayerData.h:507
const Annotations1DContainer & getCurrentAnnotations() const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:283
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerData.h:457
Param param
Layer parameters.
Definition: LayerData.h:454
LayerData & operator=(LayerData &&ld)=default
move assignment
DataType
Definition: LayerData.h:103
@ DT_FEATURE
Feature data.
Definition: LayerData.h:106
@ DT_PEAK
Spectrum profile or centroided data.
Definition: LayerData.h:104
@ DT_CONSENSUS
Consensus feature data.
Definition: LayerData.h:107
@ DT_CHROMATOGRAM
Chromatogram data.
Definition: LayerData.h:105
@ DT_IDENT
Peptide identification data.
Definition: LayerData.h:108
ExperimentSharedPtrType getFullChromData()
Definition: LayerData.h:338
FeatureMap FeatureMapType
Features.
Definition: LayerData.h:144
void updateRanges()
Update ranges of all data structures.
String filename
file name of the file the data comes from (if available)
Definition: LayerData.h:448
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerData.h:167
ExperimentType::SpectrumType cached_spectrum_
Current cached spectrum.
Definition: LayerData.h:513
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerData.h:147
int peptide_hit_index
Definition: LayerData.h:479
const ExperimentType::SpectrumType & getCurrentSpectrum() const
Returns a const reference to the current spectrum (1D view)
void setName(const String &new_name)
Definition: LayerData.h:442
String getDecoratedName() const
get name augmented with attributes, e.g. [flipped], or '*' if modified
void labelAsDIAData()
Label the current layer as DIA (SWATH-MS) data.
Definition: LayerData.h:368
bool flipped
if this layer is flipped (1d mirror view)
Definition: LayerData.h:428
Annotations1DContainer & getAnnotations(Size spectrum_index)
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData.h:301
std::vector< QColor > peak_colors_1d
Peak colors of the currently shown spectrum.
Definition: LayerData.h:466
int peptide_id_index
Selected peptide id and hit index (-1 if none is selected)
Definition: LayerData.h:478
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:55
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:68
Holds all or partial information from an OSW file.
Definition: OSWData.h:305
Management and storage of parameters / INI files.
Definition: Param.h:70
Representation of a peptide hit.
Definition: PeptideHit.h:57
A more convenient string class.
Definition: String.h:61
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
const FileTypes::FileTypeList supported_types({ FileTypes::MZML, FileTypes::MZXML, FileTypes::MZDATA, FileTypes::SQMASS, FileTypes::FEATUREXML, FileTypes::CONSENSUSXML, FileTypes::IDXML, FileTypes::DTA, FileTypes::DTA2D, FileTypes::MGF, FileTypes::MS2, FileTypes::MSP, FileTypes::BZ2, FileTypes::GZ })
supported types which can be opened with File–>Open
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Centralizes the file types recognized by FileHandler.
Definition: FileTypes.h:53
Type
Actual file types enum.
Definition: FileTypes.h:57
@ MZIDENTML
mzIdentML (HUPO PSI AnalysisXML followup format) (.mzid)
Definition: FileTypes.h:75
@ FEATUREXML
OpenMS feature file (.featureXML)
Definition: FileTypes.h:63
@ IDXML
OpenMS identification format (.idXML)
Definition: FileTypes.h:64
@ OSW
OpenSWATH OpenSWATH report (OSW) SQLite DB.
Definition: FileTypes.h:104