libpappsomspp
Library for mass spectrometry
filterpass.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/filers/filterpass.h
3  * \date 26/04/2019
4  * \author Olivier Langella
5  * \brief collection of filters concerned by Y selection
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #pragma once
29 
30 #include "filternameinterface.h"
31 #include <cstddef>
32 #include "../../exportinmportconfig.h"
33 
34 
35 namespace pappso
36 {
37 
38 /** @brief remove datapoints higher than a given Y value (intensity)
39  */
41 {
42  private:
43  double m_passY = 0;
44 
45  public:
46  FilterLowPass(double pass_y);
47  FilterLowPass(const FilterLowPass &other);
48  virtual ~FilterLowPass(){};
49 
50  FilterLowPass &operator=(const FilterLowPass &other);
51 
52  Trace &filter(Trace &data_points) const override;
53 };
54 
55 /** @brief remove datapoints below a given Y value (intensity)
56  */
58 {
59  private:
60  double m_passY = 0;
61 
62  public:
63  FilterHighPass(double pass_y);
64  FilterHighPass(const FilterHighPass &other);
65  virtual ~FilterHighPass(){};
66 
67  FilterHighPass &operator=(const FilterHighPass &other);
68 
69  Trace &filter(Trace &data_points) const override;
70 };
71 
72 /** @brief remove datapoints below a given intensity percentage (ratio) of the
73  * maximum intensity
74  */
76 {
77 
78  public:
79  FilterHighPassPercentage(double y_ratio);
82 
83  FilterHighPassPercentage &operator=(const FilterHighPassPercentage &other);
84 
85  Trace &filter(Trace &data_points) const override;
86 
87 
88  private:
89  double m_ratioPassY = 0;
90 };
91 
92 
93 /** @brief keep N datapoints form the greatest intensities to the lowest
94  */
96 {
97  public:
98  /** @brief constructor with the number of datapoints to keep
99  *
100  * @param number_of_points maximum number of points accepted in resulting
101  * spectrum
102  */
103  FilterGreatestY(std::size_t number_of_points = 0);
104  FilterGreatestY(const FilterGreatestY &other);
105  virtual ~FilterGreatestY(){};
106 
107  FilterGreatestY &operator=(const FilterGreatestY &other);
108  Trace &filter(Trace &data_points) const override;
109 
110  std::size_t getNumberOfPoints() const;
111 
112 
113  private:
114  std::size_t m_numberOfPoints = 0;
115 };
116 
117 
118 /** @brief keep N datapoints form the greatest intensities to the lowest within
119  * a mass range in dalton
120  */
122 {
123  public:
124  /** @brief constructor with the number of datapoints to keep
125  *
126  * @param window_range mass range to consider (must be greater than 0.5)
127  * @param number_of_points_per_window maximum number of points accepted per
128  * mass window in resulting spectrum
129  */
130  FilterGreatestYperWindow(double window_range,
131  std::size_t number_of_points_per_window);
134 
135  FilterGreatestYperWindow &operator=(const FilterGreatestYperWindow &other);
136  Trace &filter(Trace &data_points) const override;
137 
138  std::size_t getNumberOfPoints() const;
139 
140 
141  private:
142  double m_xWindowRange = 1;
143  std::size_t m_numberOfPoints = 0;
144 };
145 
148 {
149  private:
151 
152  public:
153  MassSpectrumFilterGreatestItensities(std::size_t number_of_points = 0);
157 
159  operator=(const MassSpectrumFilterGreatestItensities &other);
160  MassSpectrum &filter(MassSpectrum &spectrum) const override;
161 };
162 
163 /** @brief apply std::floor (round to lowest integer) to all Y values
164  */
166 {
167 
168  public:
169  FilterFloorY();
170  FilterFloorY(const FilterFloorY &other);
171  virtual ~FilterFloorY(){};
172 
173  FilterFloorY &operator=(const FilterFloorY &other);
174  Trace &filter(Trace &data_points) const override;
175 };
176 
177 
178 /** @brief apply std::round (round to nearest integer) to all Y values
179  */
181 {
182 
183  public:
184  FilterRoundY();
185  FilterRoundY(const FilterRoundY &other);
186  virtual ~FilterRoundY(){};
187 
188  FilterRoundY &operator=(const FilterRoundY &other);
189  Trace &filter(Trace &data_points) const override;
190 };
191 
192 /** @brief rescales Y values into a dynamic range
193  * if the dynamic range is set to 0, this filter is ignored
194  */
196 {
197  private:
198  double m_dynamic = 0;
199 
200  public:
201  FilterRescaleY(double dynamic);
202  FilterRescaleY(const FilterRescaleY &other);
203  virtual ~FilterRescaleY(){};
204 
205  FilterRescaleY &operator=(const FilterRescaleY &other);
206  double getDynamicRange() const;
207 
208  Trace &filter(Trace &data_points) const override;
209 };
210 
211 
212 /** @brief rescales Y values given a tranformation factor
213  */
215 {
216  private:
217  double m_factor = 0;
218 
219  public:
220  FilterScaleFactorY(double m_factor);
222  virtual ~FilterScaleFactorY(){};
223 
224  FilterScaleFactorY &operator=(const FilterScaleFactorY &other);
225 
226  Trace &filter(Trace &data_points) const override;
227 
228  double getScaleFactorY() const;
229 };
230 
231 
232 /** @brief removes a value to all Y values
233  */
235 {
236  private:
237  double m_valueToRemove = 0;
238 
239  public:
240  FilterRemoveY(double valueToRemove);
241  FilterRemoveY(const FilterRemoveY &other);
242  virtual ~FilterRemoveY(){};
243 
244  FilterRemoveY &operator=(const FilterRemoveY &other);
245 
246  Trace &filter(Trace &data_points) const override;
247 
248  double getValue() const;
249 };
250 
251 
252 /** @brief removes a value found by quantile to all Y values
253  *
254  * sort all values by Y intensity and take the iest value located at the defined
255  * quantile the use it to remove this value to all Y intensities
256  */
258 {
259  public:
260  FilterQuantileBasedRemoveY(double quantile_threshold);
261 
262  /**
263  * @param strBuildParams string to build the filter
264  * "passQuantileBasedRemoveY|0.6"
265  */
266  FilterQuantileBasedRemoveY(const QString &strBuildParams);
267 
270 
272  operator=(const FilterQuantileBasedRemoveY &other);
273 
274  Trace &filter(Trace &data_points) const override;
275 
276  double getQuantileThreshold() const;
277 
278  virtual QString name() const override;
279  QString toString() const override;
280 
281  protected:
282  void buildFilterFromString(const QString &strBuildParams) override;
283 
284  private:
285  double m_quantile = 0;
286 };
287 
288 } // namespace pappso
apply std::floor (round to lowest integer) to all Y values
Definition: filterpass.h:166
virtual ~FilterFloorY()
Definition: filterpass.h:171
FilterFloorY(const FilterFloorY &other)
keep N datapoints form the greatest intensities to the lowest
Definition: filterpass.h:96
virtual ~FilterGreatestY()
Definition: filterpass.h:105
keep N datapoints form the greatest intensities to the lowest within a mass range in dalton
Definition: filterpass.h:122
remove datapoints below a given intensity percentage (ratio) of the maximum intensity
Definition: filterpass.h:76
remove datapoints below a given Y value (intensity)
Definition: filterpass.h:58
virtual ~FilterHighPass()
Definition: filterpass.h:65
generic interface to apply a filter on a trace
remove datapoints higher than a given Y value (intensity)
Definition: filterpass.h:41
virtual ~FilterLowPass()
Definition: filterpass.h:48
Interface that allows to build filter objects from strings.
removes a value found by quantile to all Y values
Definition: filterpass.h:258
removes a value to all Y values
Definition: filterpass.h:235
virtual ~FilterRemoveY()
Definition: filterpass.h:242
rescales Y values into a dynamic range if the dynamic range is set to 0, this filter is ignored
Definition: filterpass.h:196
virtual ~FilterRescaleY()
Definition: filterpass.h:203
apply std::round (round to nearest integer) to all Y values
Definition: filterpass.h:181
virtual ~FilterRoundY()
Definition: filterpass.h:186
FilterRoundY(const FilterRoundY &other)
rescales Y values given a tranformation factor
Definition: filterpass.h:215
generic interface to apply a filter on a MassSpectrum This is the same as FilterInterface,...
Class to represent a mass spectrum.
Definition: massspectrum.h:71
A simple container of DataPoint instances.
Definition: trace.h:148
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39