pappsomspp
Library for mass spectrometry
pappso::FilterGreatestY Class Reference

#include <filterpass.h>

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

Public Member Functions

 FilterGreatestY (std::size_t number_of_points=0)
 
 FilterGreatestY (const FilterGreatestY &other)
 
virtual ~FilterGreatestY ()
 
Tracefilter (Trace &data_points) const override
 
std::size_t getNumberOfPoints () const
 

Private Attributes

std::size_t m_number_of_points = 0
 

Detailed Description

Definition at line 92 of file filterpass.h.

Constructor & Destructor Documentation

◆ FilterGreatestY() [1/2]

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

Definition at line 111 of file filterpass.cpp.

112  : m_number_of_points(number_of_points)
113 {
114 }

◆ FilterGreatestY() [2/2]

FilterGreatestY::FilterGreatestY ( const FilterGreatestY other)

Definition at line 117 of file filterpass.cpp.

119 {
120 }

◆ ~FilterGreatestY()

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

Definition at line 100 of file filterpass.h.

103 : public FilterInterface

Member Function Documentation

◆ filter()

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

Implements pappso::FilterInterface.

Definition at line 123 of file filterpass.cpp.

124 {
125 
126  // Reverse-sort the data points (in y decreasing order) so that we get the
127  // greatest to the front of the vector and we'll then copy the first n data
128  // points to the returned vector. See that return (b < a) ?
129  if(m_number_of_points >= data_points.size())
130  return data_points;
131 
132  std::sort(data_points.begin(),
133  data_points.end(),
134  [](const DataPoint &a, const DataPoint &b) { return (b.y < a.y); });
135 
136  data_points.erase(data_points.begin() + m_number_of_points,
137  data_points.end());
138 
139  // And now sort the Trace conventionally, that is in x increasing order.
140  std::sort(data_points.begin(),
141  data_points.end(),
142  [](const DataPoint &a, const DataPoint &b) { return (a.x < b.x); });
143 
144 
145  return data_points;
146 }

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

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

◆ getNumberOfPoints()

std::size_t FilterGreatestY::getNumberOfPoints ( ) const

Definition at line 149 of file filterpass.cpp.

150 {
151  return m_number_of_points;
152 }

References m_number_of_points.

Member Data Documentation

◆ m_number_of_points

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

Definition at line 95 of file filterpass.h.

Referenced by filter(), and getNumberOfPoints().


The documentation for this class was generated from the following files:
pappso::PeptideIonNter::a
pappso::DataPoint
Definition: datapoint.h:20
pappso::FilterGreatestY::m_number_of_points
std::size_t m_number_of_points
Definition: filterpass.h:95
pappso::PeptideIonNter::b