OpenMS
LayerDataBase.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-2023.
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 
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
52 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
53 
54 #include <boost/shared_ptr.hpp>
55 
56 #include <bitset>
57 #include <vector>
58 
59 class QWidget;
60 
61 namespace OpenMS
62 {
63  class LayerData1DBase;
64  class LayerStoreData;
65  class LayerStatistics;
66  class OSWData;
67  class Painter1DBase;
68  class Painter2DBase;
69 
70  template <int N_DIM> class DimMapper;
71 
73  {
74 
77  {
83  ~ProjectionData(); // needs to be implemented in cpp, since inline would require a full definition of LayerData1DBase;
84 
85  std::unique_ptr<LayerData1DBase> projection_ontoX;
86  std::unique_ptr<LayerData1DBase> projection_ontoY;
87  struct Summary {
90  double sum_intensity {0}; // double since sum could get large
91  } stats;
92  };
93 
98  enum DataType
99  {
105  DT_UNKNOWN
106  };
107 
109  enum Flags
110  {
120  };
121 
124  {
131  };
132 
134  static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
135 
138 
140  typedef boost::shared_ptr<FeatureMap> FeatureMapSharedPtrType;
141 
144 
146  typedef boost::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
147 
150 
152  typedef boost::shared_ptr<ExperimentType> ExperimentSharedPtrType;
153 
154  typedef boost::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
155 
157  typedef boost::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
158 
160  typedef boost::shared_ptr<OSWData> OSWDataSharedPtrType;
161  };
162 
191 #ifdef _MSC_VER
192  #pragma warning(disable : 4250) // 'class1' : inherits 'class2::member' via dominance
193 #endif
194  class OPENMS_GUI_DLLAPI LayerDataBase : public LayerDataDefs
195  {
196  public:
198  std::bitset<SIZE_OF_FLAGS> flags;
199 
201 
203  LayerDataBase() = delete; // <-- this is the problem. Call assignment op in 1DPeak???
205  explicit LayerDataBase(const DataType type) : type(type) {}
207  LayerDataBase(const LayerDataBase& ld) = default;
209  LayerDataBase& operator=(const LayerDataBase& ld) = delete;
213  LayerDataBase(LayerDataBase&& ld) = delete;
217  virtual ~LayerDataBase() = default;
218 
223  virtual std::unique_ptr<Painter2DBase> getPainter2D() const = 0;
224 
225 
230  virtual std::unique_ptr <LayerData1DBase> to1DLayer() const = 0;
231 
233  virtual std::unique_ptr<LayerStoreData> storeVisibleData(const RangeAllType& /*visible_range*/, const DataFilters& /*layer_filters*/) const
234  {
235  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
236  }
238  virtual std::unique_ptr<LayerStoreData> storeFullData() const
239  {
240  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
241  }
242 
246  // todo: put this into a LayerData2DBase class, since a LayerData1DPeak should not implement this.
247  virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType& area) const = 0;
248 
254  virtual PeakIndex findClosestDataPoint(const RangeAllType& /*area*/) const
255  {
256  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
257  }
258 
264  virtual PeakIndex findHighestDataPoint(const RangeAllType& /*area*/) const
265  {
266  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
267  }
268 
269 
276  virtual PointXYType peakIndexToXY(const PeakIndex& peak, const DimMapper<2>& mapper) const = 0;
277 
286  virtual String getDataArrayDescription(const PeakIndex& /*peak_index*/)
287  {
288  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
289  }
290 
294  virtual bool annotate(const std::vector<PeptideIdentification>& identifications,
295  const std::vector<ProteinIdentification>& protein_identifications);
296 
297 
301  virtual void updateRanges() = 0;
302 
304  float getMinIntensity() const;
305 
307  float getMaxIntensity() const;
308 
310 
314  virtual RangeAllType getRange() const = 0;
315 
317  virtual std::unique_ptr<LayerStatistics> getStats() const = 0;
318 
320  const String& getName() const
321  {
322  return name_;
323  }
325  void setName(const String& new_name)
326  {
327  name_ = new_name;
328  }
329 
331  const String& getNameSuffix() const
332  {
333  return name_suffix_;
334  }
336  void setNameSuffix(const String& decorator)
337  {
338  name_suffix_ = decorator;
339  }
340 
342  virtual String getDecoratedName() const;
343 
345  bool visible = true;
346 
348  DataType type = DT_UNKNOWN;
349 
352 
355 
358 
361 
363  bool modifiable = false;
364 
366  bool modified = false;
367 
369  LabelType label = L_NONE;
370 
372  int peptide_id_index = -1;
373  int peptide_hit_index = -1;
374 
375  private:
380  };
381 
386  {
387  public:
395  LayerAnnotatorBase(const FileTypeList& supported_types, const String& file_dialog_text, QWidget* gui_lock);
396 
398  virtual ~LayerAnnotatorBase() = default;
399 
404  bool annotateWithFileDialog(LayerDataBase& layer, LogWindow& log, const String& current_path) const;
405 
409  bool annotateWithFilename(LayerDataBase& layer, LogWindow& log, const String& filename) const;
410 
414  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const FileTypes::Type& type);
415 
417  static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const String& filename);
418 
419  protected:
422  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const = 0;
423 
426  QWidget* gui_lock_ = nullptr;
427  };
428 
432  {
433  public:
436  "Select peptide identification data", gui_lock)
437  {
438  }
439 
440  protected:
443  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
444  };
445 
449  {
450  public:
453  "Select AccurateMassSearch's featureXML file", gui_lock)
454  {
455  }
456 
457  protected:
460  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
461  };
462 
466  {
467  public:
469  LayerAnnotatorBase(std::vector<FileTypes::Type>{FileTypes::OSW},
470  "Select OpenSwath/pyProphet output file", gui_lock)
471  {
472  }
473 
474  protected:
477  virtual bool annotateWorker_(LayerDataBase& layer, const String& filename, LogWindow& log) const;
478  };
479 
481  OPENMS_GUI_DLLAPI std::ostream& operator<<(std::ostream& os, const LayerDataBase& rhs);
482 
483 }// namespace OpenMS
484 
A container for consensus elements.
Definition: ConsensusMap.h:92
DataFilter array providing some convenience functions.
Definition: DataFilters.h:53
Not implemented exception.
Definition: Exception.h:430
A container for features.
Definition: FeatureMap.h:106
holds a vector of known file types, e.g. as a way to specify supported input formats
Definition: FileTypes.h:150
Definition: LayerDataBase.h:449
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
LayerAnnotatorAMS(QWidget *gui_lock)
Definition: LayerDataBase.h:451
Definition: LayerDataBase.h:386
QWidget * gui_lock_
optional widget which will be locked when calling annotateWorker_() in child-classes
Definition: LayerDataBase.h:426
virtual ~LayerAnnotatorBase()=default
Make D'tor virtual for correct destruction from pointers to base.
const FileTypeList supported_types_
Definition: LayerDataBase.h:424
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:425
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const =0
Definition: LayerDataBase.h:466
LayerAnnotatorOSW(QWidget *gui_lock)
Definition: LayerDataBase.h:468
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
Definition: LayerDataBase.h:432
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
LayerAnnotatorPeptideID(QWidget *gui_lock)
Definition: LayerDataBase.h:434
Class that stores the data for one layer.
Definition: LayerDataBase.h:195
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:377
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:331
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:360
virtual PeakIndex findClosestDataPoint(const RangeAllType &) const
Find the closest datapoint within the given range and return a proxy to that datapoint.
Definition: LayerDataBase.h:254
virtual String getDataArrayDescription(const PeakIndex &)
Get name and value of all data-arrays corresponding to the given datapoint.
Definition: LayerDataBase.h:286
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:379
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerDataBase.h:198
LayerDataBase()=delete
Default constructor (for virtual inheritance)
LayerDataBase(const DataType type)
C'tor for child classes.
Definition: LayerDataBase.h:205
LayerDataBase(LayerDataBase &&ld)=delete
const String & getName() const
The name of the layer, usually the basename of the file.
Definition: LayerDataBase.h:320
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:238
virtual PeakIndex findHighestDataPoint(const RangeAllType &) const
Find the datapoint with the highest intensity within the given range and return a proxy to that datap...
Definition: LayerDataBase.h:264
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:336
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerDataBase.h:357
Param param
Layer parameters.
Definition: LayerDataBase.h:354
String filename
file name of the file the data comes from (if available)
Definition: LayerDataBase.h:351
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:325
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:233
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:55
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:68
Management and storage of parameters / INI files.
Definition: Param.h:70
float IntensityType
Intensity type.
Definition: Peak1D.h:62
A more convenient string class.
Definition: String.h:60
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
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:46
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
Result of computing a projection on X and Y axis in a 2D Canvas; see LayerDataBase::getProjection()
Definition: LayerDataBase.h:77
Peak1D::IntensityType max_intensity
Definition: LayerDataBase.h:89
std::unique_ptr< LayerData1DBase > projection_ontoX
Definition: LayerDataBase.h:85
struct OpenMS::LayerDataDefs::ProjectionData::Summary stats
UInt number_of_datapoints
Definition: LayerDataBase.h:88
ProjectionData(ProjectionData &&)
Move C'tor.
double sum_intensity
Definition: LayerDataBase.h:90
std::unique_ptr< LayerData1DBase > projection_ontoY
Definition: LayerDataBase.h:86
Definition: LayerDataBase.h:73
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:152
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerDataBase.h:149
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:157
LabelType
Label used in visualization.
Definition: LayerDataBase.h:124
@ L_ID_ALL
All peptide hits of the first identification run are used.
Definition: LayerDataBase.h:129
@ L_ID
The best peptide hit of the first identification run is used.
Definition: LayerDataBase.h:128
@ L_NONE
No label is displayed.
Definition: LayerDataBase.h:125
@ L_META_LABEL
The 'label' meta information is used.
Definition: LayerDataBase.h:127
@ SIZE_OF_LABEL_TYPE
Definition: LayerDataBase.h:130
@ L_INDEX
The element number is used.
Definition: LayerDataBase.h:126
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:140
ConsensusMap ConsensusMapType
consensus features
Definition: LayerDataBase.h:143
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerDataBase.h:154
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:146
Flags
Flags that determine which information is shown.
Definition: LayerDataBase.h:110
@ I_PEPTIDEMZ
Identifications: m/z source.
Definition: LayerDataBase.h:117
@ F_HULL
Features: Overall convex hull.
Definition: LayerDataBase.h:111
@ SIZE_OF_FLAGS
Definition: LayerDataBase.h:119
@ F_UNASSIGNED
Features: Unassigned peptide hits.
Definition: LayerDataBase.h:113
@ P_PRECURSORS
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerDataBase.h:114
@ I_LABELS
Identifications: Show labels (not sequences)
Definition: LayerDataBase.h:118
@ P_PROJECTIONS
Peaks: Show projections.
Definition: LayerDataBase.h:115
@ C_ELEMENTS
Consensus features: Show elements.
Definition: LayerDataBase.h:116
@ F_HULLS
Features: Convex hulls of single mass traces.
Definition: LayerDataBase.h:112
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerDataBase.h:134
DataType
Definition: LayerDataBase.h:99
@ DT_FEATURE
Feature data.
Definition: LayerDataBase.h:102
@ DT_PEAK
Spectrum profile or centroided data.
Definition: LayerDataBase.h:100
@ DT_CONSENSUS
Consensus feature data.
Definition: LayerDataBase.h:103
@ DT_CHROMATOGRAM
Chromatogram data.
Definition: LayerDataBase.h:101
@ DT_IDENT
Peptide identification data.
Definition: LayerDataBase.h:104
@ DT_UNKNOWN
Undefined data type indicating an error.
Definition: LayerDataBase.h:105
FeatureMap FeatureMapType
Features.
Definition: LayerDataBase.h:137
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerDataBase.h:160
Index of a peak or feature.
Definition: PeakIndex.h:51