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