OpenMS
Loading...
Searching...
No Matches
LayerDataBase.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
27#include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
28
29#include <memory>
30
31#include <bitset>
32#include <vector>
33
34class QWidget;
35
36namespace OpenMS
37{
38 class LayerData1DBase;
39 class LayerStoreData;
40 class LayerStatistics;
41 class OSWData;
42 class Painter1DBase;
43 class Painter2DBase;
44
45 template <int N_DIM> class DimMapper;
46
48 {
49
52 {
58 ~ProjectionData(); // needs to be implemented in cpp, since inline would require a full definition of LayerData1DBase;
59
60 std::unique_ptr<LayerData1DBase> projection_ontoX;
61 std::unique_ptr<LayerData1DBase> projection_ontoY;
62 struct Summary {
65 double sum_intensity {0}; // double since sum could get large
67 };
68
82
96
107
109 static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE];
110
113
115 typedef std::shared_ptr<FeatureMap> FeatureMapSharedPtrType;
116
119
121 typedef std::shared_ptr<ConsensusMap> ConsensusMapSharedPtrType;
122
125
127 typedef std::shared_ptr<ExperimentType> ExperimentSharedPtrType;
128
129 typedef std::shared_ptr<const ExperimentType> ConstExperimentSharedPtrType;
130
132 typedef std::shared_ptr<OnDiscMSExperiment> ODExperimentSharedPtrType;
133
135 typedef std::shared_ptr<OSWData> OSWDataSharedPtrType;
136 };
137
166#ifdef _MSC_VER
167 #pragma warning(disable : 4250) // 'class1' : inherits 'class2::member' via dominance
168#endif
169 class OPENMS_GUI_DLLAPI LayerDataBase : public LayerDataDefs
170 {
171 public:
173 std::bitset<SIZE_OF_FLAGS> flags;
174
176
178 LayerDataBase() = delete; // <-- this is the problem. Call assignment op in 1DPeak???
180 explicit LayerDataBase(const DataType type) : type(type) {}
182 LayerDataBase(const LayerDataBase& ld) = default;
192 virtual ~LayerDataBase() = default;
193
198 virtual std::unique_ptr<Painter2DBase> getPainter2D() const = 0;
199
200
205 virtual std::unique_ptr <LayerData1DBase> to1DLayer() const = 0;
206
208 virtual std::unique_ptr<LayerStoreData> storeVisibleData(const RangeAllType& /*visible_range*/, const DataFilters& /*layer_filters*/) const
209 {
210 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
211 }
213 virtual std::unique_ptr<LayerStoreData> storeFullData() const
214 {
215 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
216 }
217
221 // todo: put this into a LayerData2DBase class, since a LayerData1DPeak should not implement this.
222 virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType& area) const = 0;
223
229 virtual PeakIndex findClosestDataPoint(const RangeAllType& area) const
230 {
231 (void)area; // allow doxygen to document the param
232 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
233 }
234
240 virtual PeakIndex findHighestDataPoint(const RangeAllType& area) const
241 {
242 (void)area; // allow doxygen to document the param
243 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
244 }
245
246
253 virtual PointXYType peakIndexToXY(const PeakIndex& peak, const DimMapper<2>& mapper) const = 0;
254
263 virtual std::string getDataArrayDescription(const PeakIndex& peak_index)
264 {
265 (void)peak_index; // allow doxygen to document the param
266 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
267 }
268
272 virtual bool annotate(const PeptideIdentificationList& identifications,
273 const std::vector<ProteinIdentification>& protein_identifications);
274
275
279 virtual void updateRanges() = 0;
280
282 float getMinIntensity() const;
283
285 float getMaxIntensity() const;
286
288
292 virtual RangeAllType getRange() const = 0;
293
295 virtual std::unique_ptr<LayerStatistics> getStats() const = 0;
296
298 const std::string& getName() const
299 {
300 return name_;
301 }
303 void setName(const std::string& new_name)
304 {
305 name_ = new_name;
306 }
307
309 const std::string& getNameSuffix() const
310 {
311 return name_suffix_;
312 }
314 void setNameSuffix(const std::string& decorator)
315 {
316 name_suffix_ = decorator;
317 }
318
320 virtual std::string getDecoratedName() const;
321
323 bool visible = true;
324
326 DataType type = DT_UNKNOWN;
327
329 std::string filename;
330
333
336
339
341 bool modifiable = false;
342
344 bool modified = false;
345
347 LabelType label = L_NONE;
348
350 int peptide_id_index = -1;
351 int peptide_hit_index = -1;
352
353 private:
355 std::string name_;
357 std::string name_suffix_;
358 };
359
364 {
365 public:
373 LayerAnnotatorBase(const FileTypeList& supported_types, const std::string& file_dialog_text, QWidget* gui_lock);
374
376 virtual ~LayerAnnotatorBase() = default;
377
382 bool annotateWithFileDialog(LayerDataBase& layer, LogWindow& log, const std::string& current_path) const;
383
387 bool annotateWithFilename(LayerDataBase& layer, LogWindow& log, const std::string& filename) const;
388
392 static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const FileTypes::Type& type);
393
395 static std::unique_ptr<LayerAnnotatorBase> getAnnotatorWhichSupports(const std::string& filename);
396
397 protected:
400 virtual bool annotateWorker_(LayerDataBase& layer, const std::string& filename, LogWindow& log) const = 0;
401
403 const std::string file_dialog_text_;
404 QWidget* gui_lock_ = nullptr;
405 };
406
410 {
411 public:
414 "Select peptide identification data", gui_lock)
415 {
416 }
417
418 protected:
421 virtual bool annotateWorker_(LayerDataBase& layer, const std::string& filename, LogWindow& log) const;
422 };
423
427 {
428 public:
431 "Select AccurateMassSearch's featureXML file", gui_lock)
432 {
433 }
434
435 protected:
438 virtual bool annotateWorker_(LayerDataBase& layer, const std::string& filename, LogWindow& log) const;
439 };
440
444 {
445 public:
448 "Select OpenSwath/pyProphet output file", gui_lock)
449 {
450 }
451
452 protected:
455 virtual bool annotateWorker_(LayerDataBase& layer, const std::string& filename, LogWindow& log) const;
456 };
457
459 OPENMS_GUI_DLLAPI std::ostream& operator<<(std::ostream& os, const LayerDataBase& rhs);
460
461}// namespace OpenMS
462
Class for storing MS run data with peptide and protein identifications.
Definition AnnotatedMSRun.h:39
A container for consensus elements.
Definition ConsensusMap.h:67
DataFilter array providing some convenience functions.
Definition DataFilters.h:27
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,...
Definition DimMapper.h:662
Not implemented exception.
Definition Exception.h:400
A container for features.
Definition FeatureMap.h:78
holds a vector of known file types, e.g. as a way to specify supported input formats
Definition FileTypes.h:154
Definition LayerDataBase.h:427
LayerAnnotatorAMS(QWidget *gui_lock)
Definition LayerDataBase.h:429
virtual bool annotateWorker_(LayerDataBase &layer, const std::string &filename, LogWindow &log) const
Definition LayerDataBase.h:364
QWidget * gui_lock_
optional widget which will be locked when calling annotateWorker_() in child-classes
Definition LayerDataBase.h:404
virtual ~LayerAnnotatorBase()=default
Make D'tor virtual for correct destruction from pointers to base.
const FileTypeList supported_types_
Definition LayerDataBase.h:402
bool annotateWithFilename(LayerDataBase &layer, LogWindow &log, const std::string &filename) const
bool annotateWithFileDialog(LayerDataBase &layer, LogWindow &log, const std::string &current_path) const
const std::string file_dialog_text_
Definition LayerDataBase.h:403
virtual bool annotateWorker_(LayerDataBase &layer, const std::string &filename, LogWindow &log) const =0
LayerAnnotatorBase(const FileTypeList &supported_types, const std::string &file_dialog_text, QWidget *gui_lock)
C'tor with params.
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const FileTypes::Type &type)
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const std::string &filename)
see getAnnotatorWhichSupports(const FileTypes::Type& type). File type is queried from filename
Definition LayerDataBase.h:444
LayerAnnotatorOSW(QWidget *gui_lock)
Definition LayerDataBase.h:446
virtual bool annotateWorker_(LayerDataBase &layer, const std::string &filename, LogWindow &log) const
Definition LayerDataBase.h:410
LayerAnnotatorPeptideID(QWidget *gui_lock)
Definition LayerDataBase.h:412
virtual bool annotateWorker_(LayerDataBase &layer, const std::string &filename, LogWindow &log) const
Class that stores the data for one layer.
Definition LayerDataBase.h:170
virtual std::string getDataArrayDescription(const PeakIndex &peak_index)
Get name and value of all data-arrays corresponding to the given datapoint.
Definition LayerDataBase.h:263
LayerDataBase & operator=(const LayerDataBase &ld)=delete
Assignment operator.
virtual bool annotate(const PeptideIdentificationList &identifications, const std::vector< ProteinIdentification > &protein_identifications)
virtual std::unique_ptr< LayerData1DBase > to1DLayer() const =0
Create a shallow copy (i.e. shared experimental data using shared_ptr) of the current layer,...
virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType &area) const =0
void setNameSuffix(const std::string &decorator)
set an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is cur...
Definition LayerDataBase.h:314
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 setName(const std::string &new_name)
Set the name of the layer, usually the basename of the file.
Definition LayerDataBase.h:303
virtual ~LayerDataBase()=default
D'tor.
virtual std::string getDecoratedName() const
get name augmented with attributes, e.g. '*' if modified
const std::string & getName() const
The name of the layer, usually the basename of the file.
Definition LayerDataBase.h:298
std::string name_suffix_
an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is current...
Definition LayerDataBase.h:357
std::string name_
layer name
Definition LayerDataBase.h:355
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:213
virtual std::unique_ptr< LayerStatistics > getStats() const =0
Compute layer statistics (via visitor)
virtual void updateRanges()=0
Update ranges of the underlying data.
DataFilters filters
Filters to apply before painting.
Definition LayerDataBase.h:338
LayerDataBase & operator=(LayerDataBase &&ld)=delete
Move assignment – deleted, by same argument as for move c'tor.
virtual PointXYType peakIndexToXY(const PeakIndex &peak, const DimMapper< 2 > &mapper) const =0
Convert a PeakIndex to a XY coordinate (via mapper).
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:208
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition LayerDataBase.h:173
LayerDataBase()=delete
Default constructor (for virtual inheritance)
const std::string & getNameSuffix() const
get the extra annotation to the layers name, e.g. '[39]' for which chromatogram index is currently sh...
Definition LayerDataBase.h:309
LayerDataBase(const DataType type)
C'tor for child classes.
Definition LayerDataBase.h:180
LayerDataBase(LayerDataBase &&ld)=delete
virtual std::unique_ptr< Painter2DBase > getPainter2D() const =0
Obtain a painter which can draw the layer on a 2D canvas.
virtual RangeAllType getRange() const =0
MultiGradient gradient
Gradient for 2D and 3D views.
Definition LayerDataBase.h:335
Param param
Layer parameters.
Definition LayerDataBase.h:332
std::string filename
file name of the file the data comes from (if available)
Definition LayerDataBase.h:329
LayerDataBase(const LayerDataBase &ld)=default
Copy-C'tor.
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:229
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:240
A log window (QTextEdit) with convenience functions.
Definition LogWindow.h:28
A gradient of multiple colors and arbitrary distances between colors.
Definition MultiGradient.h:42
Management and storage of parameters / INI files.
Definition Param.h:46
float IntensityType
Intensity type.
Definition Peak1D.h:38
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
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
DIM_UNIT
Definition CommonEnums.h:20
STL namespace.
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:81
Result of computing a projection on X and Y axis in a 2D Canvas; see LayerDataBase::getProjection()
Definition LayerDataBase.h:52
Peak1D::IntensityType max_intensity
Definition LayerDataBase.h:64
std::unique_ptr< LayerData1DBase > projection_ontoX
Definition LayerDataBase.h:60
struct OpenMS::LayerDataDefs::ProjectionData::Summary stats
UInt number_of_datapoints
Definition LayerDataBase.h:63
ProjectionData(ProjectionData &&)
Move C'tor.
double sum_intensity
Definition LayerDataBase.h:65
std::unique_ptr< LayerData1DBase > projection_ontoY
Definition LayerDataBase.h:61
Definition LayerDataBase.h:48
std::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition LayerDataBase.h:127
std::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition LayerDataBase.h:129
std::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition LayerDataBase.h:121
LabelType
Label used in visualization.
Definition LayerDataBase.h:99
@ L_ID_ALL
All peptide hits of the first identification run are used.
Definition LayerDataBase.h:104
@ L_ID
The best peptide hit of the first identification run is used.
Definition LayerDataBase.h:103
@ L_NONE
No label is displayed.
Definition LayerDataBase.h:100
@ L_META_LABEL
The 'label' meta information is used.
Definition LayerDataBase.h:102
@ SIZE_OF_LABEL_TYPE
Definition LayerDataBase.h:105
@ L_INDEX
The element number is used.
Definition LayerDataBase.h:101
std::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition LayerDataBase.h:135
ConsensusMap ConsensusMapType
consensus features
Definition LayerDataBase.h:118
std::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition LayerDataBase.h:115
std::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition LayerDataBase.h:132
Flags
Flags that determine which information is shown.
Definition LayerDataBase.h:85
@ I_PEPTIDEMZ
Identifications: m/z source.
Definition LayerDataBase.h:92
@ F_HULL
Features: Overall convex hull.
Definition LayerDataBase.h:86
@ SIZE_OF_FLAGS
Definition LayerDataBase.h:94
@ F_UNASSIGNED
Features: Unassigned peptide hits.
Definition LayerDataBase.h:88
@ P_PRECURSORS
Peaks: Mark precursor peaks of MS/MS scans.
Definition LayerDataBase.h:89
@ I_LABELS
Identifications: Show labels (not sequences)
Definition LayerDataBase.h:93
@ P_PROJECTIONS
Peaks: Show projections.
Definition LayerDataBase.h:90
@ C_ELEMENTS
Consensus features: Show elements.
Definition LayerDataBase.h:91
@ F_HULLS
Features: Convex hulls of single mass traces.
Definition LayerDataBase.h:87
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition LayerDataBase.h:109
AnnotatedMSRun ExperimentType
Main data type (experiment)
Definition LayerDataBase.h:124
DataType
Definition LayerDataBase.h:74
@ DT_FEATURE
Feature data.
Definition LayerDataBase.h:77
@ DT_PEAK
Spectrum profile or centroided data.
Definition LayerDataBase.h:75
@ DT_CONSENSUS
Consensus feature data.
Definition LayerDataBase.h:78
@ DT_CHROMATOGRAM
Chromatogram data.
Definition LayerDataBase.h:76
@ DT_IDENT
Peptide identification data.
Definition LayerDataBase.h:79
@ DT_UNKNOWN
Undefined data type indicating an error.
Definition LayerDataBase.h:80
FeatureMap FeatureMapType
Features.
Definition LayerDataBase.h:112
Index of a peak or feature.
Definition PeakIndex.h:25