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
 
- Public Member Functions inherited from pappso::FilterInterface
virtual ~FilterInterface ()
 

Private Attributes

std::size_t m_numberOfPoints = 0
 

Detailed Description

keep N datapoints form the greatest intensities to the lowest

Definition at line 95 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

Parameters
number_of_pointsmaximum number of points accepted in resulting spectrum

Definition at line 143 of file filterpass.cpp.

144  : m_numberOfPoints(number_of_points)
145 {
146 }

◆ FilterGreatestY() [2/2]

FilterGreatestY::FilterGreatestY ( const FilterGreatestY other)

Definition at line 149 of file filterpass.cpp.

151 {
152 }

◆ ~FilterGreatestY()

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

Definition at line 105 of file filterpass.h.

105 {};

Member Function Documentation

◆ filter()

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

Implements pappso::FilterInterface.

Definition at line 165 of file filterpass.cpp.

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

References m_numberOfPoints.

Referenced by pappso::MassSpectrumFilterGreatestItensities::filter(), and pappso::XtandemSpectrumProcess::process().

◆ getNumberOfPoints()

std::size_t FilterGreatestY::getNumberOfPoints ( ) const

Definition at line 190 of file filterpass.cpp.

191 {
192  return m_numberOfPoints;
193 }

References m_numberOfPoints.

Referenced by pappso::XtandemSpectrumProcess::getNmostIntense().

◆ operator=()

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

Definition at line 156 of file filterpass.cpp.

157 {
159 
160  return *this;
161 }

References m_numberOfPoints.

Member Data Documentation

◆ m_numberOfPoints

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

Definition at line 114 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:21
pappso::FilterGreatestY::m_numberOfPoints
std::size_t m_numberOfPoints
Definition: filterpass.h:114