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

#include <traceminuscombiner.h>

Inheritance diagram for pappso::TraceMinusCombiner:
pappso::TraceCombiner pappso::MassDataCombinerInterface

Public Member Functions

 TraceMinusCombiner ()
 
 TraceMinusCombiner (int decimal_places)
 
 TraceMinusCombiner (const TraceMinusCombiner &other)
 
 TraceMinusCombiner (TraceMinusCombinerCstSPtr other)
 
virtual ~TraceMinusCombiner ()
 
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 MassSpectrumMinusCombiner
 

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)
 

Detailed Description

Definition at line 26 of file traceminuscombiner.h.

Constructor & Destructor Documentation

◆ TraceMinusCombiner() [1/4]

pappso::TraceMinusCombiner::TraceMinusCombiner ( )

Definition at line 22 of file traceminuscombiner.cpp.

23{
24}

◆ TraceMinusCombiner() [2/4]

pappso::TraceMinusCombiner::TraceMinusCombiner ( int  decimal_places)

Definition at line 27 of file traceminuscombiner.cpp.

27 : TraceCombiner(decimal_places)
28{
29}

◆ TraceMinusCombiner() [3/4]

pappso::TraceMinusCombiner::TraceMinusCombiner ( const TraceMinusCombiner other)

Definition at line 32 of file traceminuscombiner.cpp.

32 : TraceCombiner(other)
33{
34}

◆ TraceMinusCombiner() [4/4]

pappso::TraceMinusCombiner::TraceMinusCombiner ( TraceMinusCombinerCstSPtr  other)

Definition at line 37 of file traceminuscombiner.cpp.

37 : TraceCombiner(other)
38{
39}

◆ ~TraceMinusCombiner()

pappso::TraceMinusCombiner::~TraceMinusCombiner ( )
virtual

Definition at line 42 of file traceminuscombiner.cpp.

43{
44}

Member Function Documentation

◆ combine() [1/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 48 of file traceminuscombiner.cpp.

49{
50 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
51 //<< "map trace size:" << map_trace.size()
52 //<< "trace size:" << trace.size();
53
54 if(!trace.size())
55 return map_trace;
56
57 for(auto &current_data_point : trace)
58 {
59
60 // If the data point is 0-intensity, then do nothing!
61 if(!current_data_point.y)
62 continue;
63
64 // qDebug() << "Iterating in new trace data point:"
65 //<< current_data_point.toString(15);
66
67 double x = Utils::roundToDecimals(current_data_point.x, m_decimalPlaces);
68
69 std::map<double, double>::iterator map_iterator;
70
71 std::pair<std::map<pappso_double, pappso_double>::iterator, bool> result;
72
73 // qDebug() << "Willing to insert new data point:" << x << ","
74 //<< -current_data_point.y;
75
76 result = map_trace.insert(std::pair<pappso_double, pappso_double>(x, -current_data_point.y));
77
78 if(result.second)
79 {
80 // qDebug() << "Inserted new data point:" << x << ","
81 //<< -current_data_point.y;
82 // The new element was inserted, we have nothing to do.
83 }
84 else
85 {
86 // qDebug() << "Going to decrement from" << result.first->second
87 //<< "a value of " << current_data_point.y;
88
89 // The key already existed! The item was not inserted. We need to
90 // update the value.
91
92 result.first->second -= current_data_point.y;
93
94 // qDebug() << "New result: " << result.first->second;
95 }
96 }
97
98 // qDebug() << "Prior to returning map_trace, its size is:" <<
99 // map_trace.size();
100
101 return map_trace;
102}
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:140

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

Referenced by combine().

◆ combine() [2/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 106 of file traceminuscombiner.cpp.

107{
108 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
109 //<< "map trace size:" << map_trace_out.size()
110 //<< "trace size:" << trace.size();
111
112 if(!map_trace_in.size())
113 return map_trace_out;
114
115 return combine(map_trace_out, map_trace_in.toTrace());
116}
virtual MapTrace & combine(MapTrace &map_trace, const Trace &trace) const override

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

Friends And Related Symbol Documentation

◆ MassSpectrumMinusCombiner

friend class MassSpectrumMinusCombiner
friend

Definition at line 29 of file traceminuscombiner.h.


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