29 #include "../../massspectrum/massspectrum.h"
53 spectrum.erase(begin_it, spectrum.end());
86 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
87 <<
" spectrum.size()=" << spectrum.size();
89 spectrum.erase(spectrum.begin(), last_it);
90 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
91 <<
" spectrum.size()=" << spectrum.size();
97 : m_minX(min_x), m_maxX(max_x)
133 spectrum.erase(begin_it, end_it);
142 : m_minX(min_x), m_maxX(max_x)
148 : m_minX(other.m_minX), m_maxX(other.m_maxX)
169 qDebug() <<
"The range to keep:" <<
m_minX <<
"-" <<
m_maxX;
174 qDebug() <<
"Found begin iterator (for m_minX) having:" << begin_it->x
179 if(end_it == spectrum.end())
181 qDebug() <<
"The end iterator (for m_maxX) is the end(). The prev "
183 << std::prev(end_it)->x <<
" x(m / z) value.";
186 qDebug() <<
"Found end iterator (for m_maxX) having:" << end_it->x
189 qDebug() <<
"Only keeping range" << begin_it->x <<
"-"
190 << std::prev(end_it)->x;
192 spectrum.erase(end_it, spectrum.end());
193 spectrum.erase(spectrum.begin(), begin_it);
201 : m_filterRange(mz_range.lower(), mz_range.upper())
208 : m_filterRange(other.m_filterRange)
215 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
217 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
224 : m_filterRange(mz_range.lower(), mz_range.upper())
230 : m_filterRange(other.m_filterRange)
269 selection_polygon_specs.end());
274 std::min(
m_lowestMz, item.selectionPolygon.getBottomMostPoint().y());
277 std::max(
m_greatestMz, item.selectionPolygon.getTopMostPoint().y());
293 std::min(
m_lowestMz, item.selectionPolygon.getBottomMostPoint().y());
296 std::max(
m_greatestMz, item.selectionPolygon.getTopMostPoint().y());
340 qFatal(
"Programming error.");
348 double rt_value)
const
361 qDebug() <<
"The lowest and greatest m/z values:" <<
m_lowestMz <<
"and"
369 trace = the_filter.
filter(trace);
375 auto begin_it = trace.begin();
376 auto end_it = trace.end();
378 qDebug() <<
"Iterating in the m/z range:" << begin_it->x <<
"-"
379 << std::prev(end_it)->x;
385 while(iter > begin_it)
392 qDebug() <<
"Iterating in trace data point with m/z value:" << iter->x;
398 double checked_value;
408 qFatal(
"Programming error.");
410 checked_value = dt_value;
416 checked_value = rt_value;
421 qFatal(
"Programming error.");
426 if(!spec.selectionPolygon.contains(QPointF(checked_value, iter->x)))
427 iter = trace.erase(iter);
461 qDebug() <<
"The left line goes: (" << xA_left <<
"," << yA_left
462 <<
")->(" << xB_left <<
"," << yB_left <<
")";
464 if((xB_left - xA_left) * (iter->x - yA_left) -
465 (yB_left - yA_left) * (checked_value - xA_left) >
471 qDebug() << qSetRealNumberPrecision(10)
472 <<
"Filtered out point (left of left line):"
473 << checked_value <<
"-" << iter->x;
475 iter = trace.erase(iter);
484 qDebug() << qSetRealNumberPrecision(10)
485 <<
"Kept point (right of left line):" << checked_value
503 qDebug() <<
"The right line goes: (" << xA_right <<
"," << yA_right
504 <<
")->(" << xB_right <<
"," << yB_right <<
")";
506 if((xB_right - xA_right) * (iter->x - yA_right) -
507 (yB_right - yA_right) * (checked_value - xA_right) <
510 qDebug() << qSetRealNumberPrecision(10)
511 <<
"Filtered out point (right of right line):"
512 << checked_value <<
"-" << iter->x;
516 iter = trace.erase(iter);
525 if(iter->x >= 449 && iter->x <= 450 && checked_value > 19.5 &&
528 << qSetRealNumberPrecision(10)
529 <<
"SHOULD NOT Definitively kept point (left of right line):"
530 << checked_value <<
"-" << iter->x;
533 << qSetRealNumberPrecision(10)
534 <<
"MIGHT Definitively kept point (left of right line):"
535 << checked_value <<
"-" << iter->x;
double getThresholdX() const
FilterResampleKeepGreater & operator=(const FilterResampleKeepGreater &other)
FilterResampleKeepGreater(double x_value)
Trace & filter(Trace &trace) const override
void newSelectionPolygonSpec(const SelectionPolygonSpec &selection_polygon_spec)
std::vector< SelectionPolygonSpec > m_selectionPolygonSpecs
virtual Trace & filter(Trace &data_points) const=0
FilterResampleKeepPointInPolygon & operator=(const FilterResampleKeepPointInPolygon &other)
FilterResampleKeepPointInPolygon()
Trace & filter(Trace &trace) const override
FilterResampleKeepSmaller(double x_value)
FilterResampleKeepXRange & operator=(const FilterResampleKeepXRange &other)
FilterResampleKeepXRange(double min_x=0, double max_x=0)
Trace & filter(Trace &trace) const override
FilterResampleRemoveXRange(double min_x, double max_x)
FilterResampleRemoveXRange & operator=(const FilterResampleRemoveXRange &other)
Trace & filter(Trace &trace) const override
MassSpectrumFilterResampleKeepMzRange(const MzRange &mz_range)
MassSpectrum & filter(MassSpectrum &spectrum) const override
const FilterResampleKeepXRange m_filterRange
const FilterResampleRemoveXRange m_filterRange
MassSpectrumFilterResampleRemoveMzRange(const MzRange &mz_range)
MassSpectrum & filter(MassSpectrum &spectrum) const override
Class to represent a mass spectrum.
A simple container of DataPoint instances.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::vector< DataPoint >::iterator findFirstEqualOrGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is equal or greater than the value searched important : it implies ...
std::vector< DataPoint >::iterator findFirstGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is greater than the value searched important : it implies that Trac...
std::vector< SelectionPolygonSpec > SelectionPolygonSpecVector