libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::Trace Class Reference

A simple container of DataPoint instances. More...

#include <trace.h>

Inheritance diagram for pappso::Trace:
pappso::MassSpectrum pappso::Xic

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 Traceoperator= (const Trace &x)
 
virtual Traceoperator= (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_doublexValues () const
 
std::vector< pappso_doubleyValues () const
 
std::map< pappso_double, pappso_doubletoMap () const
 
DataPoint containsX (pappso_double value, PrecisionPtr precision_p=nullptr) const
 
const DataPointminXDataPoint () const
 
const DataPointmaxXDataPoint () const
 
const DataPointminYDataPoint () const
 
const DataPointmaxYDataPoint () 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 (SortType sort_type, SortOrder sort_order=SortOrder::ascending)
 
void sortX (SortOrder sort_order=SortOrder::ascending)
 
void sortY (SortOrder sort_order=SortOrder::ascending)
 
void unique ()
 
std::size_t removeZeroYDataPoints ()
 
virtual Tracefilter (const FilterInterface &filter) final
 apply a filter on this trace
 
QString toString () const
 
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
 
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 147 of file trace.h.

Constructor & Destructor Documentation

◆ Trace() [1/9]

pappso::Trace::Trace ( )

Definition at line 444 of file trace.cpp.

445{
446}

◆ Trace() [2/9]

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

Definition at line 449 of file trace.cpp.

450{
451 initialize(text);
452}
size_t initialize(const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
Definition trace.cpp:588

References initialize().

◆ Trace() [3/9]

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

Definition at line 455 of file trace.cpp.

457{
458 initialize(xVector, yVector);
459}

References initialize().

◆ Trace() [4/9]

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

Definition at line 522 of file trace.cpp.

524{
525 reserve(dataPoints.size());
526
527 for(auto &dataPoint : dataPoints)
528 {
529 push_back(DataPoint(dataPoint));
530 }
531
532 sortX();
533 // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
534 // return (a.x < b.x);
535 //});
536}
void sortX(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1086

References sortX().

◆ Trace() [5/9]

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

Definition at line 539 of file trace.cpp.

540 : std::vector<DataPoint>(dataPoints)
541{
542 sortX();
543 // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
544 // return (a.x < b.x);
545 //});
546}

References sortX().

◆ Trace() [6/9]

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

Definition at line 549 of file trace.cpp.

550 : std::vector<DataPoint>(std::move(dataPoints))
551{
552 // This constructor used by the MassSpectrum && constructor.
553
554 sortX();
555 // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
556 // return (a.x < b.x);
557 //});
558}

References sortX().

◆ Trace() [7/9]

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

Definition at line 561 of file trace.cpp.

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

◆ Trace() [8/9]

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

Definition at line 569 of file trace.cpp.

569 : std::vector<DataPoint>(other)
570{
571}

◆ Trace() [9/9]

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

Definition at line 574 of file trace.cpp.

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

◆ ~Trace()

pappso::Trace::~Trace ( )
virtual

Definition at line 580 of file trace.cpp.

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

Member Function Documentation

◆ append()

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

appends a datapoint and return new size

Definition at line 648 of file trace.cpp.

649{
650 push_back(data_point);
651
652 return size();
653}

Referenced by pappso::TimsFramesMsRunReader::computeTicChromatogram(), initialize(), and initialize().

◆ containsX()

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

Definition at line 800 of file trace.cpp.

801{
802 // std::cout << std::setprecision(10) << "getting value: " << value
803 //<< " and precision: " << precision_p->getNominal() << std::endl;
804
805 pappso_double delta = precision_p->delta(value);
806
807 double left_most = value - delta;
808 double right_most = value + delta;
809
810 // std::cout << std::setprecision(10) << "delta: " << delta
811 //<< " left_most: " << left_most << " right_most: " << right_most
812 //<< std::endl;
813
814 auto iterator =
815 std::find_if(begin(),
816 end(),
817 [value, precision_p, delta, left_most, right_most](
818 const DataPoint &data_point) {
819 if(precision_p)
820 {
821
822 // FIXME: unbelievable behaviour: when building in
823 // release mode this code, under i386 (but not x86_64),
824 // this code fails if the following%S statement is
825 // missing.
826
827 // std::cout << std::setprecision(10)
828 //<< "Testing data_point.x: " << data_point.x
829 //<< std::endl;
830
831 // For this reason I had to deactivate the related tests
832 // for i386 in tests/test_trace.cpp
833
834 double diff_to_left_most = data_point.x - left_most;
835 double diff_to_right_most = data_point.x - right_most;
836
837 // std::cout << std::setprecision(10)
838 //<< "diff_to_left_most: " << diff_to_left_most
839 //<< " diff_to_right_most: " << diff_to_right_most <<
840 // std::endl;
841
842 // if(diff_to_left_most > 0)
843 //{
844 // std::cout << std::setprecision(10)
845 //<< " point is right of left_most: " <<
846 // diff_to_left_most
847 //<< std::endl;
848 //}
849 // if(diff_to_left_most < 0)
850 //{
851 // std::cout << std::setprecision(10)
852 //<< "point is left of left_most: " << diff_to_left_most
853 //<< std::endl;
854 //}
855 // if(!diff_to_left_most)
856 //{
857 // std::cout << std::setprecision(10)
858 //<< "point is spot on left_most: " << diff_to_left_most
859 //<< std::endl;
860 //}
861
862 // if(diff_to_right_most > 0)
863 //{
864 // std::cout << std::setprecision(10)
865 //<< "point is right of right_most: " <<
866 // diff_to_right_most
867 //<< std::endl;
868 //}
869 // if(diff_to_right_most < 0)
870 //{
871 // std::cout << std::setprecision(10)
872 //<< "point is left or of right_most: "
873 //<< diff_to_right_most << std::endl;
874 //}
875 // if(!diff_to_right_most)
876 //{
877 // std::cout << std::setprecision(10)
878 //<< "point is spot on right_most: " <<
879 // diff_to_right_most
880 //<< std::endl;
881 //}
882
883 if(diff_to_left_most >= 0 && diff_to_right_most <= 0)
884 {
885 // std::cout << "The point is inside the range,
886 // should return true."
887 //<< std::endl;
888 return true;
889 }
890 else
891 {
892 // std::cout
893 //<< "The point is outside the range, should return
894 // false."
895 //<< std::endl;
896 return false;
897 }
898 }
899 else
900 {
901 return (data_point.x == value);
902 }
903 });
904
905 if(iterator != end())
906 {
907 // The returned data point is valid.
908 return *iterator;
909 }
910 else
911 {
912 // The returned data point is invalid because it is not initialized.
913 return DataPoint();
914 }
915}
double pappso_double
A type definition for doubles.
Definition types.h:50

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

◆ dataPointCstIteratorWithX()

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

find datapoint with exactly x value

Definition at line 775 of file trace.cpp.

776{
777 auto iterator =
778 std::find_if(begin(), end(), [value](const DataPoint &dataPoint) {
779 return (dataPoint.x == value);
780 });
781
782 return iterator;
783}

References pappso::DataPoint::x.

Referenced by dataPointIndexWithX().

◆ dataPointIndexWithX()

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

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

Definition at line 787 of file trace.cpp.

788{
789 std::vector<DataPoint>::const_iterator iterator =
791
792 if(iterator != end())
793 return std::distance(begin(), iterator);
794
795 return std::numeric_limits<std::size_t>::max();
796}
std::vector< DataPoint >::const_iterator dataPointCstIteratorWithX(pappso_double value) const
find datapoint with exactly x value
Definition trace.cpp:775

References dataPointCstIteratorWithX().

◆ dataPointIteratorWithX()

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

Definition at line 763 of file trace.cpp.

764{
765 auto iterator =
766 std::find_if(begin(), end(), [value](const DataPoint &dataPoint) {
767 return (dataPoint.x == value);
768 });
769
770 return iterator;
771}

References pappso::DataPoint::x.

◆ filter()

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

apply a filter on this trace

Parameters
filterto process the signal
Returns
reference on the modified Trace

Definition at line 1210 of file trace.cpp.

1211{
1212 return filter.filter(*this);
1213}
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
Definition trace.cpp:1210

References filter().

Referenced by pappso::MsRunRetentionTime< T >::align(), pappso::FilterSuite::filter(), pappso::FilterSuiteString::filter(), filter(), pappso::MassSpectrum::massSpectrumFilter(), and pappso::CosineSimilarity::similarity().

◆ initialize() [1/5]

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

Definition at line 463 of file trace.cpp.

464{
465 QStringList string_list = space_sep_text.split("\n", Qt::SkipEmptyParts);
466
467 // qDebug() << "Split text into" << string_list.size()
468 //<< "substrings:" << string_list;
469
470 for(int iter = 0; iter < string_list.size(); ++iter)
471 {
472 QString line = string_list.at(iter);
473 // qDebug() << "Now processing line:" << line;
474
475 // Returns a string that has whitespace removed from the start and the
476 // end, and that has each sequence of internal whitespace replaced with a
477 // single space.
478 line = line.simplified();
479
480 // Remove any parentheses and replace comma and semicolumn with space.
481 // line.remove(QChar('('));
482 // line.remove(QChar(')'));
483
484 // line.replace(QChar(','), QChar(' '));
485 // line.replace(QChar(';'), QChar(' '));
486
487 append(DataPoint(line));
488 }
489
490 return size();
491}
size_t append(const DataPoint &data_point)
appends a datapoint and return new size
Definition trace.cpp:648

References append(), and line.

◆ initialize() [2/5]

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

Definition at line 495 of file trace.cpp.

496{
497 QStringList x_string_list = x_text.split("\n", Qt::SkipEmptyParts);
498 QStringList y_string_list = y_text.split("\n", Qt::SkipEmptyParts);
499
500 if(x_string_list.size() != y_string_list.size())
501 throw ExceptionNotPossible(
502 "trace.cpp -- ERROR x_text and y_text must have the same number of "
503 "lines.");
504
505 for(int iter = 0; iter < x_string_list.size(); ++iter)
506 {
507 QString x_line = x_string_list.at(iter);
508 QString y_line = y_string_list.at(iter);
509
510 // Returns a string that has whitespace removed from the start and the
511 // end, and that has each sequence of internal whitespace replaced with a
512 // single space.
513 x_line = x_line.simplified();
514 y_line = y_line.simplified();
515
516 append(DataPoint(x_line + " " + y_line));
517 }
518 return size();
519}

References append().

◆ initialize() [3/5]

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

Definition at line 621 of file trace.cpp.

622{
623
624 // We are initializing, not appending.
625 erase(begin(), end());
626
627 for(auto &&item : map)
628 {
629 push_back(DataPoint(item.first, item.second));
630 }
631
632 // No need to sort, maps are sorted by key (that is, x).
633
634 return size();
635}

◆ initialize() [4/5]

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

Definition at line 588 of file trace.cpp.

590{
591 // Sanity check
592 if(xVector.size() != yVector.size())
593 throw ExceptionNotPossible(
594 "trace.cpp -- ERROR xVector and yVector must have the same size.");
595
596 // We are initializing, not appending.
597 erase(begin(), end());
598
599 for(std::size_t iter = 0; iter < xVector.size(); ++iter)
600 {
601 push_back(DataPoint(xVector.at(iter), yVector.at(iter)));
602 }
603
604 sortX();
605 // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
606 // return (a.x < b.x);
607 //});
608
609#if 0
610 for(auto &item : *this)
611 {
612 std::cout << item.x << "-" << item.y;
613 }
614#endif
615
616 return size();
617}

References sortX().

Referenced by Trace(), and Trace().

◆ initialize() [5/5]

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

Definition at line 639 of file trace.cpp.

640{
641 *this = other;
642
643 return size();
644}

◆ makeTraceCstSPtr()

TraceCstSPtr pappso::Trace::makeTraceCstSPtr ( ) const

Definition at line 681 of file trace.cpp.

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

◆ makeTraceSPtr()

TraceSPtr pappso::Trace::makeTraceSPtr ( ) const

Definition at line 674 of file trace.cpp.

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

Referenced by pappso::TimsFrameMobilityTraces::extractMobilityTraces().

◆ maxX()

pappso_double pappso::Trace::maxX ( ) const

Definition at line 1002 of file trace.cpp.

1003{
1004 return maxXDataPoint().x;
1005}
const DataPoint & maxXDataPoint() const
Definition trace.cpp:938
pappso_double x
Definition datapoint.h:23

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

◆ maxXDataPoint()

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

Definition at line 938 of file trace.cpp.

939{
940 auto dataPoint = std::max_element(
941 begin(), end(), [](const DataPoint &a, const DataPoint &b) {
942 return (a.x < b.x);
943 });
944
945 if(dataPoint == end())
946 {
947 throw ExceptionOutOfRange(
948 QObject::tr("unable to get max peak x on spectrum size %1")
949 .arg(size()));
950 }
951
952 return (*dataPoint);
953}

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

Referenced by maxX().

◆ maxY() [1/2]

pappso_double pappso::Trace::maxY ( ) const

Definition at line 1016 of file trace.cpp.

1017{
1018 return maxYDataPoint().y;
1019}
const DataPoint & maxYDataPoint() const
Definition trace.cpp:976
pappso_double y
Definition datapoint.h:24

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

◆ maxY() [2/2]

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

Definition at line 1055 of file trace.cpp.

1056{
1057 std::vector<DataPoint>::const_iterator begin_it =
1058 findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
1059
1060 double max_y = 0;
1061
1062 while(begin_it != findFirstGreaterX(begin_it, this->end(), mzEnd))
1063 {
1064 if(begin_it->y > max_y)
1065 max_y = begin_it->y;
1066 begin_it++;
1067 }
1068 return max_y;
1069}
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:71
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:99

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

◆ maxYDataPoint()

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

Definition at line 976 of file trace.cpp.

977{
978 auto dataPoint = std::max_element(
979 begin(), end(), [](const DataPoint &a, const DataPoint &b) {
980 return (a.y < b.y);
981 });
982
983 if(dataPoint == end())
984 {
985 throw ExceptionOutOfRange(
986 QObject::tr("unable to get max peak intensity on spectrum size %1")
987 .arg(size()));
988 }
989
990 return (*dataPoint);
991}

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

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

◆ minX()

pappso_double pappso::Trace::minX ( ) const

Definition at line 995 of file trace.cpp.

996{
997 return minXDataPoint().x;
998}
const DataPoint & minXDataPoint() const
Definition trace.cpp:919

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

◆ minXDataPoint()

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

Definition at line 919 of file trace.cpp.

920{
921 auto dataPoint = std::min_element(
922 begin(), end(), [](const DataPoint &a, const DataPoint &b) {
923 return (a.x < b.x);
924 });
925
926 if(dataPoint == end())
927 {
928 throw ExceptionOutOfRange(
929 QObject::tr("unable to get min peak x on spectrum size %1")
930 .arg(size()));
931 }
932
933 return (*dataPoint);
934}

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

Referenced by minX().

◆ minY()

pappso_double pappso::Trace::minY ( ) const

Definition at line 1009 of file trace.cpp.

1010{
1011 return minYDataPoint().y;
1012}
const DataPoint & minYDataPoint() const
Definition trace.cpp:957

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

◆ minYDataPoint()

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

Definition at line 957 of file trace.cpp.

958{
959 auto dataPoint = std::min_element(
960 begin(), end(), [](const DataPoint &a, const DataPoint &b) {
961 return (a.y < b.y);
962 });
963
964 if(dataPoint == end())
965 {
966 throw ExceptionOutOfRange(
967 QObject::tr("unable to get min peak intensity on spectrum size %1")
968 .arg(size()));
969 }
970
971 return (*dataPoint);
972}

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

Referenced by 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 657 of file trace.cpp.

658{
659 assign(other.begin(), other.end());
660
661 return *this;
662}

◆ operator=() [2/2]

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

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

Definition at line 666 of file trace.cpp.

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

◆ removeZeroYDataPoints()

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

Definition at line 1126 of file trace.cpp.

1127{
1128 qDebug();
1129
1130 auto it = begin();
1131 auto end_it = end();
1132
1133 std::size_t count = 0;
1134
1135 while(it != end_it)
1136 {
1137 if(Utils::almostEqual(it->y, 0))
1138 {
1139 // erase returns an iterator to the next item in the vector.
1140 it = erase(it);
1141 ++count;
1142 }
1143 else
1144 // We need to increment (no call to erase here).
1145 ++it;
1146 }
1147
1148 return count;
1149}
static bool almostEqual(double value1, double value2, int decimalPlaces=10)
Definition utils.cpp:305

References pappso::Utils::almostEqual().

◆ sort()

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

Definition at line 1073 of file trace.cpp.

1074{
1075 if(sort_type == SortType::no_sort)
1076 return;
1077
1078 if(sort_type == SortType::x)
1079 return sortX(sort_order);
1080 else
1081 return sortY(sort_order);
1082}
void sortY(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1100

References pappso::no_sort, sortX(), sortY(), and pappso::x.

◆ sortX()

◆ sortY()

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

Definition at line 1100 of file trace.cpp.

1101{
1102 if(sort_order == SortOrder::ascending)
1103 std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
1104 return (a.y < b.y);
1105 });
1106 else
1107 std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
1108 return (a.y > b.y);
1109 });
1110}

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

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

◆ sumY() [1/2]

pappso_double pappso::Trace::sumY ( ) const

Definition at line 1023 of file trace.cpp.

1024{
1025 // double sum = 0;
1026
1027 // for(auto &&dp : m_dataPoints)
1028 // sum += dp.y;
1029
1030 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
1031 //<< "Returning sum/tic:" << sum;
1032
1033 // return sum;
1034
1035 return std::accumulate(begin(),
1036 end(),
1037 (double)0,
1038 [](pappso_double sum, const DataPoint &dataPoint) {
1039 return (sum + dataPoint.y);
1040 });
1041}
@ sum
sum of intensities

References pappso::sum, and pappso::DataPoint::y.

Referenced by 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 1045 of file trace.cpp.

1046{
1047 auto begin_it = findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
1048 auto end_it = findFirstGreaterX(begin_it, this->end(), mzEnd);
1049
1050 return sumYTrace(begin_it, end_it, 0);
1051}
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:244

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

◆ toMap()

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

Definition at line 716 of file trace.cpp.

717{
718 std::map<pappso_double, pappso_double> map;
719
720 std::pair<std::map<pappso_double, pappso_double>::iterator, bool> ret;
721
722 for(auto &&dataPoint : *this)
723 {
724 ret = map.insert(
725 std::pair<pappso_double, pappso_double>(dataPoint.x, dataPoint.y));
726
727 if(ret.second == false)
728 {
729 qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
730 << "It is odd that the Trace contains multiple same keys.";
731
732 // No insertion, then increment the y value.
733 ret.first->second += dataPoint.y;
734 }
735 }
736
737 return map;
738}

◆ toString()

QString pappso::Trace::toString ( ) const

Definition at line 1153 of file trace.cpp.

1154{
1155 // Even if the spectrum is empty, we should return an empty string.
1156 QString text;
1157
1158 for(auto &&dataPoint : *this)
1159 {
1160 text.append(QString("%1\n").arg(dataPoint.toString()));
1161 }
1162
1163 return text;
1164}

Referenced by pappso::FilterSuiteString::filter(), and pappso::FilterSuiteString::toString().

◆ unique()

void pappso::Trace::unique ( )

Definition at line 1114 of file trace.cpp.

1115{
1116 auto last =
1117 std::unique(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
1118 return (a.x == b.x);
1119 });
1120
1121 erase(last, end());
1122}

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

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

◆ xAsBase64Encoded()

QByteArray pappso::Trace::xAsBase64Encoded ( ) const

Definition at line 1168 of file trace.cpp.

1169{
1170 QByteArray unencoded_array;
1171
1172 for(auto &&data_point : *this)
1173 {
1174 QByteArray local_array;
1175 local_array.setNum(data_point.x, 'f', 12);
1176 local_array.append("\n");
1177
1178 unencoded_array.append(local_array);
1179 }
1180
1181 QByteArray base64_encoded_array = unencoded_array.toBase64(
1182 QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);
1183
1184 return base64_encoded_array;
1185}

◆ xValues()

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

Definition at line 688 of file trace.cpp.

689{
690 std::vector<pappso_double> values;
691
692 for(auto &&dataPoint : *this)
693 {
694 values.push_back(dataPoint.x);
695 }
696
697 return values;
698}

Referenced by pappso::BaseTracePlotWidget::addTrace().

◆ yAsBase64Encoded()

QByteArray pappso::Trace::yAsBase64Encoded ( ) const

Definition at line 1189 of file trace.cpp.

1190{
1191 QByteArray unencoded_array;
1192
1193 for(auto &&data_point : *this)
1194 {
1195 QByteArray local_array;
1196 local_array.setNum(data_point.y, 'f', 12);
1197 local_array.append("\n");
1198
1199 unencoded_array.append(local_array);
1200 }
1201
1202 QByteArray base64_encoded_array = unencoded_array.toBase64(
1203 QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);
1204
1205 return base64_encoded_array;
1206}

◆ yValues()

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

Definition at line 702 of file trace.cpp.

703{
704 std::vector<pappso_double> values;
705
706 for(auto &&dataPoint : *this)
707 {
708 values.push_back(dataPoint.y);
709 }
710
711 return values;
712}

Referenced by pappso::BaseTracePlotWidget::addTrace(), and pappso::MsRunRetentionTime< T >::align().

Friends And Related Symbol Documentation

◆ MassSpectrumCombinerInterface

friend class MassSpectrumCombinerInterface
friend

Definition at line 154 of file trace.h.

◆ TraceCombiner

friend class TraceCombiner
friend

Definition at line 150 of file trace.h.

◆ TraceMinusCombiner

friend class TraceMinusCombiner
friend

Definition at line 151 of file trace.h.

◆ TracePlusCombiner

friend class TracePlusCombiner
friend

Definition at line 152 of file trace.h.


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