29 #include "../../trace/trace.h"
32 #include "../../massspectrum/massspectrum.h"
33 #include "../../exception/exceptionoutofrange.h"
34 #include "../../exception/exceptionnotrecognized.h"
43 : m_passY(other.m_passY)
59 Trace new_data_points;
60 for(
auto &&data_point : data_points)
64 new_data_points.push_back(data_point);
67 data_points = std::move(new_data_points);
75 : m_passY(other.m_passY)
91 Trace new_data_points;
92 for(
auto &&data_point : data_points)
96 new_data_points.push_back(data_point);
99 data_points = std::move(new_data_points);
105 : m_ratioPassY(ratio_pass_y)
111 : m_ratioPassY(other.m_ratioPassY)
127 auto it_max =
maxYDataPoint(data_points.begin(), data_points.end());
128 if(it_max == data_points.end())
131 Trace new_data_points;
132 for(
auto &&data_point : data_points)
134 if(data_point.y > pass)
136 new_data_points.push_back(data_point);
139 data_points = std::move(new_data_points);
145 : m_numberOfPoints(number_of_points)
151 : m_numberOfPoints(other.m_numberOfPoints)
175 std::sort(data_points.begin(),
179 data_points.erase(data_points.begin() +
m_numberOfPoints, data_points.end());
182 std::sort(data_points.begin(),
198 double window_range, std::size_t number_of_points_per_window)
199 : m_xWindowRange(window_range), m_numberOfPoints(number_of_points_per_window)
206 QObject::tr(
"window_range must be greater than 0.5"));
215 : m_xWindowRange(other.m_xWindowRange),
216 m_numberOfPoints(other.m_numberOfPoints)
236 std::vector<DataPoint> new_trace(data_points);
239 int window_number = 0;
240 int old_window_number = -1;
241 std::size_t number_of_peaks_in_window = 0;
242 auto itbegin = data_points.begin();
243 std::vector<DataPoint>::iterator it_min;
255 qDebug() <<
" data_point.x=" << data_point.x
256 <<
" data_point.y=" << data_point.y;
258 qDebug() << window_number;
259 if(window_number != old_window_number)
261 old_window_number = window_number;
262 number_of_peaks_in_window = 0;
263 itbegin = data_points.end();
268 data_points.push_back(data_point);
269 number_of_peaks_in_window++;
270 if(number_of_peaks_in_window == 1)
272 itbegin = data_points.begin() + (data_points.size() - 1);
280 if(it_min != data_points.end())
283 if(it_min->y < data_point.y)
286 *it_min = data_point;
329 for(
auto &&dataPoint : data_points)
331 dataPoint.y = std::floor(dataPoint.y);
353 for(
auto &&dataPoint : data_points)
355 dataPoint.y = std::round(dataPoint.y);
365 : m_dynamic(other.m_dynamic)
373 auto it_max =
maxYDataPoint(data_points.begin(), data_points.end());
374 if(it_max == data_points.end())
376 double maximum = it_max->y;
377 for(
auto &&dataPoint : data_points)
379 dataPoint.y = (dataPoint.y / maximum) *
m_dynamic;
401 std::size_t number_of_points)
402 : m_filterGreatestY(number_of_points)
408 : m_filterGreatestY(other.m_filterGreatestY)
434 : m_factor(other.m_factor)
452 for(
auto &&dataPoint : data_points)
454 dataPoint.y = dataPoint.y *
m_factor;
465 : m_valueToRemove(valueToRemove)
470 : m_valueToRemove(other.m_valueToRemove)
490 for(
auto &&dataPoint : data_points)
502 : m_quantile(quantile)
508 : m_quantile(other.m_quantile)
529 if(data_points.size() == 0)
531 double value_to_temove =
532 quantileYTrace(data_points.begin(), data_points.end(), m_quantile);
533 for(
auto &&dataPoint : data_points)
535 if(dataPoint.y < value_to_temove)
538 dataPoint.y = dataPoint.y - value_to_temove;
544 const QString &strBuildParams)
546 buildFilterFromString(strBuildParams);
552 const QString &strBuildParams)
556 if(strBuildParams.startsWith(
"passQuantileBasedRemoveY|"))
559 strBuildParams.split(
"|").back().split(
";", Qt::SkipEmptyParts);
561 QString value = params.at(0);
562 m_quantile = value.toDouble();
568 "building passQuantileBasedRemoveY from string %1 is not possible")
569 .arg(strBuildParams));
578 return "passQuantileBasedRemoveY";
585 QString strCode = QString(
"%1|%2").arg(name()).arg(m_quantile);
excetion to use when an item type is not recognized
apply std::floor (round to lowest integer) to all Y values
FilterFloorY & operator=(const FilterFloorY &other)
Trace & filter(Trace &data_points) const override
keep N datapoints form the greatest intensities to the lowest
Trace & filter(Trace &data_points) const override
FilterGreatestY(std::size_t number_of_points=0)
constructor with the number of datapoints to keep
FilterGreatestY & operator=(const FilterGreatestY &other)
std::size_t getNumberOfPoints() const
std::size_t m_numberOfPoints
keep N datapoints form the greatest intensities to the lowest within a mass range in dalton
Trace & filter(Trace &data_points) const override
std::size_t m_numberOfPoints
FilterGreatestYperWindow(double window_range, std::size_t number_of_points_per_window)
constructor with the number of datapoints to keep
FilterGreatestYperWindow & operator=(const FilterGreatestYperWindow &other)
std::size_t getNumberOfPoints() const
remove datapoints below a given intensity percentage (ratio) of the maximum intensity
FilterHighPassPercentage(double y_ratio)
Trace & filter(Trace &data_points) const override
FilterHighPassPercentage & operator=(const FilterHighPassPercentage &other)
remove datapoints below a given Y value (intensity)
Trace & filter(Trace &data_points) const override
FilterHighPass & operator=(const FilterHighPass &other)
FilterHighPass(double pass_y)
remove datapoints higher than a given Y value (intensity)
FilterLowPass(double pass_y)
Trace & filter(Trace &data_points) const override
FilterLowPass & operator=(const FilterLowPass &other)
removes a value found by quantile to all Y values
double getQuantileThreshold() const
FilterQuantileBasedRemoveY & operator=(const FilterQuantileBasedRemoveY &other)
FilterQuantileBasedRemoveY(double quantile_threshold)
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
Trace & filter(Trace &data_points) const override
QString toString() const override
virtual QString name() const override
removes a value to all Y values
FilterRemoveY(double valueToRemove)
Trace & filter(Trace &data_points) const override
FilterRemoveY & operator=(const FilterRemoveY &other)
rescales Y values into a dynamic range if the dynamic range is set to 0, this filter is ignored
Trace & filter(Trace &data_points) const override
FilterRescaleY(double dynamic)
double getDynamicRange() const
FilterRescaleY & operator=(const FilterRescaleY &other)
apply std::round (round to nearest integer) to all Y values
Trace & filter(Trace &data_points) const override
FilterRoundY & operator=(const FilterRoundY &other)
rescales Y values given a tranformation factor
FilterScaleFactorY & operator=(const FilterScaleFactorY &other)
FilterScaleFactorY(double m_factor)
Trace & filter(Trace &data_points) const override
double getScaleFactorY() const
MassSpectrumFilterGreatestItensities(std::size_t number_of_points=0)
FilterGreatestY m_filterGreatestY
MassSpectrum & filter(MassSpectrum &spectrum) const override
MassSpectrumFilterGreatestItensities & operator=(const MassSpectrumFilterGreatestItensities &other)
Class to represent a mass spectrum.
A simple container of DataPoint instances.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
std::vector< DataPoint >::const_iterator minYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
double quantileYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double quantile)
calculate the quantile of y value of a trace