OpenMS
LayerDataBase Class Referenceabstract

Class that stores the data for one layer. More...

#include <OpenMS/VISUAL/LayerDataBase.h>

Inheritance diagram for LayerDataBase:
[legend]
Collaboration diagram for LayerDataBase:
[legend]

Public Types

using RangeAllType = RangeManager< RangeRT, RangeMZ, RangeIntensity, RangeMobility >
 
- Public Types inherited from LayerDataDefs
enum  DataType {
  DT_PEAK , DT_CHROMATOGRAM , DT_FEATURE , DT_CONSENSUS ,
  DT_IDENT , DT_UNKNOWN
}
 
enum  Flags {
  F_HULL , F_HULLS , F_UNASSIGNED , P_PRECURSORS ,
  P_PROJECTIONS , C_ELEMENTS , I_PEPTIDEMZ , I_LABELS ,
  SIZE_OF_FLAGS
}
 Flags that determine which information is shown. More...
 
enum  LabelType {
  L_NONE , L_INDEX , L_META_LABEL , L_ID ,
  L_ID_ALL , SIZE_OF_LABEL_TYPE
}
 Label used in visualization. More...
 
typedef FeatureMap FeatureMapType
 Features. More...
 
typedef boost::shared_ptr< FeatureMapFeatureMapSharedPtrType
 SharedPtr on feature map. More...
 
typedef ConsensusMap ConsensusMapType
 consensus features More...
 
typedef boost::shared_ptr< ConsensusMapConsensusMapSharedPtrType
 SharedPtr on consensus features. More...
 
typedef PeakMap ExperimentType
 Main data type (experiment) More...
 
typedef boost::shared_ptr< ExperimentTypeExperimentSharedPtrType
 SharedPtr on MSExperiment. More...
 
typedef boost::shared_ptr< const ExperimentTypeConstExperimentSharedPtrType
 
typedef boost::shared_ptr< OnDiscMSExperimentODExperimentSharedPtrType
 SharedPtr on On-Disc MSExperiment. More...
 
typedef boost::shared_ptr< OSWDataOSWDataSharedPtrType
 SharedPtr on OSWData. More...
 

Public Member Functions

 LayerDataBase ()=delete
 Default constructor (for virtual inheritance) More...
 
 LayerDataBase (const DataType type)
 C'tor for child classes. More...
 
 LayerDataBase (const LayerDataBase &ld)=default
 Copy-C'tor. More...
 
LayerDataBaseoperator= (const LayerDataBase &ld)=delete
 Assignment operator. More...
 
 LayerDataBase (LayerDataBase &&ld)=delete
 
LayerDataBaseoperator= (LayerDataBase &&ld)=delete
 Move assignment – deleted, by same argument as for move c'tor. More...
 
virtual ~LayerDataBase ()=default
 D'tor. More...
 
virtual std::unique_ptr< Painter2DBasegetPainter2D () const =0
 Obtain a painter which can draw the layer on a 2D canvas. More...
 
virtual std::unique_ptr< LayerData1DBaseto1DLayer () const =0
 Create a shallow copy (i.e. shared experimental data using shared_ptr) of the current layer, and make it 1D (i.e. support showing a single spec/chrom etc) More...
 
virtual std::unique_ptr< LayerStoreDatastoreVisibleData (const RangeAllType &, const DataFilters &) const
 Returns a visitor which contains the current visible data and can write the data to disk. More...
 
virtual std::unique_ptr< LayerStoreDatastoreFullData () const
 Returns a visitor which contains the the full data of the layer and can write the data to disk in the appropriate format (e.g. mzML) More...
 
virtual ProjectionData getProjection (const DIM_UNIT unit_x, const DIM_UNIT unit_y, const RangeAllType &area) const =0
 
virtual PeakIndex findClosestDataPoint (const RangeAllType &) const
 Find the closest datapoint within the given range and return a proxy to that datapoint. More...
 
virtual PeakIndex findHighestDataPoint (const RangeAllType &) const
 Find the datapoint with the highest intensity within the given range and return a proxy to that datapoint. More...
 
virtual PointXYType peakIndexToXY (const PeakIndex &peak, const DimMapper< 2 > &mapper) const =0
 Convert a PeakIndex to a XY coordinate (via mapper). More...
 
virtual String getDataArrayDescription (const PeakIndex &)
 Get name and value of all data-arrays corresponding to the given datapoint. More...
 
virtual bool annotate (const std::vector< PeptideIdentification > &identifications, const std::vector< ProteinIdentification > &protein_identifications)
 
virtual void updateRanges ()=0
 Update ranges of the underlying data. More...
 
float getMinIntensity () const
 Returns the minimum intensity of the internal data, depending on type. More...
 
float getMaxIntensity () const
 Returns the maximum intensity of the internal data, depending on type. More...
 
virtual RangeAllType getRange () const =0
 
virtual std::unique_ptr< LayerStatisticsgetStats () const =0
 Compute layer statistics (via visitor) More...
 
const StringgetName () const
 The name of the layer, usually the basename of the file. More...
 
void setName (const String &new_name)
 Set the name of the layer, usually the basename of the file. More...
 
const StringgetNameSuffix () const
 get the extra annotation to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D More...
 
void setNameSuffix (const String &decorator)
 set an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D More...
 
virtual String getDecoratedName () const
 get name augmented with attributes, e.g. '*' if modified More...
 

Public Attributes

std::bitset< SIZE_OF_FLAGSflags
 Actual state of each flag. More...
 
bool visible = true
 if this layer is visible More...
 
DataType type = DT_UNKNOWN
 data type (peak or feature data, etc) More...
 
String filename
 file name of the file the data comes from (if available) More...
 
Param param
 Layer parameters. More...
 
MultiGradient gradient
 Gradient for 2D and 3D views. More...
 
DataFilters filters
 Filters to apply before painting. More...
 
bool modifiable = false
 Flag that indicates if the layer data can be modified (so far used for features only) More...
 
bool modified = false
 Flag that indicates that the layer data was modified since loading it. More...
 
LabelType label = L_NONE
 Label type. More...
 
int peptide_id_index = -1
 Selected peptide id and hit index (-1 if none is selected) More...
 
int peptide_hit_index = -1
 

Private Attributes

String name_
 layer name More...
 
String name_suffix_
 an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D More...
 

Additional Inherited Members

- Static Public Attributes inherited from LayerDataDefs
static const std::string NamesOfLabelType [SIZE_OF_LABEL_TYPE]
 Label names. More...
 

Detailed Description

Class that stores the data for one layer.

The data for a layer can be peak data, feature data (feature, consensus), chromatogram or peptide identification data.

For 2D and 3D data, the data is generally accessible through getPeakData() while features are accessible through getFeatureMap() and getConsensusMap(). For 1D data, the current spectrum must be accessed through getCurrentSpectrum().

Peak data is stored using a shared pointer to an MSExperiment data structure as well as a shared pointer to a OnDiscMSExperiment data structure. Note that the actual data may not be in memory as this is not efficient for large files and therefore may have to be retrieved from disk on-demand.

Note
The spectrum for 1D viewing retrieved through getCurrentSpectrum() is a copy of the actual raw data and *different* from the one retrieved through getPeakData()[index]. Any changes to applied to getCurrentSpectrum() are non-persistent and will be gone the next time the cache is updated. Persistent changes can be applied to getPeakDataMuteable() and will be available on the next cache update.
Layer is mainly used as a member variable of PlotCanvas which holds a vector of LayerDataBase objects.

Member Typedef Documentation

◆ RangeAllType

Constructor & Destructor Documentation

◆ LayerDataBase() [1/4]

LayerDataBase ( )
delete

Default constructor (for virtual inheritance)

◆ LayerDataBase() [2/4]

LayerDataBase ( const DataType  type)
inlineexplicit

C'tor for child classes.

◆ LayerDataBase() [3/4]

LayerDataBase ( const LayerDataBase ld)
default

Copy-C'tor.

◆ LayerDataBase() [4/4]

LayerDataBase ( LayerDataBase &&  ld)
delete

Move-C'tor - do not move from this class since its a virtual base class (diamond problem) and the move c'tor may be called twice (which would loose data!) Instead of painstakingly writing user-defined move c'tors which check for moving for all the direct child classes, we'd rather use copy (which is the automatic fallback, and safe) and incur a small performance hit

◆ ~LayerDataBase()

virtual ~LayerDataBase ( )
virtualdefault

D'tor.

Member Function Documentation

◆ annotate()

virtual bool annotate ( const std::vector< PeptideIdentification > &  identifications,
const std::vector< ProteinIdentification > &  protein_identifications 
)
virtual

add peptide identifications to the layer Only supported for DT_PEAK, DT_FEATURE and DT_CONSENSUS. Will return false otherwise.

Reimplemented in LayerDataPeak, LayerDataFeature, and LayerDataConsensus.

◆ findClosestDataPoint()

virtual PeakIndex findClosestDataPoint ( const RangeAllType ) const
inlinevirtual

Find the closest datapoint within the given range and return a proxy to that datapoint.

Parameters
areaRange to search in. Only dimensions used in the canvas are populated.
Returns
A proxy (e.g. scan + peak index in an MSExperiment) which points to the data

Reimplemented in LayerData1DPeak, LayerData1DIonMobility, and LayerData1DChrom.

◆ findHighestDataPoint()

virtual PeakIndex findHighestDataPoint ( const RangeAllType ) const
inlinevirtual

Find the datapoint with the highest intensity within the given range and return a proxy to that datapoint.

Parameters
areaRange to search in. Only dimensions used in the canvas are populated.
Returns
A proxy (e.g. scan + peak index in an MSExperiment) which points to the data

Reimplemented in LayerDataPeak, LayerDataFeature, LayerDataConsensus, LayerDataChrom, LayerDataIonMobility, and LayerDataIdent.

◆ getDataArrayDescription()

virtual String getDataArrayDescription ( const PeakIndex )
inlinevirtual

Get name and value of all data-arrays corresponding to the given datapoint.

Empty (or shorter) data-arrays are skipped.

Parameters
peak_indexThe datapoint
Returns
A string, e.g. "fwhm: 20, im: 3.3", depending on which float/string dataarrays are populated for the given datapoint

Reimplemented in LayerDataPeak, LayerDataIonMobility, and LayerDataChrom.

◆ getDecoratedName()

virtual String getDecoratedName ( ) const
virtual

get name augmented with attributes, e.g. '*' if modified

Reimplemented in LayerData1DBase.

Referenced by TOPPViewBase::showPlotWidgetInWindow().

◆ getMaxIntensity()

float getMaxIntensity ( ) const

Returns the maximum intensity of the internal data, depending on type.

◆ getMinIntensity()

float getMinIntensity ( ) const

Returns the minimum intensity of the internal data, depending on type.

◆ getName()

const String& getName ( ) const
inline

◆ getNameSuffix()

const String& getNameSuffix ( ) const
inline

get the extra annotation to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D

◆ getPainter2D()

virtual std::unique_ptr<Painter2DBase> getPainter2D ( ) const
pure virtual

Obtain a painter which can draw the layer on a 2D canvas.

Returns
A painter

Implemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, and LayerDataChrom.

◆ getProjection()

virtual ProjectionData getProjection ( const DIM_UNIT  unit_x,
const DIM_UNIT  unit_y,
const RangeAllType area 
) const
pure virtual

Calculate a projection of the current layer for the given unit and the given area. E.g. the area might be restricted in RT and m/z, and then requested projection should return the XIC (unit == RT) It is up to the implementation to decide on binning.

Implemented in LayerDataFeature, LayerDataConsensus, LayerDataPeak, LayerDataIonMobility, LayerDataIdent, and LayerDataChrom.

◆ getRange()

virtual RangeAllType getRange ( ) const
pure virtual

Returns the data range of the whole layer (i.e. all scans/chroms/etc) in all known dimensions. If a layer does not support the dimension (or the layer is empty) the dimension will be empty If you need the data range for a 1D view (i.e. only a single spec/chrom/etc), call 'LayerDataBase1D::getRange1D()'

Implemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, LayerDataChrom, LayerData1DIonMobility, and LayerData1DChrom.

◆ getStats()

virtual std::unique_ptr<LayerStatistics> getStats ( ) const
pure virtual

Compute layer statistics (via visitor)

Implemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, and LayerDataChrom.

◆ operator=() [1/2]

LayerDataBase& operator= ( const LayerDataBase ld)
delete

Assignment operator.

◆ operator=() [2/2]

LayerDataBase& operator= ( LayerDataBase &&  ld)
delete

Move assignment – deleted, by same argument as for move c'tor.

◆ peakIndexToXY()

virtual PointXYType peakIndexToXY ( const PeakIndex peak,
const DimMapper< 2 > &  mapper 
) const
pure virtual

Convert a PeakIndex to a XY coordinate (via mapper).

Parameters
peakThe Peak to convert
mapperConverts the internal representation (e.g. Peak1D) to an XY coordinate
Returns
XY coordinate in data units (e.g. X=m/z, Y=intensity)

Implemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, and LayerDataChrom.

◆ setName()

void setName ( const String new_name)
inline

Set the name of the layer, usually the basename of the file.

◆ setNameSuffix()

void setNameSuffix ( const String decorator)
inline

set an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D

◆ storeFullData()

virtual std::unique_ptr<LayerStoreData> storeFullData ( ) const
inlinevirtual

Returns a visitor which contains the the full data of the layer and can write the data to disk in the appropriate format (e.g. mzML)

Reimplemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, LayerDataChrom, LayerData1DPeak, LayerData1DIonMobility, and LayerData1DChrom.

Referenced by TOPPViewBase::runTOPPTool_().

◆ storeVisibleData()

virtual std::unique_ptr<LayerStoreData> storeVisibleData ( const RangeAllType ,
const DataFilters  
) const
inlinevirtual

Returns a visitor which contains the current visible data and can write the data to disk.

Reimplemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, LayerDataChrom, LayerData1DPeak, LayerData1DIonMobility, and LayerData1DChrom.

Referenced by TOPPViewBase::runTOPPTool_().

◆ to1DLayer()

virtual std::unique_ptr<LayerData1DBase> to1DLayer ( ) const
pure virtual

Create a shallow copy (i.e. shared experimental data using shared_ptr) of the current layer, and make it 1D (i.e. support showing a single spec/chrom etc)

Returns
A new layer for 1D

Implemented in LayerDataPeak, LayerDataIonMobility, LayerDataIdent, LayerDataFeature, LayerDataConsensus, and LayerDataChrom.

◆ updateRanges()

virtual void updateRanges ( )
pure virtual

Member Data Documentation

◆ filename

◆ filters

DataFilters filters

Filters to apply before painting.

Referenced by TOPPViewBase::runTOPPTool_().

◆ flags

std::bitset<SIZE_OF_FLAGS> flags

Actual state of each flag.

◆ gradient

MultiGradient gradient

Gradient for 2D and 3D views.

◆ label

LabelType label = L_NONE

Label type.

Referenced by TOPPViewBase::updateToolBar().

◆ modifiable

bool modifiable = false

Flag that indicates if the layer data can be modified (so far used for features only)

◆ modified

bool modified = false

Flag that indicates that the layer data was modified since loading it.

◆ name_

String name_
private

layer name

◆ name_suffix_

String name_suffix_
private

an extra annotation as suffix to the layers name, e.g. '[39]' for which chromatogram index is currently shown in 1D

◆ param

Param param

Layer parameters.

Referenced by TOPPViewBase::loadFiles().

◆ peptide_hit_index

int peptide_hit_index = -1

◆ peptide_id_index

int peptide_id_index = -1

Selected peptide id and hit index (-1 if none is selected)

◆ type

◆ visible

bool visible = true