OpenMS  3.0.0
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-2022.
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 
96  enum DataType
99  {
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  class OPENMS_GUI_DLLAPI LayerDataBase : public LayerDataDefs
192  {
193  public:
195  std::bitset<SIZE_OF_FLAGS> flags;
196 
198 
200  LayerDataBase() = delete; // <-- this is the problem. Call assignment op in 1DPeak???
202  explicit LayerDataBase(const DataType type) : type(type) {}
204  LayerDataBase(const LayerDataBase& ld) = default;
206  LayerDataBase& operator=(const LayerDataBase& ld) = delete;
210  LayerDataBase(LayerDataBase&& ld) = delete;
212  LayerDataBase& operator=(LayerDataBase&& ld) = delete;
214  virtual ~LayerDataBase() = default;
215 
220  virtual std::unique_ptr<Painter2DBase> getPainter2D() const = 0;
221 
222 
227  virtual std::unique_ptr <LayerData1DBase> to1DLayer() const = 0;
228 
230  virtual std::unique_ptr<LayerStoreData> storeVisibleData(const RangeAllType& /*visible_range*/, const DataFilters& /*layer_filters*/) const
231  {
232  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
233  }
235  virtual std::unique_ptr<LayerStoreData> storeFullData() const
236  {
237  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
238  }
239 
243  // todo: put this into a LayerData2DBase class, since a LayerData1DPeak should not implement this.
244  virtual ProjectionData getProjection(const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType& area) const = 0;
245 
251  virtual PeakIndex findClosestDataPoint(const RangeAllType& /*area*/) const
252  {
253  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
254  }
255 
261  virtual PeakIndex findHighestDataPoint(const RangeAllType& /*area*/) const
262  {
263  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
264  }
265 
266 
273  virtual PointXYType peakIndexToXY(const PeakIndex& peak, const DimMapper<2>& mapper) const = 0;
274 
283  virtual String getDataArrayDescription(const PeakIndex& /*peak_index*/)
284  {
285  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
286  }
287 
291  virtual bool annotate(const std::vector<PeptideIdentification>& identifications,
292  const std::vector<ProteinIdentification>& protein_identifications);
293 
294 
298  virtual void updateRanges() = 0;
299 
301  float getMinIntensity() const;
302 
304  float getMaxIntensity() const;
305 
307 
310  virtual RangeAllType getRange() const = 0;
311 
313  virtual std::unique_ptr<LayerStatistics> getStats() const = 0;
314 
315  const String& getName() const
316  {
317  return name_;
318  }
319  void setName(const String& new_name)
320  {
321  name_ = new_name;
322  }
323 
325  bool visible = true;
326 
328  DataType type = DT_UNKNOWN;
329 
332 
335 
338 
341 
343  bool modifiable = false;
344 
346  bool modified = false;
347 
349  LabelType label = L_NONE;
350 
352  int peptide_id_index = -1;
353  int peptide_hit_index = -1;
354 
356  virtual String getDecoratedName() const;
357 
358  private:
361  };
362 
366  {
367  public:
375  LayerAnnotatorBase(const FileTypeList& supported_types, const String& file_dialog_text, QWidget* gui_lock);
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:
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 
Type
Actual file types enum.
Definition: FileTypes.h:56
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
A log window (QTextEdit) with convenience functions.
Definition: LogWindow.h:53
const String & getName() const
Definition: LayerDataBase.h:315
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
DataType
Definition: LayerDataBase.h:98
std::unique_ptr< LayerData1DBase > projection_ontoY
Definition: LayerDataBase.h:86
A more convenient string class.
Definition: String.h:58
boost::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition: LayerDataBase.h:152
Definition: LayerDataBase.h:130
std::bitset< SIZE_OF_FLAGS > flags
Actual state of each flag.
Definition: LayerDataBase.h:195
Definition: LayerDataBase.h:425
boost::shared_ptr< OnDiscMSExperiment > ODExperimentSharedPtrType
SharedPtr on On-Disc MSExperiment.
Definition: LayerDataBase.h:157
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const
Peptide identification data.
Definition: LayerDataBase.h:104
The &#39;label&#39; meta information is used.
Definition: LayerDataBase.h:127
bool annotateWithFileDialog(LayerDataBase &layer, LogWindow &log, const String &current_path) const
static std::unique_ptr< LayerAnnotatorBase > getAnnotatorWhichSupports(const FileTypes::Type &type)
String name_
layer name
Definition: LayerDataBase.h:360
UInt number_of_datapoints
Definition: LayerDataBase.h:88
A container for features.
Definition: FeatureMap.h:98
OpenMS identification format (.idXML)
Definition: FileTypes.h:64
void setName(const String &new_name)
Definition: LayerDataBase.h:319
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Features: Unassigned peptide hits.
Definition: LayerDataBase.h:113
Chromatogram data.
Definition: LayerDataBase.h:101
virtual bool annotateWorker_(LayerDataBase &layer, const String &filename, LogWindow &log) const =0
Identifications: Show labels (not sequences)
Definition: LayerDataBase.h:118
A container for consensus elements.
Definition: ConsensusMap.h:82
STL namespace.
String filename
file name of the file the data comes from (if available)
Definition: LayerDataBase.h:331
const FileTypeList supported_types_
Definition: LayerDataBase.h:401
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
boost::shared_ptr< ConsensusMap > ConsensusMapSharedPtrType
SharedPtr on consensus features.
Definition: LayerDataBase.h:146
DIM_UNIT
Definition: CommonEnums.h:45
holds a vector of known file types, e.g. as a way to specify supported input formats ...
Definition: FileTypes.h:149
Peak1D::IntensityType max_intensity
Definition: LayerDataBase.h:89
LayerDataBase(const DataType type)
C&#39;tor for child classes.
Definition: LayerDataBase.h:202
virtual String getDataArrayDescription(const PeakIndex &)
Get name and value of all data-arrays corresponding to the given datapoint.
Definition: LayerDataBase.h:283
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerDataBase.h:160
Centralizes the file types recognized by FileHandler.
Definition: FileTypes.h:52
LayerAnnotatorOSW(QWidget *gui_lock)
Definition: LayerDataBase.h:445
Result of computing a projection on X and Y axis in a 2D Canvas; see LayerDataBase::getProjection() ...
Definition: LayerDataBase.h:76
MultiGradient gradient
Gradient for 2D and 3D views.
Definition: LayerDataBase.h:337
LabelType
Label used in visualization.
Definition: LayerDataBase.h:123
Spectrum profile or centroided data.
Definition: LayerDataBase.h:100
Features: Overall convex hull.
Definition: LayerDataBase.h:111
Definition: LayerDataBase.h:72
std::unique_ptr< LayerData1DBase > projection_ontoX
Definition: LayerDataBase.h:85
bool annotateWithFilename(LayerDataBase &layer, LogWindow &log, const String &filename) const
Definition: LayerDataBase.h:442
mzIdentML (HUPO PSI AnalysisXML followup format) (.mzid)
Definition: FileTypes.h:75
Undefined data type indicating an error.
Definition: LayerDataBase.h:105
Definition: LayerDataBase.h:119
FeatureMap FeatureMapType
Features.
Definition: LayerDataBase.h:137
QWidget * gui_lock_
optional widget which will be locked when calling annotateWorker_() in child-classes ...
Definition: LayerDataBase.h:403
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
const String file_dialog_text_
Definition: LayerDataBase.h:402
ConsensusMap ConsensusMapType
consensus features
Definition: LayerDataBase.h:143
virtual PeakIndex findClosestDataPoint(const RangeAllType &) const
Find the closest datapoint within the given range and return a proxy to that datapoint.
Definition: LayerDataBase.h:251
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:230
All peptide hits of the first identification run are used.
Definition: LayerDataBase.h:129
Definition: LayerDataBase.h:408
The element number is used.
Definition: LayerDataBase.h:126
OpenMS feature file (.featureXML)
Definition: FileTypes.h:63
Management and storage of parameters / INI files.
Definition: Param.h:69
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
struct OpenMS::LayerDataDefs::ProjectionData::Summary stats
Definition: LayerDataBase.h:365
Peaks: Mark precursor peaks of MS/MS scans.
Definition: LayerDataBase.h:114
LayerAnnotatorPeptideID(QWidget *gui_lock)
Definition: LayerDataBase.h:411
LayerAnnotatorBase(const FileTypeList &supported_types, const String &file_dialog_text, QWidget *gui_lock)
C&#39;tor with params.
LayerAnnotatorAMS(QWidget *gui_lock)
Definition: LayerDataBase.h:428
static const std::string NamesOfLabelType[SIZE_OF_LABEL_TYPE]
Label names.
Definition: LayerDataBase.h:134
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
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:235
boost::shared_ptr< const ExperimentType > ConstExperimentSharedPtrType
Definition: LayerDataBase.h:154
Identifications: m/z source.
Definition: LayerDataBase.h:117
OpenSWATH OpenSWATH report (OSW) SQLite DB.
Definition: FileTypes.h:104
No label is displayed.
Definition: LayerDataBase.h:125
The best peptide hit of the first identification run is used.
Definition: LayerDataBase.h:128
boost::shared_ptr< FeatureMap > FeatureMapSharedPtrType
SharedPtr on feature map.
Definition: LayerDataBase.h:140
Consensus feature data.
Definition: LayerDataBase.h:103
DataFilter array providing some convenience functions.
Definition: DataFilters.h:52
double sum_intensity
Definition: LayerDataBase.h:90
Features: Convex hulls of single mass traces.
Definition: LayerDataBase.h:112
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:67
Feature data.
Definition: LayerDataBase.h:102
Peaks: Show projections.
Definition: LayerDataBase.h:115
Param param
Layer parameters.
Definition: LayerDataBase.h:334
DataFilters filters
Filters to apply before painting.
Definition: LayerDataBase.h:340
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:261
PeakMap ExperimentType
Main data type (experiment)
Definition: LayerDataBase.h:149
Not implemented exception.
Definition: Exception.h:428
Class that stores the data for one layer.
Definition: LayerDataBase.h:191
Flags
Flags that determine which information is shown.
Definition: LayerDataBase.h:109
Index of a peak or feature.
Definition: PeakIndex.h:50
Consensus features: Show elements.
Definition: LayerDataBase.h:116