libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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
 
 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 142 of file filterpass.cpp.

142 : m_numberOfPoints(number_of_points)
143{
144}
std::size_t m_numberOfPoints
Definition filterpass.h:114

References m_numberOfPoints.

Referenced by FilterGreatestY(), and operator=().

◆ FilterGreatestY() [2/2]

FilterGreatestY::FilterGreatestY ( const FilterGreatestY & other)

Definition at line 147 of file filterpass.cpp.

149{
150}

References FilterGreatestY(), and m_numberOfPoints.

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

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

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

Referenced by pappso::cbor::psm::PsmSpecGlob::filterMassSpectrum(), and pappso::cbor::psm::PsmSpecPeptidOms::filterMassSpectrum().

◆ getNumberOfPoints()

std::size_t FilterGreatestY::getNumberOfPoints ( ) const

Definition at line 188 of file filterpass.cpp.

189{
190 return m_numberOfPoints;
191}

References m_numberOfPoints.

◆ operator=()

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

Definition at line 154 of file filterpass.cpp.

155{
157
158 return *this;
159}

References FilterGreatestY(), and 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 FilterGreatestY(), FilterGreatestY(), filter(), getNumberOfPoints(), and operator=().


The documentation for this class was generated from the following files: