libpappsomspp
Library for mass spectrometry
trace.cpp
Go to the documentation of this file.
1 #include <numeric>
2 #include <limits>
3 #include <vector>
4 #include <map>
5 #include <cmath>
6 #include <algorithm>
7 #include <iostream>
8 
9 #include <QDebug>
10 
11 #include "trace.h"
12 #include "maptrace.h"
13 #include "../processing/combiners/tracepluscombiner.h"
14 #include "../processing/combiners/traceminuscombiner.h"
15 #include "../types.h"
16 #include "../pappsoexception.h"
17 #include "../exception/exceptionoutofrange.h"
18 #include "../exception/exceptionnotpossible.h"
19 #include "../processing/filters/filterresample.h"
20 #include "../processing/filters/filterpass.h"
21 
22 
23 int traceMetaTypeId = qRegisterMetaType<pappso::Trace>("pappso::Trace");
24 int tracePtrMetaTypeId = qRegisterMetaType<pappso::Trace *>("pappso::Trace *");
25 
26 
27 namespace pappso
28 {
29 
30 std::vector<DataPoint>::iterator
31 findFirstEqualOrGreaterX(std::vector<DataPoint>::iterator begin,
32  std::vector<DataPoint>::iterator end,
33  const double &value)
34 {
35  return std::find_if(begin, end, [value](const DataPoint &to_compare) {
36  if(to_compare.x < value)
37  {
38  return false;
39  }
40  return true;
41  });
42 }
43 
44 std::vector<DataPoint>::const_iterator
45 findFirstEqualOrGreaterX(std::vector<DataPoint>::const_iterator begin,
46  std::vector<DataPoint>::const_iterator end,
47  const double &value)
48 {
49  return std::find_if(begin, end, [value](const DataPoint &to_compare) {
50  if(to_compare.x < value)
51  {
52  return false;
53  }
54  return true;
55  });
56 }
57 
58 std::vector<DataPoint>::iterator
59 findFirstGreaterX(std::vector<DataPoint>::iterator begin,
60  std::vector<DataPoint>::iterator end,
61  const double &value)
62 {
63  return std::find_if(begin, end, [value](const DataPoint &to_compare) {
64  if(to_compare.x > value)
65  {
66  return true;
67  }
68  return false;
69  });
70 }
71 
72 std::vector<DataPoint>::const_iterator
73 findFirstGreaterX(std::vector<DataPoint>::const_iterator begin,
74  std::vector<DataPoint>::const_iterator end,
75  const double &value)
76 {
77  return std::find_if(begin, end, [value](const DataPoint &to_compare) {
78  if(to_compare.x > value)
79  {
80  return true;
81  }
82  return false;
83  });
84 }
85 
86 std::vector<DataPoint>::iterator
87 findDifferentYvalue(std::vector<DataPoint>::iterator begin,
88  std::vector<DataPoint>::iterator end,
89  const double &y_value)
90 {
91  return std::find_if(begin, end, [y_value](const DataPoint &to_compare) {
92  if(to_compare.y != y_value)
93  {
94  return true;
95  }
96  return false;
97  });
98 }
99 
100 std::vector<DataPoint>::const_iterator
101 findDifferentYvalue(std::vector<DataPoint>::const_iterator begin,
102  std::vector<DataPoint>::const_iterator end,
103  const double &y_value)
104 {
105  return std::find_if(begin, end, [y_value](const DataPoint &to_compare) {
106  if(to_compare.y != y_value)
107  {
108  return true;
109  }
110  return false;
111  });
112 }
113 
114 
115 std::vector<DataPoint>::const_iterator
116 minYDataPoint(std::vector<DataPoint>::const_iterator begin,
117  std::vector<DataPoint>::const_iterator end)
118 {
119  return std::min_element(
120  begin, end, [](const DataPoint &a, const DataPoint &b) {
121  return a.y < b.y;
122  });
123 }
124 
125 
126 std::vector<DataPoint>::iterator
127 minYDataPoint(std::vector<DataPoint>::iterator begin,
128  std::vector<DataPoint>::iterator end)
129 {
130  return std::min_element(
131  begin, end, [](const DataPoint &a, const DataPoint &b) {
132  return a.y < b.y;
133  });
134 }
135 
136 
137 std::vector<DataPoint>::const_iterator
138 maxYDataPoint(std::vector<DataPoint>::const_iterator begin,
139  std::vector<DataPoint>::const_iterator end)
140 {
141  return std::max_element(
142  begin, end, [](const DataPoint &a, const DataPoint &b) {
143  return a.y < b.y;
144  });
145 }
146 
147 
148 std::vector<DataPoint>::iterator
149 maxYDataPoint(std::vector<DataPoint>::iterator begin,
150  std::vector<DataPoint>::iterator end)
151 {
152  return std::max_element(
153  begin, end, [](const DataPoint &a, const DataPoint &b) {
154  return a.y < b.y;
155  });
156 }
157 
158 
159 // As long as next DataPoint has its y value less or equal to prev's,
160 // move along down the container. That is, continue moving is
161 // direction is downhill to the end of the container (its back).
162 std::vector<DataPoint>::const_iterator
164  std::vector<DataPoint>::const_iterator begin)
165 {
166  if(begin == trace.end())
167  return begin;
168  auto it = begin + 1;
169  auto result = begin;
170  // Move along as long as next point's y value is less
171  // or equal to prev point's y value (FR, check).
172  while((it != trace.end()) && (it->y <= result->y))
173  {
174  it++;
175  result++;
176  }
177  return result;
178 }
179 
180 std::vector<DataPoint>::const_iterator
182  std::vector<DataPoint>::const_iterator begin)
183 {
184  if(begin == trace.begin())
185  return begin;
186  auto it = begin - 1;
187  auto result = begin;
188 
189  // As long as prev datapoint has y value less or equal to next,
190  // move along up the container. That is, continue moving if
191  // direction is downhill to the beginning of the container (its front).
192  while((it != trace.begin()) && (it->y <= result->y))
193  {
194  it--;
195  result--;
196  }
197  return result;
198 }
199 
200 
201 double
202 sumYTrace(std::vector<DataPoint>::const_iterator begin,
203  std::vector<DataPoint>::const_iterator end,
204  double init)
205 {
206  return std::accumulate(
207  begin, end, init, [](double a, const DataPoint &b) { return a + b.y; });
208 }
209 
210 double
211 meanYTrace(std::vector<DataPoint>::const_iterator begin,
212  std::vector<DataPoint>::const_iterator end)
213 {
214  pappso_double nb_element = distance(begin, end);
215  if(nb_element == 0)
216  throw ExceptionOutOfRange(
217  QObject::tr("unable to compute mean on a trace of size 0"));
218  return (sumYTrace(begin, end, 0) / nb_element);
219 }
220 
221 double
222 medianYTrace(std::vector<DataPoint>::const_iterator begin,
223  std::vector<DataPoint>::const_iterator end)
224 {
225  pappso_double nb_element = distance(begin, end);
226  if(nb_element == 0)
227  throw ExceptionOutOfRange(
228  QObject::tr("unable to compute median on a trace of size 0"));
229 
230  std::vector<DataPoint> data(begin, end);
231  std::nth_element(
232  data.begin(),
233  data.begin() + data.size() / 2,
234  data.end(),
235  [](const DataPoint &a, const DataPoint &b) { return a.y < b.y; });
236  return data[data.size() / 2].y;
237 }
238 
239 double
240 areaTrace(std::vector<DataPoint>::const_iterator begin,
241  std::vector<DataPoint>::const_iterator end)
242 {
243 
244  if(begin == end)
245  return 0;
246  auto previous = begin;
247  auto next = begin + 1;
248  double area = 0;
249  while(next != end)
250  {
251  area += ((next->x - previous->x) * (previous->y + next->y)) / (double)2;
252  previous++;
253  next++;
254  }
255  return area;
256 }
257 
258 
259 Trace
260 flooredLocalMaxima(std::vector<DataPoint>::const_iterator begin,
261  std::vector<DataPoint>::const_iterator end,
262  double y_floor)
263 {
264  Trace local_maxima_trace;
265 
266  Trace single_peak_trace;
267 
268  DataPoint previous_data_point;
269 
270  for(auto iter = begin; iter != end; ++iter)
271  {
272  DataPoint iterated_data_point(iter->x, iter->y);
273 
274  // qDebug().noquote() << "Current data point:"
275  //<< iterated_data_point.toString();
276 
277  if(iterated_data_point.y < y_floor)
278  {
279  // qDebug() << "under the floor";
280 
281  if(single_peak_trace.size())
282  {
283  // qDebug() << "There was a single peak trace cooking";
284 
285  local_maxima_trace.push_back(single_peak_trace.maxYDataPoint());
286 
287  // qDebug().noquote() << "pushed back local maximum point:"
288  //<< local_maxima_trace.back().toString();
289 
290  // Clean and set the context.
291  single_peak_trace.clear();
292 
293  previous_data_point = iterated_data_point;
294 
295  continue;
296  }
297  else
298  {
299  // qDebug() << "no single peak trace cooking";
300 
301  previous_data_point = iterated_data_point;
302 
303  continue;
304  }
305  }
306  else
307  {
308  // qDebug() << "over the floor";
309 
310  // The iterated value is greater than the y_floor value, so we need to
311  // handle it.
312 
313  if(iterated_data_point.y == previous_data_point.y)
314  {
315  // We are in a flat region, no need to change anything to the
316  // context, just skip the point.
317  continue;
318  }
319  else if(iterated_data_point.y > previous_data_point.y)
320  {
321  // qDebug().noquote() << "ascending in a peak";
322 
323  // The previously iterated y value was smaller than the presently
324  // iterated one, so we are ascending in a peak.
325 
326  // All we need to do is set the context.
327 
328  single_peak_trace.push_back(iterated_data_point);
329 
330  // qDebug().noquote() << "pushed back normal point:"
331  //<< single_peak_trace.back().toString();
332 
333  previous_data_point = iterated_data_point;
334 
335  continue;
336  }
337  else
338  {
339  // qDebug().noquote() << "started descending in a peak";
340 
341  // No, the currently iterated y value is less than the previously
342  // iterated value.
343 
344  single_peak_trace.push_back(iterated_data_point);
345 
346  // qDebug().noquote() << "pushed back normal point:"
347  //<< single_peak_trace.back().toString();
348 
349  previous_data_point = iterated_data_point;
350 
351  continue;
352  }
353  }
354  }
355  // End of
356  // for(auto iter = begin; iter != end; ++iter)
357 
358  // Attention, we might arrive here with a peak being created, we need to get
359  // its maximum if that peak is non-empty;
360 
361  if(single_peak_trace.size())
362  {
363 
364  local_maxima_trace.push_back(single_peak_trace.maxYDataPoint());
365 
366  // qDebug().noquote()
367  //<< "was cooking a peak: pushed back local maximum point:"
368  //<< local_maxima_trace.back().toString();
369  }
370 
371  return local_maxima_trace;
372 }
373 
374 
376 {
377 }
378 
379 
380 Trace::Trace(const std::vector<pappso_double> &xVector,
381  const std::vector<pappso_double> &yVector)
382 {
383  initialize(xVector, yVector);
384 }
385 
386 
388  const std::vector<std::pair<pappso_double, pappso_double>> &dataPoints)
389 {
390  reserve(dataPoints.size());
391 
392  for(auto &dataPoint : dataPoints)
393  {
394  push_back(DataPoint(dataPoint));
395  }
396 
397  sortX();
398  // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
399  // return (a.x < b.x);
400  //});
401 }
402 
403 
404 Trace::Trace(const std::vector<DataPoint> &dataPoints)
405  : std::vector<DataPoint>(dataPoints)
406 {
407  sortX();
408  // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
409  // return (a.x < b.x);
410  //});
411 }
412 
413 
414 Trace::Trace(const std::vector<DataPoint> &&dataPoints)
415  : std::vector<DataPoint>(std::move(dataPoints))
416 {
417  // This constructor used by the MassSpectrum && constructor.
418 
419  sortX();
420  // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
421  // return (a.x < b.x);
422  //});
423 }
424 
425 
426 Trace::Trace(const MapTrace &map_trace)
427 {
428  for(auto &&item : map_trace)
429  push_back(DataPoint(item.first, item.second));
430 
431  // No need to sort, maps are sorted by key (that is, x).
432 }
433 
434 Trace::Trace(const Trace &other) : std::vector<DataPoint>(other)
435 {
436 }
437 
438 
439 Trace::Trace(const Trace &&other) : std::vector<DataPoint>(std::move(other))
440 {
441  // This constructor used by the MassSpectrum && constructor.
442 }
443 
444 
446 {
447  // Calls the destructor for each DataPoint object in the vector.
448  clear();
449 }
450 
451 
452 size_t
453 Trace::initialize(const std::vector<pappso_double> &xVector,
454  const std::vector<pappso_double> &yVector)
455 {
456  // Sanity check
457  if(xVector.size() != yVector.size())
458  throw ExceptionNotPossible(
459  "trace.cpp -- ERROR xVector and yVector must have the same size.");
460 
461  // We are initializing, not appending.
462  erase(begin(), end());
463 
464  for(std::size_t iter = 0; iter < xVector.size(); ++iter)
465  {
466  push_back(DataPoint(xVector.at(iter), yVector.at(iter)));
467  }
468 
469  sortX();
470  // std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
471  // return (a.x < b.x);
472  //});
473 
474 #if 0
475  for(auto &item : *this)
476  {
477  std::cout << item.x << "-" << item.y;
478  }
479 #endif
480 
481  return size();
482 }
483 
484 
485 size_t
486 Trace::initialize(const std::map<pappso_double, pappso_double> &map)
487 {
488 
489  // We are initializing, not appending.
490  erase(begin(), end());
491 
492  for(auto &&item : map)
493  {
494  push_back(DataPoint(item.first, item.second));
495  }
496 
497  // No need to sort, maps are sorted by key (that is, x).
498 
499  return size();
500 }
501 
502 
503 size_t
505 {
506  *this = other;
507 
508  return size();
509 }
510 
511 
512 Trace &
513 Trace::operator=(const Trace &other)
514 {
515  assign(other.begin(), other.end());
516 
517  return *this;
518 }
519 
520 
521 Trace &
523 {
524  vector<DataPoint>::operator=(std::move(other));
525  return *this;
526 }
527 
528 
529 TraceSPtr
531 {
532  return std::make_shared<Trace>(*this);
533 }
534 
535 
538 {
539  return std::make_shared<const Trace>(*this);
540 }
541 
542 
543 std::vector<pappso_double>
545 {
546  std::vector<pappso_double> values;
547 
548  for(auto &&dataPoint : *this)
549  {
550  values.push_back(dataPoint.x);
551  }
552 
553  return values;
554 }
555 
556 
557 std::vector<pappso_double>
559 {
560  std::vector<pappso_double> values;
561 
562  for(auto &&dataPoint : *this)
563  {
564  values.push_back(dataPoint.y);
565  }
566 
567  return values;
568 }
569 
570 
571 std::map<pappso_double, pappso_double>
573 {
574  std::map<pappso_double, pappso_double> map;
575 
576  std::pair<std::map<pappso_double, pappso_double>::iterator, bool> ret;
577 
578  for(auto &&dataPoint : *this)
579  {
580  ret = map.insert(
581  std::pair<pappso_double, pappso_double>(dataPoint.x, dataPoint.y));
582 
583  if(ret.second == false)
584  {
585  qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
586  << "It is odd that the Trace contains multiple same keys.";
587 
588  // No insertion, then increment the y value.
589  ret.first->second += dataPoint.y;
590  }
591  }
592 
593  return map;
594 }
595 
596 
597 // const DataPoint &
598 // Trace::dataPointWithX(pappso_double value) const
599 //{
600 // auto iterator =
601 // std::find_if(begin(), end(), [value](const DataPoint &dataPoint) {
602 // return (dataPoint.x == value);
603 //});
604 
605 // if(iterator != end())
606 //{
607 //// The returned data point is valid.
608 // return *iterator;
609 //}
610 // else
611 //{
612 //// The returned data point is invalid because it is not initialized.
613 // return DataPoint();
614 //}
615 //}
616 
617 
618 std::vector<DataPoint>::iterator
620 {
621  auto iterator =
622  std::find_if(begin(), end(), [value](const DataPoint &dataPoint) {
623  return (dataPoint.x == value);
624  });
625 
626  return iterator;
627 }
628 
629 
630 std::vector<DataPoint>::const_iterator
632 {
633  auto iterator =
634  std::find_if(begin(), end(), [value](const DataPoint &dataPoint) {
635  return (dataPoint.x == value);
636  });
637 
638  return iterator;
639 }
640 
641 
642 std::size_t
644 {
645  std::vector<DataPoint>::const_iterator iterator =
647 
648  if(iterator != end())
649  return std::distance(begin(), iterator);
650 
651  return std::numeric_limits<std::size_t>::max();
652 }
653 
654 
655 DataPoint
656 Trace::containsX(pappso_double value, PrecisionPtr precision_p) const
657 {
658  auto iterator = std::find_if(
659  begin(), end(), [value, precision_p](const DataPoint &data_point) {
660  if(precision_p)
661  {
662  pappso_double delta = precision_p->delta(value);
663 
664  if(data_point.x >= (value - delta) && data_point.x <= (value + delta))
665  return true;
666  else
667  return false;
668  }
669  else
670  {
671  return (data_point.x == value);
672  }
673  });
674 
675  if(iterator != end())
676  {
677  // The returned data point is valid.
678  return *iterator;
679  }
680  else
681  {
682  // The returned data point is invalid because it is not initialized.
683  return DataPoint();
684  }
685 }
686 
687 
688 const DataPoint &
690 {
691  auto dataPoint = std::min_element(
692  begin(), end(), [](const DataPoint &a, const DataPoint &b) {
693  return (a.y < b.y);
694  });
695 
696  if(dataPoint == end())
697  {
698  throw ExceptionOutOfRange(
699  QObject::tr("unable to get min peak intensity on spectrum size %1")
700  .arg(size()));
701  }
702 
703  return (*dataPoint);
704 }
705 
706 
707 const DataPoint &
709 {
710  auto dataPoint = std::max_element(
711  begin(), end(), [](const DataPoint &a, const DataPoint &b) {
712  return (a.y < b.y);
713  });
714 
715  if(dataPoint == end())
716  {
717  throw ExceptionOutOfRange(
718  QObject::tr("unable to get max peak intensity on spectrum size %1")
719  .arg(size()));
720  }
721 
722  return (*dataPoint);
723 }
724 
725 
727 Trace::minY() const
728 {
729  return minYDataPoint().y;
730 }
731 
732 
734 Trace::maxY() const
735 {
736  return maxYDataPoint().y;
737 }
738 
739 
741 Trace::sumY() const
742 {
743  // double sum = 0;
744 
745  // for(auto &&dp : m_dataPoints)
746  // sum += dp.y;
747 
748  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
749  //<< "Returning sum/tic:" << sum;
750 
751  // return sum;
752 
753  return std::accumulate(begin(),
754  end(),
755  (double)0,
756  [](pappso_double sum, const DataPoint &dataPoint) {
757  return (sum + dataPoint.y);
758  });
759 }
760 
761 
763 Trace::sumY(double mzStart, double mzEnd) const
764 {
765  auto begin_it = findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
766  return sumYTrace(
767  begin_it, findFirstGreaterX(begin_it, this->end(), mzEnd), 0);
768 }
769 
770 
772 Trace::maxY(double mzStart, double mzEnd) const
773 {
774  std::vector<DataPoint>::const_iterator begin_it =
775  findFirstEqualOrGreaterX(this->begin(), this->end(), mzStart);
776 
777  double max_y = 0;
778 
779  while(begin_it != findFirstGreaterX(begin_it, this->end(), mzEnd))
780  {
781  if(begin_it->y > max_y)
782  max_y = begin_it->y;
783  begin_it++;
784  }
785  return max_y;
786 }
787 
788 
789 void
791 {
792  std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
793  return (a.x < b.x);
794  });
795 }
796 
797 void
799 {
800  std::sort(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
801  return (a.y > b.y);
802  });
803 }
804 
805 void
807 {
808  auto last =
809  std::unique(begin(), end(), [](const DataPoint &a, const DataPoint &b) {
810  return (a.x == b.x);
811  });
812 
813  erase(last, end());
814 }
815 
816 
817 QString
819 {
820  // Even if the spectrum is empty, we should return an empty string.
821  QString text;
822 
823  for(auto &&dataPoint : *this)
824  {
825  text.append(QString("%1 %2\n")
826  .arg(dataPoint.x, 0, 'f', 10)
827  .arg(dataPoint.y, 0, 'f', 10));
828  }
829 
830  return text;
831 }
832 
833 
834 Trace &
836 {
837  return filter.filter(*this);
838 }
839 
840 } // namespace pappso
pappso::moveLowerYLeftDataPoint
std::vector< DataPoint >::const_iterator moveLowerYLeftDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move left to the lower value.
Definition: trace.cpp:181
pappso::Trace::maxYDataPoint
const DataPoint & maxYDataPoint() const
Definition: trace.cpp:708
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:69
pappso::moveLowerYRigthDataPoint
std::vector< DataPoint >::const_iterator moveLowerYRigthDataPoint(const Trace &trace, std::vector< DataPoint >::const_iterator begin)
Move right to the lower value.
Definition: trace.cpp:163
pappso::DataPoint::y
pappso_double y
Definition: datapoint.h:23
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
trace.h
pappso::Trace::Trace
Trace()
Definition: trace.cpp:375
pappso::Trace::toString
QString toString() const
Definition: trace.cpp:818
pappso::PeptideIonNter::a
@ a
pappso::DataPoint
Definition: datapoint.h:21
pappso::Trace::initialize
size_t initialize(const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
Definition: trace.cpp:453
pappso::Trace::~Trace
virtual ~Trace()
Definition: trace.cpp:445
pappso::MapTrace
Definition: maptrace.h:33
pappso::FilterInterface
generic interface to apply a filter on a trace
Definition: filterinterface.h:58
pappso::ExceptionNotPossible
Definition: exceptionnotpossible.h:53
tracePtrMetaTypeId
int tracePtrMetaTypeId
Definition: trace.cpp:24
pappso::Trace::filter
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
Definition: trace.cpp:835
pappso::Trace::sumY
pappso_double sumY() const
Definition: trace.cpp:741
pappso::Trace::sortY
void sortY()
Definition: trace.cpp:798
pappso::flooredLocalMaxima
Trace flooredLocalMaxima(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double y_floor)
Definition: trace.cpp:260
pappso::Trace::dataPointIteratorWithX
std::vector< DataPoint >::iterator dataPointIteratorWithX(pappso_double value)
Definition: trace.cpp:619
pappso::ExceptionOutOfRange
Definition: exceptionoutofrange.h:53
pappso::Trace::makeTraceCstSPtr
TraceCstSPtr makeTraceCstSPtr() const
Definition: trace.cpp:537
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::areaTrace
double areaTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
calculate the area of a trace
Definition: trace.cpp:240
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:202
pappso::TraceSPtr
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:119
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition: trace.cpp:138
pappso::Trace::unique
void unique()
Definition: trace.cpp:806
pappso::Trace::toMap
std::map< pappso_double, pappso_double > toMap() const
Definition: trace.cpp:572
pappso::QualifiedMassSpectrumParameter::last
@ last
pappso::DataPoint::x
pappso_double x
Definition: datapoint.h:22
pappso::Trace::makeTraceSPtr
TraceSPtr makeTraceSPtr() const
Definition: trace.cpp:530
traceMetaTypeId
int traceMetaTypeId
Definition: trace.cpp:23
pappso::Trace::sortX
void sortX()
Definition: trace.cpp:790
pappso::Trace::operator=
virtual Trace & operator=(const Trace &x)
Definition: trace.cpp:513
pappso::PrecisionBase::delta
virtual pappso_double delta(pappso_double value) const =0
pappso::findDifferentYvalue
std::vector< DataPoint >::iterator findDifferentYvalue(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &y_value)
find the first element in which Y is different of value
Definition: trace.cpp:87
maptrace.h
pappso::PrecisionBase
Definition: precision.h:65
pappso::Trace::xValues
std::vector< pappso_double > xValues() const
Definition: trace.cpp:544
pappso::XicExtractMethod::sum
@ sum
sum of intensities
pappso::Trace::minY
pappso_double minY() const
Definition: trace.cpp:727
pappso::Trace::minYDataPoint
const DataPoint & minYDataPoint() const
Definition: trace.cpp:689
pappso::Trace::maxY
pappso_double maxY() const
Definition: trace.cpp:734
pappso::PeptideIonNter::b
@ b
pappso::Trace::dataPointIndexWithX
std::size_t dataPointIndexWithX(pappso_double value) const
Definition: trace.cpp:643
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:31
pappso::medianYTrace
double medianYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
calculate the median of y value of a trace
Definition: trace.cpp:222
pappso::TraceCstSPtr
std::shared_ptr< const Trace > TraceCstSPtr
Definition: trace.h:120
pappso::Trace::containsX
DataPoint containsX(pappso_double value, PrecisionPtr precision_p=nullptr) const
Definition: trace.cpp:656
pappso::meanYTrace
double meanYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
calculate the mean of y value of a trace
Definition: trace.cpp:211
pappso::Trace::yValues
std::vector< pappso_double > yValues() const
Definition: trace.cpp:558
pappso::minYDataPoint
std::vector< DataPoint >::const_iterator minYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition: trace.cpp:116
pappso::Trace::dataPointCstIteratorWithX
std::vector< DataPoint >::const_iterator dataPointCstIteratorWithX(pappso_double value) const
Definition: trace.cpp:631
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:59