libpappsomspp
Library for mass spectrometry
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
 
virtual 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
 
void setFilterResampleKeepXRange (const FilterResampleKeepXRange &range)
 
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) More...
 
bool m_isApplyXRangeFilter = false
 
FilterResampleKeepXRange m_filterXRange
 

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.

28  : TraceCombiner(decimal_places)
29 {
30 }

◆ TraceMinusCombiner() [3/4]

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

Definition at line 33 of file traceminuscombiner.cpp.

34  : TraceCombiner(other.m_decimalPlaces)
35 {
36 }

◆ TraceMinusCombiner() [4/4]

pappso::TraceMinusCombiner::TraceMinusCombiner ( TraceMinusCombinerCstSPtr  other)

Definition at line 39 of file traceminuscombiner.cpp.

40  : TraceCombiner(other->m_decimalPlaces)
41 {
42 }

◆ ~TraceMinusCombiner()

pappso::TraceMinusCombiner::~TraceMinusCombiner ( )
virtual

Definition at line 45 of file traceminuscombiner.cpp.

46 {
47 }

Member Function Documentation

◆ combine() [1/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 51 of file traceminuscombiner.cpp.

52 {
53  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
54  //<< "map trace size:" << map_trace.size()
55  //<< "trace size:" << trace.size();
56 
57  if(!trace.size())
58  return map_trace;
59 
60  for(auto &current_data_point : trace)
61  {
62 
63  // If the data point is 0-intensity, then do nothing!
64  if(!current_data_point.y)
65  continue;
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  result = map_trace.insert(
74  std::pair<pappso_double, pappso_double>(x, current_data_point.y));
75 
76  if(result.second)
77  {
78  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
79  // The new element was inserted, we have nothing to do.
80  }
81  else
82  {
83  // The key already existed! The item was not inserted. We need to
84  // update the value.
85 
86  result.first->second -= current_data_point.y;
87  }
88  }
89 
90  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
91  //<< "Prior to returning map_trace, its size is:" << map_trace.size();
92 
93  return map_trace;
94 }

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

◆ combine() [2/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 98 of file traceminuscombiner.cpp.

100 {
101  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
102  //<< "map trace size:" << map_trace_out.size()
103  //<< "trace size:" << trace.size();
104 
105  if(!map_trace_in.size())
106  return map_trace_out;
107 
108  for(auto &map_pair : map_trace_in)
109  {
110 
111  // If the data point is 0-intensity, then do nothing!
112  if(!map_pair.second)
113  continue;
114 
115  double x = Utils::roundToDecimals(map_pair.first, m_decimalPlaces);
116 
117  std::map<double, double>::iterator map_iterator;
118 
119  std::pair<std::map<pappso_double, pappso_double>::iterator, bool> result;
120 
121  result = map_trace_out.insert(
122  std::pair<pappso_double, pappso_double>(x, map_pair.second));
123 
124  if(result.second)
125  {
126  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
127  // The new element was inserted, we have nothing to do.
128  }
129  else
130  {
131  // The key already existed! The item was not inserted. We need to
132  // update the value.
133 
134  result.first->second -= map_pair.second;
135  }
136  }
137 
138  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
139  //<< "Prior to returning map_trace_out, its size is:" << map_trace_out.size();
140 
141  return map_trace_out;
142 }

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

Friends And Related Function 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:
pappso::TraceCombiner::TraceCombiner
TraceCombiner()
Definition: tracecombiner.cpp:21
pappso::MassDataCombinerInterface::m_decimalPlaces
int m_decimalPlaces
Number of decimals to use for the keys (x values)
Definition: massdatacombinerinterface.h:44
pappso::PeptideIonCter::x
@ x
pappso::Utils::roundToDecimals
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition: utils.cpp:125