OpenMS
LayerDataBase.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
26 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
27 
28 #include <boost/shared_ptr.hpp>
29 
30 #include <bitset>
31 #include <vector>
32 
33 class QWidget;
34 
35 namespace OpenMS
36 {
37  class LayerData1DBase;
38  class LayerStoreData;
39  class LayerStatistics;
40  class OSWData;
41  class Painter1DBase;
42  class Painter2DBase;
43 
44  template <int N_DIM> class DimMapper;
45 
47  {
48 
51  {
57  ~ProjectionData(); // needs to be implemented in cpp, since inline would require a full definition of LayerData1DBase;
58 
59  std::unique_ptr<LayerData1DBase> projection_ontoX;
60  std::unique_ptr<LayerData1DBase> projection_ontoY;
61  struct Summary {
64  double sum_intensity {0}; // double since sum could get large
65  } stats;
66  };
67 
72  enum DataType
73  {
79  DT_UNKNOWN
80  };
81 
83  enum Flags
84  {
94  };
95 
97  enum LabelType
98  {
105  };
106 
108  static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
109 
112 
114  typedef boost::shared_ptr<FeatureMap> FeatureMapSharedPtrType;
115 
118 
120  typedef boost::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
121 
124 
126  typedef boost::shared_ptr<ExperimentType> ExperimentSharedPtrType;
127 
128  typedef boost::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
129 
131  typedef boost::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
132 
134  typedef boost::shared_ptr<OSWData> OSWDataSharedPtrType;
135  };
136 
165 #ifdef _MSC_VER
166  #pragma warning(disable : 4250) // 'class1' : inherits 'class2::member' via dominance
167 #endif
168  class OPENMS_GUI_DLLAPI LayerDataBase : public LayerDataDefs
169  {
170  public:
172  std::bitset<SIZE_OF_FLAGS> flags;
173 
175 
177  LayerDataBase() = delete; // <-- this is the problem. Call assignment op in 1DPeak???
179  explicit LayerDataBase(const DataType type) : type(type) {}
181  LayerDataBase(const LayerDataBase& ld) = default;
183  LayerDataBase& operator=(const LayerDataBase& ld) = delete;
187  LayerDataBase(LayerDataBase&& ld) = delete;
191  virtual ~LayerDataBase() = default;
192 
197  virtual std::unique_ptr<Painter2DBase> getPainter2D() const = 0;
198 
199 
204  virtual std::unique_ptr <LayerData1DBase> to1DLayer() const = 0;
205 
207  virtual std::unique_ptr<LayerStoreData> storeVisibleData(const RangeAllType& /*visible_range*/, const DataFilters& /*layer_filters*/) const
208  {
209  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
210  }
212  virtual std::unique_ptr<LayerStoreData> storeFullData() const
213  {
214  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
215  }
216 
220  // todo: put this into a LayerData2DBase class, since a LayerData1DPeak should not implement this.
221  virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType& area) const = 0;
222 
228  virtual PeakIndex findClosestDataPoint(const RangeAllType& area) const
229  {
230  (void)area; // allow doxygen to document the param
231  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
232  }
233 
239  virtual PeakIndex findHighestDataPoint(const RangeAllType& area) const
240  {
241  (void)area; // allow doxygen to document the param
242  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
243  }
244 
245 
252  virtual PointXYType peakIndexToXY(const PeakIndex& peak, const DimMapper<2>& mapper) const = 0;
253 
262  virtual String getDataArrayDescription(const PeakIndex& peak_index)
263  {
264  (void)peak_index; // allow doxygen to document the param
265  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
266  }
267 
271  virtual bool annotate(const std::vector<PeptideIdentification>& identifications,
272  const std::vector<ProteinIdentification>& protein_identifications);
273 
274 
278  virtual void updateRanges() = 0;
279 
281  float getMinIntensity() const;
282 
284  float getMaxIntensity() const;
285 
287 
291  virtual RangeAllType getRange() const = 0;
292 
294  virtual std::unique_ptr<LayerStatistics> getStats() const = 0;
295 
297  const String& getName() const
298  {
299  return name_;
300  }
302  void setName(const String& new_name)
303  {
304  name_ = new_name;
305  }
306 
308  const String& getNameSuffix() const
309  {
310  return name_suffix_;
311  }
313  void setNameSuffix(const String& decorator)
314  {
315  name_suffix_ = decorator;
316  }
317 
319  virtual String getDecoratedName() const;
320 
322  bool visible = true;
323 
325  DataType type = DT_UNKNOWN;
326 
329 
332 
335 
338 
340  bool modifiable = false;
341 
343  bool modified = false;
344 
346  LabelType label = L_NONE;
347 
349  int peptide_id_index = -1;
350  int peptide_hit_index = -1;
351 
352  private:
357  };
358 
363  {
364  public:
372  LayerAnnotatorBase(const FileTypeList& supported_types, const String& file_dialog_text, QWidget* gui_lock);
373 
375  virtual ~LayerAnnotatorBase() = default;
376 
381  bool annotateWithFileDialog(LayerDataBase& layer, LogWindow& log, const String& current_path) const;
382 
386  bool annotateWithFilename(LayerDataBase& layer, LogWindow& log, const String& filename) const;
387 
391  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const FileTypes::Type& type);
392 
394  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const String& filename);
395 
396  protected:
399  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const = 0;
400 
403  QWidget* gui_lock_ = nullptr;
404  };
405 
409  {
410  public:
413  "Select peptide identification data", gui_lock)
414  {
415  }
416 
417  protected:
420  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
421  };
422 
426  {
427  public:
430  "Select AccurateMassSearch's featureXML file", gui_lock)
431  {
432  }
433 
434  protected:
437  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
438  };
439 
443  {
444  public:
446  LayerAnnotatorBase(std::vector<FileTypes::Type>{FileTypes::OSW},
447  "Select OpenSwath/pyProphet output file", gui_lock)
448  {
449  }
450 
451  protected:
454  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
455  };
456 
458  OPENMS_GUI_DLLAPI std::ostream& operator<<(std::ostream& os, const LayerDataBase& rhs);
459 
460 }// namespace OpenMS
461 
A container for consensus elements.
Definition: ConsensusMap.h:66
DataFilter array providing some convenience functions.
Definition: DataFilters.h:27
Not implemented exception.
Definition: Exception.h:399
A container for features.
Definition: FeatureMap.h:80
holds a vector of known file types, e.g. as a way to specify supported input formats
Definition: FileTypes.h:139
Definition: LayerDataBase.h:426
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
LayerAnnotatorAMS(QWidget *gui_lock)
Definition: LayerDataBase.h:428
Definition: LayerDataBase.h:363
QWidget * gui_lock_
optional widget which will be locked when calling annotateWorker_() in child-classes
Definition: LayerDataBase.h:403
virtual ~LayerAnnotatorBase()=default
Make D'tor virtual for correct destruction from pointers to base.
const FileTypeList supported_types_
Definition: LayerDataBase.h:401
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const FileTypes::Type &type)
bool annotateWithFilename(LayerDataBase &layer, LogWindow &log, const String &filename) const
LayerAnnotatorBase(const FileTypeList &supported_types, const String &file_dialog_text, QWidget *gui_lock)
C'tor with params.
bool annotateWithFileDialog(LayerDataBase &layer, LogWindow &log, const String &current_path) const
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const String &filename)
see getAnnotatorWhichSupports(const FileTypes::Type& type). File type is queried from filename
const String file_dialog_text_
Definition: LayerDataBase.h:402
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const =0
Definition: LayerDataBase.h:443
LayerAnnotatorOSW(QWidget *gui_lock)
Definition: LayerDataBase.h:445
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
Definition: LayerDataBase.h:409
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
LayerAnnotatorPeptideID(QWidget *gui_lock)
Definition: LayerDataBase.h:411
Class that stores the data for one layer.
Definition: LayerDataBase.h:169
LayerDataBase & operator=(LayerDataBase &&ld)=delete
Move assignment – deleted, by same argument as for move c'tor.
virtual String getDecoratedName() const
get name augmented with attributes, e.g. '*' if modified
virtual std::unique_ptr< LayerStatistics > getStats() const =0
Compute layer statistics (via visitor)
virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType &area) const =0
LayerDataBase & operator=(const LayerDataBase &ld)=delete
Assignment operator.
float getMaxIntensity() const
Returns the maximum intensity of the internal data, depending on type.
virtual std::unique_ptr< LayerData1DBase > to1DLayer() const =0
Create a shallow copy (i.e. shared experimental data using shared_ptr) of the current layer,...
float getMinIntensity() const
Returns the minimum intensity of the internal data, depending on type.
virtual ~LayerDataBase()=default
D'tor.
String name_
layer name
Definition: LayerDataBase.h:354
const String & getNameSuffix() const
get the extra annotation to the layers name, e.g. '[39]' for which chromatogram index is currently sh...
Definition: LayerDataBase.h:308
virtual std::unique_ptr< Painter2DBase > getPainter2D() const =0
Obtain a painter which can draw the layer on a 2D canvas.
virtual void updateRanges()=0
Update ranges of the underlying data.
DataFilters filters
Filters to apply before painting.
Definition: LayerDataBase.h:337
virtual PointXYType peakIndexToXY(const PeakIndex &peak, const DimMapper< 2 > &mapper) const =0
Convert a PeakIndex to a XY coordinate (via mapper).
String name_suffix_
an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is current...
Definition: LayerDataBase.h:356
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerDataBase.h:172
LayerDataBase()=delete
Default constructor (for virtual inheritance)
LayerDataBase(const DataType type)
C'tor for child classes.
Definition: LayerDataBase.h:179
LayerDataBase(LayerDataBase &&ld)=delete
const String & getName() const
The name of the layer, usually the basename of the file.
Definition: LayerDataBase.h:297
virtual std::unique_ptr< LayerStoreData > storeFullData() const
Returns a visitor which contains the the full data of the layer and can write the data to disk in the...
Definition: LayerDataBase.h:212
virtual String getDataArrayDescription(const PeakIndex &peak_index)
Get name and value of all data-arrays corresponding to the given datapoint.
Definition: LayerDataBase.h:262
virtual RangeAllType getRange() const =0
virtual bool annotate(const std::vector< PeptideIdentification > &identifications, const std::vector< ProteinIdentification > &protein_identifications)
void setNameSuffix(const String &decorator)
set an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is cur...
Definition: LayerDataBase.h:313
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerDataBase.h:334
Param param
Layer parameters.
Definition: LayerDataBase.h:331
String filename
file name of the file the data comes from (if available)
Definition: LayerDataBase.h:328
LayerDataBase(const LayerDataBase &ld)=default
Copy-C'tor.
void setName(const String &new_name)
Set the name of the layer, usually the basename of the file.
Definition: LayerDataBase.h:302
virtual std::unique_ptr< LayerStoreData > storeVisibleData(const RangeAllType &, const DataFilters &) const
Returns a visitor which contains the current visible data and can write the data to disk.
Definition: LayerDataBase.h:207
virtual PeakIndex findClosestDataPoint(const RangeAllType &area) const
Find the closest datapoint within the given range and return a proxy to that datapoint.
Definition: LayerDataBase.h:228
virtual PeakIndex findHighestDataPoint(const RangeAllType &area) const
Find the datapoint with the highest intensity within the given range and return a proxy to that datap...
Definition: LayerDataBase.h:239
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:29
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:45
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:42
Management and storage of parameters / INI files.
Definition: Param.h:44
float IntensityType
Intensity type.
Definition: Peak1D.h:36
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
const 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)
DIM_UNIT
Definition: CommonEnums.h:20
Centralizes the file types recognized by FileHandler.
Definition: FileTypes.h:27
Type
Actual file types enum.
Definition: FileTypes.h:31
@ MZIDENTML
mzIdentML (HUPO PSI AnalysisXML followup format) (.mzid)
Definition: FileTypes.h:49
@ FEATUREXML
OpenMS feature file (.featureXML)
Definition: FileTypes.h:37
@ IDXML
OpenMS identification format (.idXML)
Definition: FileTypes.h:38
@ OSW
OpenSWATH OpenSWATH report (OSW) SQLite DB.
Definition: FileTypes.h:77
Result of computing a projection on X and Y axis in a 2D Canvas; see LayerDataBase::getProjection()
Definition: LayerDataBase.h:51
Peak1D::IntensityType max_intensity
Definition: LayerDataBase.h:63
std::unique_ptr< LayerData1DBase > projection_ontoX
Definition: LayerDataBase.h:59
struct OpenMS::LayerDataDefs::ProjectionData::Summary stats
UInt number_of_datapoints
Definition: LayerDataBase.h:62
ProjectionData(ProjectionData &&)
Move C'tor.
double sum_intensity
Definition: LayerDataBase.h:64
std::unique_ptr< LayerData1DBase > projection_ontoY
Definition: LayerDataBase.h:60
Definition: LayerDataBase.h:47
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:126
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerDataBase.h:123
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:131
LabelType
Label used in visualization.
Definition: LayerDataBase.h:98
@ L_ID_ALL
All peptide hits of the first identification run are used.
Definition: LayerDataBase.h:103
@ L_ID
The best peptide hit of the first identification run is used.
Definition: LayerDataBase.h:102
@ L_NONE
No label is displayed.
Definition: LayerDataBase.h:99
@ L_META_LABEL
The 'label' meta information is used.
Definition: LayerDataBase.h:101
@ SIZE_OF_LABEL_TYPE
Definition: LayerDataBase.h:104
@ L_INDEX
The element number is used.
Definition: LayerDataBase.h:100
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:114
ConsensusMap ConsensusMapType
consensus features
Definition: LayerDataBase.h:117
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerDataBase.h:128
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:120
Flags
Flags that determine which information is shown.
Definition: LayerDataBase.h:84
@ I_PEPTIDEMZ
Identifications: m/z source.
Definition: LayerDataBase.h:91
@ F_HULL
Features: Overall convex hull.
Definition: LayerDataBase.h:85
@ SIZE_OF_FLAGS
Definition: LayerDataBase.h:93
@ F_UNASSIGNED
Features: Unassigned peptide hits.
Definition: LayerDataBase.h:87
@ P_PRECURSORS
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerDataBase.h:88
@ I_LABELS
Identifications: Show labels (not sequences)
Definition: LayerDataBase.h:92
@ P_PROJECTIONS
Peaks: Show projections.
Definition: LayerDataBase.h:89
@ C_ELEMENTS
Consensus features: Show elements.
Definition: LayerDataBase.h:90
@ F_HULLS
Features: Convex hulls of single mass traces.
Definition: LayerDataBase.h:86
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerDataBase.h:108
DataType
Definition: LayerDataBase.h:73
@ DT_FEATURE
Feature data.
Definition: LayerDataBase.h:76
@ DT_PEAK
Spectrum profile or centroided data.
Definition: LayerDataBase.h:74
@ DT_CONSENSUS
Consensus feature data.
Definition: LayerDataBase.h:77
@ DT_CHROMATOGRAM
Chromatogram data.
Definition: LayerDataBase.h:75
@ DT_IDENT
Peptide identification data.
Definition: LayerDataBase.h:78
@ DT_UNKNOWN
Undefined data type indicating an error.
Definition: LayerDataBase.h:79
FeatureMap FeatureMapType
Features.
Definition: LayerDataBase.h:111
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerDataBase.h:134
Index of a peak or feature.
Definition: PeakIndex.h:25