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 146 of file filterpass.cpp.

147  : m_numberOfPoints(number_of_points)
148 {
149 }
std::size_t m_numberOfPoints
Definition: filterpass.h:114

◆ FilterGreatestY() [2/2]

FilterGreatestY::FilterGreatestY ( const FilterGreatestY other)

Definition at line 152 of file filterpass.cpp.

154 {
155 }

◆ ~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 168 of file filterpass.cpp.

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

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

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

◆ getNumberOfPoints()

std::size_t FilterGreatestY::getNumberOfPoints ( ) const

Definition at line 193 of file filterpass.cpp.

194 {
195  return m_numberOfPoints;
196 }

References m_numberOfPoints.

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

◆ operator=()

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

Definition at line 159 of file filterpass.cpp.

160 {
162 
163  return *this;
164 }

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: