libpappsomspp
Library for mass spectrometry
pappso::TracePlusCombiner Class Reference

#include <tracepluscombiner.h>

Inheritance diagram for pappso::TracePlusCombiner:
pappso::TraceCombiner pappso::MassDataCombinerInterface

Public Member Functions

 TracePlusCombiner ()
 
 TracePlusCombiner (int decimal_places)
 
 TracePlusCombiner (const TracePlusCombiner &other)
 
 TracePlusCombiner (TracePlusCombinerCstSPtr other)
 
virtual ~TracePlusCombiner ()
 
virtual MapTracecombine (MapTrace &map_trace, const Trace &trace) const override
 
MapTracecombine (MapTrace &map_trace_out, const MapTrace &map_trace_in) const override
 
- Public Member Functions inherited from pappso::TraceCombiner
 TraceCombiner ()
 
 TraceCombiner (int decimal_places)
 
 TraceCombiner (const TraceCombiner &other)
 
 TraceCombiner (TraceCombinerCstSPtr other)
 
virtual ~TraceCombiner ()
 
- Public Member Functions inherited from pappso::MassDataCombinerInterface
 MassDataCombinerInterface (int decimal_places=-1)
 
virtual ~MassDataCombinerInterface ()
 
void setDecimalPlaces (int value)
 
int getDecimalPlaces () const
 
virtual MapTracecombine (MapTrace &map_trace, Iterator begin, Iterator end)
 

Friends

class MassSpectrumPlusCombiner
 

Additional Inherited Members

- Public Types inherited from pappso::MassDataCombinerInterface
using Iterator = std::vector< const Trace * >::const_iterator
 
- Protected Attributes inherited from pappso::MassDataCombinerInterface
int m_decimalPlaces = -1
 Number of decimals to use for the keys (x values) More...
 

Detailed Description

Definition at line 26 of file tracepluscombiner.h.

Constructor & Destructor Documentation

◆ TracePlusCombiner() [1/4]

pappso::TracePlusCombiner::TracePlusCombiner ( )

Definition at line 23 of file tracepluscombiner.cpp.

23  : TraceCombiner()
24 {
25 }

◆ TracePlusCombiner() [2/4]

pappso::TracePlusCombiner::TracePlusCombiner ( int  decimal_places)

Definition at line 28 of file tracepluscombiner.cpp.

29  : TraceCombiner(decimal_places)
30 {
31 }

◆ TracePlusCombiner() [3/4]

pappso::TracePlusCombiner::TracePlusCombiner ( const TracePlusCombiner other)

Definition at line 34 of file tracepluscombiner.cpp.

35  : TraceCombiner(other)
36 {
37 }

◆ TracePlusCombiner() [4/4]

pappso::TracePlusCombiner::TracePlusCombiner ( TracePlusCombinerCstSPtr  other)

Definition at line 40 of file tracepluscombiner.cpp.

41  : TraceCombiner(other)
42 {
43  qDebug();
44 }

◆ ~TracePlusCombiner()

pappso::TracePlusCombiner::~TracePlusCombiner ( )
virtual

Definition at line 47 of file tracepluscombiner.cpp.

48 {
49 }

Member Function Documentation

◆ combine() [1/2]

MapTrace & pappso::TracePlusCombiner::combine ( MapTrace map_trace,
const Trace trace 
) const
overridevirtual

Implements pappso::MassDataCombinerInterface.

Definition at line 53 of file tracepluscombiner.cpp.

55 {
56  //qDebug();
57 
58  if(!trace.size())
59  return map_trace;
60 
61  for(auto &current_data_point : trace)
62  {
63 
64  // If the data point is 0-intensity, then do nothing!
65  if(!current_data_point.y)
66  continue;
67 
68  double x = Utils::roundToDecimals(current_data_point.x, m_decimalPlaces);
69 
70  std::map<double, double>::iterator map_iterator;
71 
72  std::pair<std::map<pappso_double, pappso_double>::iterator, bool> result;
73 
74  result = map_trace.insert(
75  std::pair<pappso_double, pappso_double>(x, current_data_point.y));
76 
77  if(result.second)
78  {
79  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
80  // The new element was inserted, we have nothing to do.
81  }
82  else
83  {
84  // The key already existed! The item was not inserted. We need to
85  // update the value.
86 
87  result.first->second += current_data_point.y;
88  }
89  }
90 
91  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
92  //<< "Prior to returning map_trace, its size is:" << map_trace.size();
93  // qDebug();
94  return map_trace;
95 }
int m_decimalPlaces
Number of decimals to use for the keys (x values)
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition: utils.cpp:120

References pappso::MassDataCombinerInterface::m_decimalPlaces, pappso::Utils::roundToDecimals(), and pappso::x.

Referenced by combine(), and pappso::TimsData::getQualifiedMs1MassSpectrumByPrecursorId().

◆ combine() [2/2]

MapTrace & pappso::TracePlusCombiner::combine ( MapTrace map_trace_out,
const MapTrace map_trace_in 
) const
overridevirtual

Implements pappso::MassDataCombinerInterface.

Definition at line 99 of file tracepluscombiner.cpp.

101 {
102  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
103  //<< "map trace size:" << map_trace_out.size()
104  //<< "trace size:" << trace.size();
105 
106  if(!map_trace_in.size())
107  return map_trace_out;
108 
109  return combine(map_trace_out, map_trace_in.toTrace());
110 }
virtual MapTrace & combine(MapTrace &map_trace, const Trace &trace) const override

References combine(), and pappso::MapTrace::toTrace().

Friends And Related Function Documentation

◆ MassSpectrumPlusCombiner

friend class MassSpectrumPlusCombiner
friend

Definition at line 29 of file tracepluscombiner.h.


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