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
 
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 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...
 
bool m_isApplyXRangeFilter = false
 
FilterResampleKeepXRange m_filterXRange
 

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.

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.m_decimalPlaces)
36 {
37 }

◆ TracePlusCombiner() [4/4]

pappso::TracePlusCombiner::TracePlusCombiner ( TracePlusCombinerCstSPtr  other)

Definition at line 40 of file tracepluscombiner.cpp.

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

◆ ~TracePlusCombiner()

pappso::TracePlusCombiner::~TracePlusCombiner ( )
virtual

Definition at line 46 of file tracepluscombiner.cpp.

47 {
48 }

Member Function Documentation

◆ combine() [1/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 52 of file tracepluscombiner.cpp.

53 {
54  // qDebug();
55 
56  if(!trace.size())
57  return map_trace;
58 
59  // Let's check if we need to apply a filter to the input data.
60 
61  Trace filtered_trace(trace);
62 
64  {
65  m_filterXRange.filter(filtered_trace);
66 
67  if(!filtered_trace.size())
68  return map_trace;
69  }
70 
71  for(auto &current_data_point : filtered_trace)
72  {
73 
74  // If the data point is 0-intensity, then do nothing!
75  if(!current_data_point.y)
76  continue;
77 
78  double x = Utils::roundToDecimals(current_data_point.x, m_decimalPlaces);
79 
80  std::map<double, double>::iterator map_iterator;
81 
82  std::pair<std::map<pappso_double, pappso_double>::iterator, bool> result;
83 
84  result = map_trace.insert(
85  std::pair<pappso_double, pappso_double>(x, current_data_point.y));
86 
87  if(result.second)
88  {
89  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
90  // The new element was inserted, we have nothing to do.
91  }
92  else
93  {
94  // The key already existed! The item was not inserted. We need to
95  // update the value.
96 
97  result.first->second += current_data_point.y;
98  }
99  }
100 
101  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
102  //<< "Prior to returning map_trace, its size is:" << map_trace.size();
103  // qDebug();
104  return map_trace;
105 }

References pappso::FilterResampleKeepXRange::filter(), pappso::MassDataCombinerInterface::m_decimalPlaces, pappso::MassDataCombinerInterface::m_filterXRange, pappso::MassDataCombinerInterface::m_isApplyXRangeFilter, pappso::Utils::roundToDecimals(), and pappso::x.

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

◆ combine() [2/2]

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

Implements pappso::MassDataCombinerInterface.

Definition at line 109 of file tracepluscombiner.cpp.

111 {
112  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
113  //<< "map trace size:" << map_trace_out.size()
114  //<< "trace size:" << trace.size();
115 
116  if(!map_trace_in.size())
117  return map_trace_out;
118 
119  // The call below will ensure that if there are filtering steps to apply, they
120  // are actually applied.
121  return combine(map_trace_out, map_trace_in.toTrace());
122 }

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:
pappso::TraceCombiner::TraceCombiner
TraceCombiner()
Definition: tracecombiner.cpp:21
pappso::TracePlusCombiner::combine
virtual MapTrace & combine(MapTrace &map_trace, const Trace &trace) const override
Definition: tracepluscombiner.cpp:52
pappso::MassDataCombinerInterface::m_decimalPlaces
int m_decimalPlaces
Number of decimals to use for the keys (x values)
Definition: massdatacombinerinterface.h:44
pappso::FilterResampleKeepXRange::filter
Trace & filter(Trace &trace) const override
Definition: filterresample.cpp:162
pappso::PeptideIonCter::x
@ x
pappso::MassDataCombinerInterface::m_filterXRange
FilterResampleKeepXRange m_filterXRange
Definition: massdatacombinerinterface.h:48
pappso::Utils::roundToDecimals
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition: utils.cpp:125
pappso::MassDataCombinerInterface::m_isApplyXRangeFilter
bool m_isApplyXRangeFilter
Definition: massdatacombinerinterface.h:46