libpappsomspp
Library for mass spectrometry
pappso::FilterGreatestY Class Reference

keep N datapoints form the greatest intensities to the lowest More...

#include <filterpass.h>

Inheritance diagram for pappso::FilterGreatestY:
pappso::FilterInterface

Public Member Functions

 FilterGreatestY (std::size_t number_of_points=0)
 constructor with the number of datapoints to keep More...
 
 FilterGreatestY (const FilterGreatestY &other)
 
virtual ~FilterGreatestY ()
 
FilterGreatestYoperator= (const FilterGreatestY &other)
 
Tracefilter (Trace &data_points) const override
 
std::size_t getNumberOfPoints () const
 

Private Attributes

std::size_t m_numberOfPoints = 0
 

Detailed Description

keep N datapoints form the greatest intensities to the lowest

Definition at line 113 of file filterpass.h.

Constructor & Destructor Documentation

◆ FilterGreatestY() [1/2]

FilterGreatestY::FilterGreatestY ( std::size_t  number_of_points = 0)

constructor with the number of datapoints to keep

Definition at line 142 of file filterpass.cpp.

143  : m_numberOfPoints(number_of_points)
144 {
145 }

◆ FilterGreatestY() [2/2]

FilterGreatestY::FilterGreatestY ( const FilterGreatestY other)

Definition at line 148 of file filterpass.cpp.

150 {
151 }

◆ ~FilterGreatestY()

virtual pappso::FilterGreatestY::~FilterGreatestY ( )
inlinevirtual

Definition at line 120 of file filterpass.h.

120 :
121  MassSpectrumFilterGreatestItensities(std::size_t number_of_points = 0);

Member Function Documentation

◆ filter()

Trace & FilterGreatestY::filter ( Trace data_points) const
overridevirtual

Implements pappso::FilterInterface.

Definition at line 164 of file filterpass.cpp.

165 {
166 
167  // Reverse-sort the data points (in y decreasing order) so that we get the
168  // greatest to the front of the vector and we'll then copy the first n data
169  // points to the returned vector. See that return (b < a) ?
170  if(m_numberOfPoints >= data_points.size())
171  return data_points;
172 
173  std::sort(data_points.begin(),
174  data_points.end(),
175  [](const DataPoint &a, const DataPoint &b) { return (b.y < a.y); });
176 
177  data_points.erase(data_points.begin() + m_numberOfPoints, data_points.end());
178 
179  // And now sort the Trace conventionally, that is in x increasing order.
180  std::sort(data_points.begin(),
181  data_points.end(),
182  [](const DataPoint &a, const DataPoint &b) { return (a.x < b.x); });
183 
184 
185  return data_points;
186 }

References pappso::a, pappso::b, and m_numberOfPoints.

Referenced by pappso::MassSpectrumFilterGreatestItensities::filter().

◆ getNumberOfPoints()

std::size_t FilterGreatestY::getNumberOfPoints ( ) const

Definition at line 189 of file filterpass.cpp.

190 {
191  return m_numberOfPoints;
192 }

References m_numberOfPoints.

◆ operator=()

FilterGreatestY & FilterGreatestY::operator= ( const FilterGreatestY other)

Definition at line 155 of file filterpass.cpp.

156 {
158 
159  return *this;
160 }

References m_numberOfPoints.

Member Data Documentation

◆ m_numberOfPoints

std::size_t pappso::FilterGreatestY::m_numberOfPoints = 0
private

Definition at line 129 of file filterpass.h.

Referenced by filter(), getNumberOfPoints(), and operator=().


The documentation for this class was generated from the following files:
pappso::DataPoint
Definition: datapoint.h:20
pappso::FilterGreatestY::m_numberOfPoints
std::size_t m_numberOfPoints
Definition: filterpass.h:129