Loading...
Searching...
No Matches
pappso::Trace Class Reference

A simple container of DataPoint instances. More...

`#include <trace.h>`

Inheritance diagram for pappso::Trace:

## Public Member Functions

| Trace ()
| Trace (const QString &text)
| Trace (const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
| Trace (const std::vector< std::pair< pappso_double, pappso_double > > &dataPoints)
| Trace (const std::vector< DataPoint > &dataPoints)
| Trace (const std::vector< DataPoint > &&dataPoints)
| Trace (const MapTrace &map_trace)
| Trace (const Trace &other)
| Trace (const Trace &&other)
virtual | ~Trace ()
size_t | initialize (const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
size_t | initialize (const QString &x_text, const QString &y_text)
size_t | initialize (const QString &space_sep_text)
size_t | initialize (const Trace &other)
size_t | initialize (const std::map< pappso_double, pappso_double > &map)
virtual Trace & | operator= (const Trace &x)
virtual Trace & | operator= (Trace &&x)
TraceSPtr | makeTraceSPtr () const
TraceCstSPtr | makeTraceCstSPtr () const
size_t | append (const DataPoint &data_point)
| appends a datapoint and return new size
std::vector< pappso_double > | xValues () const
std::vector< pappso_double > | yValues () const
std::map< pappso_double, pappso_double > | toMap () const
DataPoint | containsX (pappso_double value, PrecisionPtr precision_p=nullptr) const
const DataPoint & | minXDataPoint () const
const DataPoint & | maxXDataPoint () const
const DataPoint & | minYDataPoint () const
const DataPoint & | maxYDataPoint () const
pappso_double | minX () const
pappso_double | maxX () const
pappso_double | minY () const
pappso_double | maxY () const
pappso_double | maxY (double mzStart, double mzEnd) const
pappso_double | sumY () const
pappso_double | sumY (double mzStart, double mzEnd) const
void | sort (Enums::SortType sort_type, Enums::SortOrder sort_order=Enums::SortOrder::ascending)
void | sortX (Enums::SortOrder sort_order=Enums::SortOrder::ascending)
void | sortY (Enums::SortOrder sort_order=Enums::SortOrder::ascending)
void | unique ()
std::size_t | removeZeroYDataPoints ()
virtual Trace & | filter (const FilterInterface &filter) final
| apply a filter on this trace
QString | toString () const
QJsonObject | toJsonObject (const QString &x_label="x", const QString &y_label="y") const
| serialize a PAPPSO trace object to JSON
QByteArray | xAsBase64Encoded () const
QByteArray | yAsBase64Encoded () const
std::vector< DataPoint >::const_iterator | dataPointCstIteratorWithX (pappso_double value) const
| find datapoint with exactly x value

## Protected Member Functions

std::size_t | dataPointIndexWithX (pappso_double value) const
| Return a reference to the DataPoint instance that has its x member equal to `value`.
std::vector< DataPoint >::iterator | dataPointIteratorWithX (pappso_double value)

## Friends

class | TraceCombiner
class | TraceMinusCombiner
class | TracePlusCombiner
class | MassSpectrumCombinerInterface

## Detailed Description

A simple container of DataPoint instances.

Definition at line 151 of file trace.h.

## Constructor & Destructor Documentation

## Trace() [1/9]

pappso::Trace::Trace | ( |  | ) |

Definition at line 455 of file trace.cpp.

{
}

Referenced by pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), pappso::MassSpectrum::MassSpectrum(), Trace(), Trace(), pappso::Xic::Xic(), initialize(), MassSpectrumCombinerInterface, operator=(), and operator=().

## Trace() [2/9]

pappso::Trace::Trace | ( | const QString & | text | ) |

Definition at line 460 of file trace.cpp.

{
initialize(text);
}
pappso::Trace::initialize
size_t initialize(const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
Definition trace.cpp:597

References initialize().

## Trace() [3/9]

pappso::Trace::Trace | ( | const std::vector< pappso_double > & | xVector,
|  | const std::vector< pappso_double > & | yVector )

Definition at line 466 of file trace.cpp.

{
initialize(xVector, yVector);
}

References initialize().

## Trace() [4/9]

pappso::Trace::Trace | ( | const std::vector< std::pair< pappso_double, pappso_double > > & | dataPoints | ) |

Definition at line 533 of file trace.cpp.

{
reserve(dataPoints.size());
for(auto &dataPoint : dataPoints)
{
push_back(DataPoint(dataPoint));
}
sortX();
// std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
// return (a.x < b.x);
//});
}
pappso::Trace::sortX
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1071

References sortX().

## Trace() [5/9]

pappso::Trace::Trace | ( | const std::vector< DataPoint > & | dataPoints | ) |

Definition at line 549 of file trace.cpp.

: std::vector<DataPoint>(dataPoints)
{
sortX();
// std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
// return (a.x < b.x);
//});
}

References sortX().

## Trace() [6/9]

pappso::Trace::Trace | ( | const std::vector< DataPoint > && | dataPoints | ) |

Definition at line 558 of file trace.cpp.

: std::vector<DataPoint>(std::move(dataPoints))
{
// This constructor used by the MassSpectrum && constructor.
sortX();
// std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
// return (a.x < b.x);
//});
}

References sortX().

## Trace() [7/9]

pappso::Trace::Trace | ( | const MapTrace & | map_trace | ) |

explicit

Definition at line 570 of file trace.cpp.

{
for(auto &&item : map_trace)
push_back(DataPoint(item.first, item.second));
// No need to sort, maps are sorted by key (that is, x).
}

## Trace() [8/9]

pappso::Trace::Trace | ( | const Trace & | other | ) |

Definition at line 578 of file trace.cpp.

: std::vector<DataPoint>(other)
{
}

References Trace().

## Trace() [9/9]

pappso::Trace::Trace | ( | const Trace && | other | ) |

Definition at line 583 of file trace.cpp.

: std::vector<DataPoint>(std::move(other))
{
// This constructor used by the MassSpectrum && constructor.
}

References Trace().

## ~Trace()

pappso::Trace::~Trace | ( |  | ) |

virtual

Definition at line 589 of file trace.cpp.

{
// Calls the destructor for each DataPoint object in the vector.
clear();
}

## Member Function Documentation

## append()

size_t pappso::Trace::append | ( | const DataPoint & | data_point | ) |

appends a datapoint and return new size

Definition at line 657 of file trace.cpp.

{
push_back(data_point);
return size();
}

Referenced by pappso::TimsFramesMsRunReader::computeTicChromatogram(), pappso::incrementByValueX(), pappso::incrementByValueY(), initialize(), initialize(), MassSpectrumCombinerInterface, and pappso::HighResPeakPicker::pick().

## containsX()

DataPoint pappso::Trace::containsX | ( | pappso_double | value,
|  | PrecisionPtr | precision_p = nullptr ) const

Definition at line 802 of file trace.cpp.

{
// std::cout << std::setprecision(10) << "getting value: " << value
//<< " and precision: " << precision_p->getNominal() << std::endl;
pappso_double delta = precision_p->delta(value);
double left_most = value - delta;
double right_most = value + delta;
// std::cout << std::setprecision(10) << "delta: " << delta
//<< " left_most: " << left_most << " right_most: " << right_most
//<< std::endl;
auto iterator = std::find_if(
begin(), end(), [value, precision_p, left_most, right_most](const DataPoint &data_point) {
if(precision_p)
{
// FIXME: unbelievable behaviour: when building in
// release mode this code, under i386 (but not x86_64),
// this code fails if the following%S statement is
// missing.
// std::cout << std::setprecision(10)
//<< "Testing data_point.x: " << data_point.x
//<< std::endl;
// For this reason I had to deactivate the related tests
// for i386 in tests/test_trace.cpp
double diff_to_left_most = data_point.x - left_most;
double diff_to_right_most = data_point.x - right_most;
// std::cout << std::setprecision(10)
//<< "diff_to_left_most: " << diff_to_left_most
//<< " diff_to_right_most: " << diff_to_right_most <<
// std::endl;
// if(diff_to_left_most > 0)
//{
// std::cout << std::setprecision(10)
//<< " point is right of left_most: " <<
// diff_to_left_most
//<< std::endl;
//}
// if(diff_to_left_most < 0)
//{
// std::cout << std::setprecision(10)
//<< "point is left of left_most: " << diff_to_left_most
//<< std::endl;
//}
// if(!diff_to_left_most)
//{
// std::cout << std::setprecision(10)
//<< "point is spot on left_most: " << diff_to_left_most
//<< std::endl;
//}
// if(diff_to_right_most > 0)
//{
// std::cout << std::setprecision(10)
//<< "point is right of right_most: " <<
// diff_to_right_most
//<< std::endl;
//}
// if(diff_to_right_most < 0)
//{
// std::cout << std::setprecision(10)
//<< "point is left or of right_most: "
//<< diff_to_right_most << std::endl;
//}
// if(!diff_to_right_most)
//{
// std::cout << std::setprecision(10)
//<< "point is spot on right_most: " <<
// diff_to_right_most
//<< std::endl;
//}
if(diff_to_left_most >= 0 && diff_to_right_most <= 0)
{
// std::cout << "The point is inside the range,
// should return true."
//<< std::endl;
return true;
}
else
{
// std::cout
//<< "The point is outside the range, should return
// false."
//<< std::endl;
return false;
}
}
else
{
return (data_point.x == value);
}
});
if(iterator != end())
{
// The returned data point is valid.
return *iterator;
}
else
{
// The returned data point is invalid because it is not initialized.
return DataPoint();
}
}
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition types.h:60

References pappso::PrecisionBase::delta(), and pappso::DataPoint::x.

Referenced by MassSpectrumCombinerInterface.

## dataPointCstIteratorWithX()

std::vector< DataPoint >::const_iterator pappso::Trace::dataPointCstIteratorWithX | ( | pappso_double | value | ) | const

find datapoint with exactly x value

Definition at line 780 of file trace.cpp.

{
auto iterator = std::find_if(
begin(), end(), [value](const DataPoint &dataPoint) { return (dataPoint.x == value); });
return iterator;
}

References pappso::DataPoint::x.

Referenced by dataPointIndexWithX(), and MassSpectrumCombinerInterface.

## dataPointIndexWithX()

std::size_t pappso::Trace::dataPointIndexWithX | ( | pappso_double | value | ) | const

protected

Return a reference to the DataPoint instance that has its x member equal to `value`.

Definition at line 790 of file trace.cpp.

{
std::vector<DataPoint>::const_iterator iterator = dataPointCstIteratorWithX(value);
if(iterator != end())
return std::distance(begin(), iterator);
return std::numeric_limits<std::size_t>::max();
}
pappso::Trace::dataPointCstIteratorWithX
std::vector< DataPoint >::const_iterator dataPointCstIteratorWithX(pappso_double value) const
find datapoint with exactly x value
Definition trace.cpp:780

References dataPointCstIteratorWithX().

Referenced by MassSpectrumCombinerInterface.

## dataPointIteratorWithX()

std::vector< DataPoint >::iterator pappso::Trace::dataPointIteratorWithX | ( | pappso_double | value | ) |

protected

Definition at line 770 of file trace.cpp.

{
auto iterator = std::find_if(
begin(), end(), [value](const DataPoint &dataPoint) { return (dataPoint.x == value); });
return iterator;
}

References pappso::DataPoint::x.

Referenced by MassSpectrumCombinerInterface.

## filter()

Trace & pappso::Trace::filter | ( | const FilterInterface & | filter | ) |

final virtual

apply a filter on this trace

Parameters

  filter | to process the signal

Returns
  reference on the modified Trace.

Definition at line 1185 of file trace.cpp.

{
return filter.filter(*this);
}
pappso::Trace::filter
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
Definition trace.cpp:1185

References filter().

Referenced by filter(), MassSpectrumCombinerInterface, and pappso::MassSpectrum::massSpectrumFilter().

## initialize() [1/5]

size_t pappso::Trace::initialize | ( | const QString & | space_sep_text | ) |

Definition at line 473 of file trace.cpp.

{
QStringList string_list = space_sep_text.split("\n", Qt::SkipEmptyParts);
// qDebug() << "Split text into" << string_list.size()
//<< "substrings:" << string_list;
for(int iter = 0; iter < string_list.size(); ++iter)
{
QString line = string_list.at(iter);
// qDebug() << "Now processing line:" << line;
// Returns a string that has whitespace removed from the start and the
// end, and that has each sequence of internal whitespace replaced with a
// single space.
line = line.simplified();
// Remove any parentheses and replace comma and semicolumn with space.
// line.remove(QChar('('));
// line.remove(QChar(')'));
// line.replace(QChar(','), QChar(' '));
// line.replace(QChar(';'), QChar(' '));
qDebug() << "Now appending DataPoint as this line:" << line;
append(DataPoint(line));
}
return size();
}
CardanoResultCase::line
@ line
Definition cardano.h:42
pappso::Trace::append
size_t append(const DataPoint &data_point)
appends a datapoint and return new size
Definition trace.cpp:657

References append(), and line.

## initialize() [2/5]

size_t pappso::Trace::initialize | ( | const QString & | x_text,
|  | const QString & | y_text )

Definition at line 506 of file trace.cpp.

{
QStringList x_string_list = x_text.split("\n", Qt::SkipEmptyParts);
QStringList y_string_list = y_text.split("\n", Qt::SkipEmptyParts);
if(x_string_list.size() != y_string_list.size())
throw ExceptionNotPossible(
"trace.cpp -- ERROR x_text and y_text must have the same number of "
"lines.");
for(int iter = 0; iter < x_string_list.size(); ++iter)
{
QString x_line = x_string_list.at(iter);
QString y_line = y_string_list.at(iter);
// Returns a string that has whitespace removed from the start and the
// end, and that has each sequence of internal whitespace replaced with a
// single space.
x_line = x_line.simplified();
y_line = y_line.simplified();
append(DataPoint(x_line + " " + y_line));
}
return size();
}

References append().

## initialize() [3/5]

size_t pappso::Trace::initialize | ( | const std::map< pappso_double, pappso_double > & | map | ) |

Definition at line 629 of file trace.cpp.

{
// We are initializing, not appending.
erase(begin(), end());
for(auto &&item : map)
{
push_back(DataPoint(item.first, item.second));
}
// No need to sort, maps are sorted by key (that is, x).
return size();
}

## initialize() [4/5]

size_t pappso::Trace::initialize | ( | const std::vector< pappso_double > & | xVector,
|  | const std::vector< pappso_double > & | yVector )

Definition at line 597 of file trace.cpp.

{
// Sanity check
if(xVector.size() != yVector.size())
throw ExceptionNotPossible("trace.cpp -- ERROR xVector and yVector must have the same size.");
// We are initializing, not appending.
erase(begin(), end());
for(std::size_t iter = 0; iter < xVector.size(); ++iter)
{
push_back(DataPoint(xVector.at(iter), yVector.at(iter)));
}
sortX();
// std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
// return (a.x < b.x);
//});
#if 0
for(auto &item : *this)
{
std::cout << item.x << "-" << item.y;
}
#endif
return size();
}

References sortX().

Referenced by Trace(), Trace(), pappso::cbor::mzcbor::Spectrum::decodeTrace(), and MassSpectrumCombinerInterface.

## initialize() [5/5]

size_t pappso::Trace::initialize | ( | const Trace & | other | ) |

Definition at line 647 of file trace.cpp.

{
clear();
*this = other;
return size();
}

References Trace().

## makeTraceCstSPtr()

TraceCstSPtr pappso::Trace::makeTraceCstSPtr | ( |  | ) | const

Definition at line 690 of file trace.cpp.

{
return std::make_shared<const Trace>(*this);
}

Referenced by MassSpectrumCombinerInterface.

## makeTraceSPtr()

TraceSPtr pappso::Trace::makeTraceSPtr | ( |  | ) | const

Definition at line 683 of file trace.cpp.

{
return std::make_shared<Trace>(*this);
}

Referenced by pappso::TimsFrameMobilityTraces::extractMobilityTraces(), and MassSpectrumCombinerInterface.

## maxX()

pappso_double pappso::Trace::maxX | ( |  | ) | const

Definition at line 989 of file trace.cpp.

{
return maxXDataPoint().x;
}
pappso::Trace::maxXDataPoint
const DataPoint & maxXDataPoint() const
Definition trace.cpp:934
pappso::DataPoint::x
pappso_double x
Definition datapoint.h:24

References maxXDataPoint(), and pappso::DataPoint::x.

Referenced by MassSpectrumCombinerInterface.

## maxXDataPoint()

const DataPoint & pappso::Trace::maxXDataPoint | ( |  | ) | const

Definition at line 934 of file trace.cpp.

{
auto dataPoint = std::max_element(
begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.x < b.x); });
if(dataPoint == end())
{
throw ExceptionOutOfRange(
QObject::tr("unable to get max peak x on spectrum size %1").arg(size()));
}
return (*dataPoint);
}
pappso::PeptideIonNter::a
@ a
Definition peptide.h:77
pappso::PeptideIonNter::b
@ b
Definition peptide.h:74

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

Referenced by MassSpectrumCombinerInterface, and maxX().

## maxY() [1/2]

pappso_double pappso::Trace::maxY | ( |  | ) | const

Definition at line 1003 of file trace.cpp.

{
return maxYDataPoint().y;
}
pappso::Trace::maxYDataPoint
const DataPoint & maxYDataPoint() const
Definition trace.cpp:966
pappso::DataPoint::y
pappso_double y
Definition datapoint.h:25

References maxYDataPoint(), and pappso::DataPoint::y.

Referenced by MassSpectrumCombinerInterface.

## maxY() [2/2]

pappso_double pappso::Trace::maxY | ( | double | mzStart,
|  | double | mzEnd ) const

Definition at line 1040 of file trace.cpp.

{
std::vector<DataPoint>::const_iterator begin_it =
findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
double max_y = 0;
while(begin_it != findFirstGreaterX(begin_it, this->end(), mzEnd))
{
if(begin_it->y > max_y)
max_y = begin_it->y;
begin_it++;
}
return max_y;
}
pappso::findFirstEqualOrGreaterX
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 ...
Definition trace.cpp:65
pappso::findFirstGreaterX
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...
Definition trace.cpp:93

References pappso::findFirstEqualOrGreaterX(), and pappso::findFirstGreaterX().

## maxYDataPoint()

const DataPoint & pappso::Trace::maxYDataPoint | ( |  | ) | const

Definition at line 966 of file trace.cpp.

{
auto dataPoint = std::max_element(
begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.y < b.y); });
if(dataPoint == end())
{
throw ExceptionOutOfRange(
QObject::tr("unable to get max peak intensity on spectrum size %1").arg(size()));
}
return (*dataPoint);
}

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

Referenced by pappso::flooredLocalMaxima(), MassSpectrumCombinerInterface, pappso::MassSpectrum::maxIntensityDataPoint(), and maxY().

## minX()

pappso_double pappso::Trace::minX | ( |  | ) | const

Definition at line 982 of file trace.cpp.

{
return minXDataPoint().x;
}
pappso::Trace::minXDataPoint
const DataPoint & minXDataPoint() const
Definition trace.cpp:918

References minXDataPoint(), and pappso::DataPoint::x.

Referenced by MassSpectrumCombinerInterface.

## minXDataPoint()

const DataPoint & pappso::Trace::minXDataPoint | ( |  | ) | const

Definition at line 918 of file trace.cpp.

{
auto dataPoint = std::min_element(
begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.x < b.x); });
if(dataPoint == end())
{
throw ExceptionOutOfRange(
QObject::tr("unable to get min peak x on spectrum size %1").arg(size()));
}
return (*dataPoint);
}

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

Referenced by MassSpectrumCombinerInterface, and minX().

## minY()

pappso_double pappso::Trace::minY | ( |  | ) | const

Definition at line 996 of file trace.cpp.

{
return minYDataPoint().y;
}
pappso::Trace::minYDataPoint
const DataPoint & minYDataPoint() const
Definition trace.cpp:950

References minYDataPoint(), and pappso::DataPoint::y.

Referenced by MassSpectrumCombinerInterface.

## minYDataPoint()

const DataPoint & pappso::Trace::minYDataPoint | ( |  | ) | const

Definition at line 950 of file trace.cpp.

{
auto dataPoint = std::min_element(
begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.y < b.y); });
if(dataPoint == end())
{
throw ExceptionOutOfRange(
QObject::tr("unable to get min peak intensity on spectrum size %1").arg(size()));
}
return (*dataPoint);
}

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

Referenced by MassSpectrumCombinerInterface, pappso::MassSpectrum::minIntensityDataPoint(), and minY().

## operator=() [1/2]

Trace & pappso::Trace::operator= | ( | const Trace & | x | ) |

virtual

Reimplemented in pappso::MassSpectrum, and pappso::Xic.

Definition at line 666 of file trace.cpp.

{
assign(other.begin(), other.end());
return *this;
}

References Trace().

Referenced by MassSpectrumCombinerInterface.

## operator=() [2/2]

Trace & pappso::Trace::operator= | ( | Trace && | x | ) |

virtual

Reimplemented in pappso::MassSpectrum, and pappso::Xic.

Definition at line 675 of file trace.cpp.

{
vector<DataPoint>::operator=(std::move(other));
return *this;
}

References Trace().

## removeZeroYDataPoints()

std::size_t pappso::Trace::removeZeroYDataPoints | ( |  | ) |

Definition at line 1101 of file trace.cpp.

{
qDebug();
auto it = begin();
auto end_it = end();
std::size_t count = 0;
while(it != end_it)
{
if(Utils::almostEqual(it->y, 0))
{
// erase returns an iterator to the next item in the vector.
it = erase(it);
++count;
}
else
// We need to increment (no call to erase here).
++it;
}
return count;
}
pappso::Utils::almostEqual
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
Tell if both double values, are equal within the double representation capabilities of the platform.
Definition utils.cpp:326

References pappso::Utils::almostEqual().

Referenced by MassSpectrumCombinerInterface.

## sort()

void pappso::Trace::sort | ( | Enums::SortType | sort_type,
|  | Enums::SortOrder | sort_order = Enums::SortOrder::ascending )

Definition at line 1058 of file trace.cpp.

{
if(sort_type == Enums::SortType::none)
return;
if(sort_type == Enums::SortType::x)
return sortX(sort_order);
else
return sortY(sort_order);
}
pappso::Trace::sortY
void sortY(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1081
pappso::Enums::SortType::none
@ none
Definition types.h:224
pappso::Enums::SortType::x
@ x
Definition types.h:225

References pappso::Enums::none, sortX(), sortY(), and pappso::Enums::x.

Referenced by MassSpectrumCombinerInterface.

## sortX()

void pappso::Trace::sortX | ( | Enums::SortOrder | sort_order = Enums::SortOrder::ascending | ) |

Definition at line 1071 of file trace.cpp.

{
if(sort_order == Enums::SortOrder::ascending)
std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.x < b.x); });
else
std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.x > b.x); });
}
pappso::Enums::SortOrder::ascending
@ ascending
Definition types.h:232

References pappso::a, pappso::Enums::ascending, and pappso::b.

Referenced by pappso::IonIsotopeRatioScore::IonIsotopeRatioScore(), Trace(), Trace(), Trace(), pappso::MsRunRetentionTime< T >::align(), pappso::TimsFrame::cumulateScansToTrace(), pappso::FilterChargeDeconvolution::filter(), pappso::FilterComplementIonEnhancer::filter(), pappso::FilterGreatestYperWindow::filter(), pappso::FilterMzExclusion::filter(), pappso::FilterPeakDelta::filter(), pappso::FilterRemoveC13::filter(), pappso::FilterTriangle::filter(), pappso::MsRunRetentionTime< T >::getCommonDeltaRt(), pappso::PsmFeatures::getIonIsotopeLinearRegression(), pappso::TimsFrameBase::getTraceFromTofIndexIntensityMap(), initialize(), MassSpectrumCombinerInterface, sort(), pappso::Xic::sortByRetentionTime(), and pappso::MassSpectrum::sortMz().

## sortY()

void pappso::Trace::sortY | ( | Enums::SortOrder | sort_order = Enums::SortOrder::ascending | ) |

Definition at line 1081 of file trace.cpp.

{
if(sort_order == Enums::SortOrder::ascending)
std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.y < b.y); });
else
std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.y > b.y); });
}

References pappso::a, pappso::Enums::ascending, and pappso::b.

Referenced by pappso::TimsFrameMobilityTraces::extractMobilityTraces(), pappso::FilterChargeDeconvolution::filter(), pappso::FilterMzExclusion::filter(), MassSpectrumCombinerInterface, and sort().

## sumY() [1/2]

pappso_double pappso::Trace::sumY | ( |  | ) | const

Definition at line 1010 of file trace.cpp.

{
// double sum = 0;
// for(auto &&dp : m_dataPoints)
// sum += dp.y;
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
//<< "Returning sum/tic:" << sum;
// return sum;
return std::accumulate(
begin(), end(), (double)0, [](pappso_double sum, const DataPoint &dataPoint) {
return (sum + dataPoint.y);
});
}

References pappso::DataPoint::y.

Referenced by MassSpectrumCombinerInterface, pappso::PsmFeatures::setPeptideSpectrumCharge(), pappso::MassSpectrum::tic(), and pappso::MassSpectrum::totalIonCurrent().

## sumY() [2/2]

pappso_double pappso::Trace::sumY | ( | double | mzStart,
|  | double | mzEnd ) const

Definition at line 1030 of file trace.cpp.

{
auto begin_it = findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
auto end_it = findFirstGreaterX(begin_it, this->end(), mzEnd);
return sumYTrace(begin_it, end_it, 0);
}
pappso::sumYTrace
double sumYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double init)
calculate the sum of y value of a trace
Definition trace.cpp:226

References pappso::findFirstEqualOrGreaterX(), pappso::findFirstGreaterX(), and pappso::sumYTrace().

## toJsonObject()

QJsonObject pappso::Trace::toJsonObject | ( | const QString & | x_label = "x",
|  | const QString & | y_label = "y" ) const

serialize a PAPPSO trace object to JSON

Parameters

  x_label | label for first dimension (x by default)
  y_label | label for second dimension (y by default)

Returns
  a JSON object

Definition at line 1191 of file trace.cpp.

{
QJsonObject json_trace;
QJsonArray x_arr;
QJsonArray y_arr;
for(auto &&data_point : *this)
{
x_arr.push_back(data_point.x);
y_arr.push_back(data_point.y);
}
json_trace.insert(x_label, x_arr);
json_trace.insert(y_label, y_arr);
return json_trace;
}

Referenced by MassSpectrumCombinerInterface, and pappso::cbor::mzcbor::Spectrum::toJsonObject().

## toMap()

std::map< pappso_double, pappso_double > pappso::Trace::toMap | ( |  | ) | const

Definition at line 725 of file trace.cpp.

{
std::map<pappso_double, pappso_double> map;
std::pair<std::map<pappso_double, pappso_double>::iterator, bool> ret;
for(auto &&dataPoint : *this)
{
ret = map.insert(std::pair<pappso_double, pappso_double>(dataPoint.x, dataPoint.y));
if(ret.second == false)
{
qDebug() << "It is odd that the Trace contains multiple same keys.";
// No insertion, then increment the y value.
ret.first->second += dataPoint.y;
}
}
return map;
}

Referenced by MassSpectrumCombinerInterface.

## toString()

QString pappso::Trace::toString | ( |  | ) | const

Definition at line 1128 of file trace.cpp.

{
// Even if the spectrum is empty, we should return an empty string.
QString text;
for(auto &&dataPoint : *this)
{
text.append(QString("%1\n").arg(dataPoint.toString()));
}
return text;
}

Referenced by MassSpectrumCombinerInterface.

## unique()

void pappso::Trace::unique | ( |  | ) |

Definition at line 1091 of file trace.cpp.

{
auto last = std::unique(
begin(), end(), [](const DataPoint &a, const DataPoint &b) { return (a.x == b.x); });
erase(last, end());
}
pappso::QualifiedMassSpectrumParameter::last
@ last
Definition qualifiedmassspectrum.h:71

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

Referenced by pappso::MsRunRetentionTime< T >::getCommonDeltaRt(), and MassSpectrumCombinerInterface.

## xAsBase64Encoded()

QByteArray pappso::Trace::xAsBase64Encoded | ( |  | ) | const

Definition at line 1143 of file trace.cpp.

{
QByteArray unencoded_array;
for(auto &&data_point : *this)
{
QByteArray local_array;
local_array.setNum(data_point.x, 'f', 12);
local_array.append("\n");
unencoded_array.append(local_array);
}
QByteArray base64_encoded_array =
unencoded_array.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);
return base64_encoded_array;
}

Referenced by MassSpectrumCombinerInterface.

## xValues()

std::vector< pappso_double > pappso::Trace::xValues | ( |  | ) | const

Definition at line 697 of file trace.cpp.

{
std::vector<pappso_double> values;
for(auto &&dataPoint : *this)
{
values.push_back(dataPoint.x);
}
return values;
}

Referenced by pappso::BaseTracePlotWidget::addBars(), pappso::BaseTracePlotWidget::addTrace(), MassSpectrumCombinerInterface, pappso::cbor::CborStreamWriter::writeTrace(), and pappso::masschroq::CborOutputStream::writeTrace().

## yAsBase64Encoded()

QByteArray pappso::Trace::yAsBase64Encoded | ( |  | ) | const

Definition at line 1164 of file trace.cpp.

{
QByteArray unencoded_array;
for(auto &&data_point : *this)
{
QByteArray local_array;
local_array.setNum(data_point.y, 'f', 12);
local_array.append("\n");
unencoded_array.append(local_array);
}
QByteArray base64_encoded_array =
unencoded_array.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);
return base64_encoded_array;
}

Referenced by MassSpectrumCombinerInterface.

## yValues()

std::vector< pappso_double > pappso::Trace::yValues | ( |  | ) | const

Definition at line 711 of file trace.cpp.

{
std::vector<pappso_double> values;
for(auto &&dataPoint : *this)
{
values.push_back(dataPoint.y);
}
return values;
}

Referenced by pappso::BaseTracePlotWidget::addBars(), pappso::BaseTracePlotWidget::addTrace(), pappso::MsRunRetentionTime< T >::align(), MassSpectrumCombinerInterface, pappso::masschroq::CborOutputStream::writeMsRunRetentionTime(), pappso::cbor::CborStreamWriter::writeTrace(), and pappso::masschroq::CborOutputStream::writeTrace().

## Friends And Related Symbol Documentation

## MassSpectrumCombinerInterface

friend class MassSpectrumCombinerInterface

friend

Definition at line 158 of file trace.h.

References Trace(), append(), pappso::Enums::ascending, containsX(), dataPointCstIteratorWithX(), dataPointIndexWithX(), dataPointIteratorWithX(), filter(), initialize(), makeTraceCstSPtr(), makeTraceSPtr(), MassSpectrumCombinerInterface, maxX(), maxXDataPoint(), maxY(), maxYDataPoint(), minX(), minXDataPoint(), minY(), minYDataPoint(), operator=(), removeZeroYDataPoints(), sort(), sortX(), sortY(), sumY(), toJsonObject(), toMap(), toString(), unique(), xAsBase64Encoded(), xValues(), yAsBase64Encoded(), and yValues().

Referenced by MassSpectrumCombinerInterface.

## TraceCombiner

friend class TraceCombiner

friend

Definition at line 154 of file trace.h.

References TraceCombiner.

Referenced by TraceCombiner.

## TraceMinusCombiner

friend class TraceMinusCombiner

friend

Definition at line 155 of file trace.h.

References TraceMinusCombiner.

Referenced by TraceMinusCombiner.

## TracePlusCombiner

friend class TracePlusCombiner

friend

Definition at line 156 of file trace.h.

References TracePlusCombiner.

Referenced by TracePlusCombiner.

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

- pappsomspp/core/trace/trace.h
- pappsomspp/core/trace/trace.cpp