OpenMS  2.6.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-2020.
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 SpectrumWidget;
56  class SpectrumCanvas;
57 
63  class OPENMS_GUI_DLLAPI LayerStatisticsDialog :
64  public QDialog
65  {
66  Q_OBJECT
67 
68 public:
69 
72 
74 
75 protected slots:
76 
78  void showDistribution_();
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 
109  void computePeakStats_();
111  void computeFeatureStats_();
113  void computeConsensusStats_();
115  template <typename MetaDataIterator>
116  void computeMetaDataArrayStats_(MetaDataIterator begin, MetaDataIterator end);
118  void bringInMetaStats_(const MetaInfoInterface & meta_interface);
120  void computeMetaAverages_();
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 }
OpenMS::LayerStatisticsDialog::min_elements_
double min_elements_
Minimum number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:149
OpenMS::LayerStatisticsDialog::computeMetaDataArrayStats_
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
OpenMS::LayerStatisticsDialog::max_charge_
double max_charge_
Maximum charge value.
Definition: LayerStatisticsDialog.h:139
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::Constants::c
const double c
OpenMS::LayerStatisticsDialog::avg_quality_
double avg_quality_
Average quality value.
Definition: LayerStatisticsDialog.h:147
QDialog
OpenMS::SpectrumWidget
Base class for spectrum widgets.
Definition: SpectrumWidget.h:80
OpenMS::LayerStatisticsDialog::MetaStatsValue_::min
double min
Definition: LayerStatisticsDialog.h:96
OpenMS::LayerStatisticsDialog::max_intensity_
double max_intensity_
Maximum intensity value.
Definition: LayerStatisticsDialog.h:133
OpenMS::LayerStatisticsDialog::ConsensusIterator_
LayerData::ConsensusMapType::ConstIterator ConsensusIterator_
Iterates over features of a feature map.
Definition: LayerStatisticsDialog.h:104
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::LayerStatisticsDialog::layer_data_
LayerData layer_data_
The LayerData object we compute statistics about.
Definition: LayerStatisticsDialog.h:129
OpenMS::LayerStatisticsDialog::canvas_
SpectrumCanvas * canvas_
The canvas of the layer.
Definition: LayerStatisticsDialog.h:127
OpenMS::LayerStatisticsDialog::MetaStatsValue_::MetaStatsValue_
MetaStatsValue_(unsigned long c=0, double mi=0, double ma=0, double a=0)
Definition: LayerStatisticsDialog.h:87
OpenMS::LayerStatisticsDialog::min_charge_
double min_charge_
Minimum charge value.
Definition: LayerStatisticsDialog.h:137
Ui
Definition: SwathWizardBase.h:62
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::LayerData
Class that stores the data for one layer.
Definition: LayerData.h:85
OpenMS::LayerStatisticsDialog::avg_elements_
double avg_elements_
Average number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:153
OpenMS::LayerStatisticsDialog::avg_charge_
double avg_charge_
Average charge value.
Definition: LayerStatisticsDialog.h:141
OpenMS::LayerStatisticsDialog::MetaStatsValue_
Struct representing the statistics about one meta information.
Definition: LayerStatisticsDialog.h:85
OpenMS::ConsensusMap::ConstIterator
std::vector< ConsensusFeature >::const_iterator ConstIterator
Non-mutable iterator.
Definition: ConsensusMap.h:172
OpenMS::LayerStatisticsDialog::max_elements_
double max_elements_
Maximum number of elements (for consensus features only)
Definition: LayerStatisticsDialog.h:151
OpenMS::LayerStatisticsDialog::MetaStatsValue_::max
double max
Definition: LayerStatisticsDialog.h:96
OpenMS::LayerStatisticsDialog::MetaStatsValue_::avg
double avg
Definition: LayerStatisticsDialog.h:96
OpenMS::LayerStatisticsDialog::min_intensity_
double min_intensity_
Minimum intensity value.
Definition: LayerStatisticsDialog.h:131
OpenMS::LayerStatisticsDialog::avg_intensity_
double avg_intensity_
Average intensity value.
Definition: LayerStatisticsDialog.h:135
OpenMS::LayerStatisticsDialog::FeatureIterator_
LayerData::FeatureMapType::ConstIterator FeatureIterator_
Iterates over features of a feature map.
Definition: LayerStatisticsDialog.h:102
OpenMS::SpectrumCanvas
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:98
OpenMS::LayerStatisticsDialog::meta_array_stats_
std::map< String, MetaStatsValue_ > meta_array_stats_
Map containing the statistics about the FloatDataArrays of all spectra in this layer.
Definition: LayerStatisticsDialog.h:125
LayerData.h
OpenMS::MSExperiment::ConstIterator
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSExperiment.h:113
OpenMS::LayerStatisticsDialog::PeakIterator_
LayerData::ExperimentType::SpectrumType::ConstIterator PeakIterator_
Iterates over peaks of a spectrum.
Definition: LayerStatisticsDialog.h:100
OpenMS::FeatureMap::ConstIterator
Base::const_iterator ConstIterator
Definition: FeatureMap.h:144
OpenMS::LayerStatisticsDialog::MetaIterator_
std::map< UInt, MetaStatsValue_ >::iterator MetaIterator_
Iterates over the meta_stats map.
Definition: LayerStatisticsDialog.h:106
OpenMS::LayerStatisticsDialog::max_quality_
double max_quality_
Maximum quality value.
Definition: LayerStatisticsDialog.h:145
OpenMS::LayerStatisticsDialog::meta_stats_
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
OpenMS::LayerStatisticsDialog
Dialog showing statistics about the data of the current layer.
Definition: LayerStatisticsDialog.h:63
OpenMS::LayerStatisticsDialog::MetaStatsValue_::count
unsigned long count
Definition: LayerStatisticsDialog.h:95
OpenMS::LayerStatisticsDialog::min_quality_
double min_quality_
Minimum quality value.
Definition: LayerStatisticsDialog.h:143
OpenMS::LayerStatisticsDialog::ui_
Ui::LayerStatisticsDialogTemplate * ui_
Definition: LayerStatisticsDialog.h:159