OpenMS  2.7.0
LayerStatisticsDialog.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-2021.
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 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
41 
42 #include <QtWidgets/QDialog>
43 #include <QtWidgets/QPushButton>
44 
45 #include <utility>
46 #include <map>
47 
48 namespace Ui
49 {
50  class LayerStatisticsDialogTemplate;
51 }
52 
53 namespace OpenMS
54 {
55  class PlotWidget;
56  class PlotCanvas;
57 
63  class OPENMS_GUI_DLLAPI LayerStatisticsDialog :
64  public QDialog
65  {
66  Q_OBJECT
67 
68 public:
69 
72 
74 
75 protected slots:
76 
79 
80 protected:
81 
86  {
87  MetaStatsValue_(unsigned long c = 0, double mi = 0, double ma = 0, double a = 0)
88  {
89  count = c;
90  min = mi;
91  max = ma;
92  avg = a;
93  }
94 
95  unsigned long count;
96  double min, max, avg;
97  };
98 
106  typedef std::map<UInt, MetaStatsValue_>::iterator MetaIterator_;
107 
115  template <typename MetaDataIterator>
116  void computeMetaDataArrayStats_(MetaDataIterator begin, MetaDataIterator end);
118  void bringInMetaStats_(const MetaInfoInterface & meta_interface);
121 
123  std::map<UInt, MetaStatsValue_> meta_stats_;
125  std::map<String, MetaStatsValue_> meta_array_stats_;
137  double min_charge_;
139  double max_charge_;
141  double avg_charge_;
143  double min_quality_;
145  double max_quality_;
147  double avg_quality_;
154 
155 private:
158 
159  Ui::LayerStatisticsDialogTemplate* ui_;
160 
161  };
162 
163  template <typename MetaDataIterator>
164  void LayerStatisticsDialog::computeMetaDataArrayStats_(MetaDataIterator begin, MetaDataIterator end)
165  {
166  for (MetaDataIterator meta_array_it = begin; meta_array_it != end; meta_array_it++)
167  {
168  String meta_name = meta_array_it->getName();
169  MetaStatsValue_ meta_stats_value;
170  std::map<String, MetaStatsValue_>::iterator it = meta_array_stats_.find(meta_name);
171  if (it != meta_array_stats_.end()) // stats about this meta name already exist -> bring this value in
172  {
173  meta_stats_value = it->second;
174  for (typename MetaDataIterator::value_type::const_iterator value_it = meta_array_it->begin(); value_it != meta_array_it->end(); value_it++)
175  {
176  float value = *value_it;
177  meta_stats_value.count++;
178  if (value < meta_stats_value.min)
179  {
180  meta_stats_value.min = value;
181  }
182  else if (value > meta_stats_value.max)
183  {
184  meta_stats_value.max = value;
185  }
186  meta_stats_value.avg += value;
187  }
188  it->second = meta_stats_value;
189  }
190  else if (meta_array_it->size() > 0) // meta name has not occurred before, create new stats for it:
191  {
192  float init_value = *(meta_array_it->begin());
193  meta_stats_value = MetaStatsValue_(0, init_value, init_value, 0);
194  for (typename MetaDataIterator::value_type::const_iterator value_it = meta_array_it->begin(); value_it != meta_array_it->end(); value_it++)
195  {
196  float value = *value_it;
197  meta_stats_value.count++;
198  if (value < meta_stats_value.min)
199  {
200  meta_stats_value.min = value;
201  }
202  else if (value > meta_stats_value.max)
203  {
204  meta_stats_value.max = value;
205  }
206  meta_stats_value.avg += value;
207  }
208  meta_array_stats_.insert(make_pair(meta_name, meta_stats_value));
209  }
210  }
211  }
212 
213 }
std::vector< ConsensusFeature >::const_iterator ConstIterator
Non-mutable iterator.
Definition: ConsensusMap.h:176
Base::const_iterator ConstIterator
Definition: FeatureMap.h:144
Class that stores the data for one layer.
Definition: LayerData.h:96
Dialog showing statistics about the data of the current layer.
Definition: LayerStatisticsDialog.h:65
double min_intensity_
Minimum intensity value.
Definition: LayerStatisticsDialog.h:131
double avg_quality_
Average quality value.
Definition: LayerStatisticsDialog.h:147
void computeConsensusStats_()
Computes the statistics of a consensus feature layer.
LayerData::ConsensusMapType::ConstIterator ConsensusIterator_
Iterates over features of a feature map.
Definition: LayerStatisticsDialog.h:104
void computeMetaAverages_()
Computes the averages of all meta values stored in meta_stats and meta_array_stats.
void showDistribution_()
Shows the distribution according to the clicked button.
double max_elements_
Maximum number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:151
const LayerData & layer_data_
The LayerData object we compute statistics about.
Definition: LayerStatisticsDialog.h:129
std::map< UInt, MetaStatsValue_ > meta_stats_
Map containing the statistics about all meta information of the peaks/features in the layer.
Definition: LayerStatisticsDialog.h:123
double max_quality_
Maximum quality value.
Definition: LayerStatisticsDialog.h:145
std::map< UInt, MetaStatsValue_ >::iterator MetaIterator_
Iterates over the meta_stats map.
Definition: LayerStatisticsDialog.h:106
LayerStatisticsDialog(PlotWidget *parent)
Constructor.
double avg_charge_
Average charge value.
Definition: LayerStatisticsDialog.h:141
LayerData::FeatureMapType::ConstIterator FeatureIterator_
Iterates over features of a feature map.
Definition: LayerStatisticsDialog.h:102
double avg_elements_
Average number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:153
void computeFeatureStats_()
Computes the statistics of a feature layer.
void bringInMetaStats_(const MetaInfoInterface &meta_interface)
Brings the meta values of one meta_interface (a peak or feature) into the statistics.
PlotCanvas * canvas_
The canvas of the layer.
Definition: LayerStatisticsDialog.h:127
LayerData::ExperimentType::SpectrumType::ConstIterator PeakIterator_
Iterates over peaks of a spectrum.
Definition: LayerStatisticsDialog.h:100
double max_intensity_
Maximum intensity value.
Definition: LayerStatisticsDialog.h:133
void computeMetaDataArrayStats_(MetaDataIterator begin, MetaDataIterator end)
Computes the statistics of all meta data contained in the FloatDataArray or IntegerDataArray of an MS...
Definition: LayerStatisticsDialog.h:164
Ui::LayerStatisticsDialogTemplate * ui_
Definition: LayerStatisticsDialog.h:159
LayerStatisticsDialog()
Not implemented.
double avg_intensity_
Average intensity value.
Definition: LayerStatisticsDialog.h:135
double max_charge_
Maximum charge value.
Definition: LayerStatisticsDialog.h:139
void computePeakStats_()
Computes the statistics of a peak layer.
double min_charge_
Minimum charge value.
Definition: LayerStatisticsDialog.h:137
std::map< String, MetaStatsValue_ > meta_array_stats_
Map containing the statistics about the FloatDataArrays of all spectra in this layer.
Definition: LayerStatisticsDialog.h:125
double min_elements_
Minimum number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:149
double min_quality_
Minimum quality value.
Definition: LayerStatisticsDialog.h:143
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Base class for visualization canvas classes.
Definition: PlotCanvas.h:136
Base class for spectrum widgets.
Definition: PlotWidget.h:83
A more convenient string class.
Definition: String.h:61
const double c
Definition: Constants.h:209
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: SwathWizardBase.h:63
Struct representing the statistics about one meta information.
Definition: LayerStatisticsDialog.h:86
double max
Definition: LayerStatisticsDialog.h:96
unsigned long count
Definition: LayerStatisticsDialog.h:95
double avg
Definition: LayerStatisticsDialog.h:96
double min
Definition: LayerStatisticsDialog.h:96
MetaStatsValue_(unsigned long c=0, double mi=0, double ma=0, double a=0)
Definition: LayerStatisticsDialog.h:87