libpappsomspp
Library for mass spectrometry
pappso::MassSpectrumCombiner Class Referenceabstract

#include <massspectrumcombiner.h>

Inheritance diagram for pappso::MassSpectrumCombiner:
pappso::MassDataCombinerInterface pappso::MassSpectrumMinusCombiner pappso::MassSpectrumPlusCombiner

Public Member Functions

 MassSpectrumCombiner ()
 Construct an uninitialized instance. More...
 
 MassSpectrumCombiner (std::vector< pappso_double > bins, int decimalPlaces=-1)
 
 MassSpectrumCombiner (int decimal_places)
 
 MassSpectrumCombiner (MassSpectrumCombinerCstSPtr other)
 
 MassSpectrumCombiner (const MassSpectrumCombiner &other)
 
 MassSpectrumCombiner (const MassSpectrumCombiner &&other)
 
virtual ~MassSpectrumCombiner ()
 Destruct the instance. More...
 
std::vector< pappso_double >::const_iterator begin () const
 
std::vector< pappso_double >::const_iterator end () const
 
std::vector< pappso_double >::iterator begin ()
 
std::vector< pappso_double >::iterator end ()
 
void setBins (std::vector< pappso_double > bins)
 
const std::vector< pappso_double > & getBins () const
 
std::size_t binCount () const
 
virtual MapTracecombine (MapTrace &map_trace, const Trace &trace) const
 
virtual MapTracecombine (MapTrace &map_trace_out, const MapTrace &map_trace_in) const
 
- 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)
 

Protected Member Functions

std::vector< pappso_double >::iterator findBin (pappso_double mz)
 Find the bin that will contain mz. More...
 

Protected Attributes

std::vector< pappso_doublem_bins
 
- 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
 

Private Member Functions

virtual MapTracecombineNoFilteringStep (MapTrace &map_trace, const Trace &trace) const =0
 

Additional Inherited Members

- Public Types inherited from pappso::MassDataCombinerInterface
using Iterator = std::vector< const Trace * >::const_iterator
 

Detailed Description

Definition at line 29 of file massspectrumcombiner.h.

Constructor & Destructor Documentation

◆ MassSpectrumCombiner() [1/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( )

Construct an uninitialized instance.

Definition at line 28 of file massspectrumcombiner.cpp.

29 {
30 }

◆ MassSpectrumCombiner() [2/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( std::vector< pappso_double bins,
int  decimalPlaces = -1 
)

Definition at line 33 of file massspectrumcombiner.cpp.

35  : MassDataCombinerInterface(decimalPlaces), m_bins(bins)
36 {
37 }

◆ MassSpectrumCombiner() [3/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( int  decimal_places)

Definition at line 40 of file massspectrumcombiner.cpp.

41  : MassDataCombinerInterface(decimal_places)
42 {
43 }

◆ MassSpectrumCombiner() [4/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( MassSpectrumCombinerCstSPtr  other)

Definition at line 55 of file massspectrumcombiner.cpp.

56  : MassDataCombinerInterface(other->m_decimalPlaces)
57 {
58  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
59 
60  m_bins.assign(other->m_bins.begin(), other->m_bins.end());
61 }

References m_bins.

◆ MassSpectrumCombiner() [5/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( const MassSpectrumCombiner other)

Definition at line 46 of file massspectrumcombiner.cpp.

47  : MassDataCombinerInterface(other.m_decimalPlaces)
48 {
49  // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()";
50 
51  m_bins.assign(other.m_bins.begin(), other.m_bins.end());
52 }

References m_bins.

◆ MassSpectrumCombiner() [6/6]

pappso::MassSpectrumCombiner::MassSpectrumCombiner ( const MassSpectrumCombiner &&  other)

◆ ~MassSpectrumCombiner()

pappso::MassSpectrumCombiner::~MassSpectrumCombiner ( )
virtual

Destruct the instance.

Definition at line 65 of file massspectrumcombiner.cpp.

66 {
67  // Calls the destructor for each DataPoint object in the vector.
68  m_bins.clear();
69 }

References m_bins.

Member Function Documentation

◆ begin() [1/2]

std::vector< pappso_double >::iterator pappso::MassSpectrumCombiner::begin ( )

Definition at line 91 of file massspectrumcombiner.cpp.

92 {
93  return m_bins.begin();
94 }

References m_bins.

◆ begin() [2/2]

std::vector< pappso_double >::const_iterator pappso::MassSpectrumCombiner::begin ( ) const

Definition at line 105 of file massspectrumcombiner.cpp.

106 {
107  return m_bins.begin();
108 }

References m_bins.

◆ binCount()

std::size_t pappso::MassSpectrumCombiner::binCount ( ) const

Definition at line 119 of file massspectrumcombiner.cpp.

120 {
121  return m_bins.size();
122 }

References m_bins.

◆ combine() [1/2]

MapTrace & pappso::MassSpectrumCombiner::combine ( MapTrace map_trace,
const Trace trace 
) const
virtual

Implements pappso::MassDataCombinerInterface.

Definition at line 137 of file massspectrumcombiner.cpp.

138 {
139 
140  // qDebug() << "Thread:" << QThread::currentThreadId()
141  //<< "Going to combine a trace this size:" << trace.size();
142 
143  if(!trace.size())
144  {
145  // qDebug() << "Thread:" << QThread::currentThreadId()
146  //<< "Returning right away because trace is empty.";
147  return map_trace;
148  }
149 
150 
151  // Let's check if we need to apply a filter to the input data.
152 
153  Trace filtered_trace(trace);
154 
156  {
157  m_filterXRange.filter(filtered_trace);
158 
159  if(!filtered_trace.size())
160  return map_trace;
161  }
162 
163  return combineNoFilteringStep(map_trace, filtered_trace);
164 }

References combineNoFilteringStep(), pappso::FilterResampleKeepXRange::filter(), pappso::MassDataCombinerInterface::m_filterXRange, and pappso::MassDataCombinerInterface::m_isApplyXRangeFilter.

◆ combine() [2/2]

MapTrace & pappso::MassSpectrumCombiner::combine ( MapTrace map_trace_out,
const MapTrace map_trace_in 
) const
virtual

Implements pappso::MassDataCombinerInterface.

Definition at line 168 of file massspectrumcombiner.cpp.

170 {
171 
172  // qDebug() << "Thread:" << QThread::currentThreadId()
173  //<< "Going to combine a map_trace_in this size:" << map_trace_in.size();
174 
175  if(!map_trace_in.size())
176  {
177  // qDebug() << "Thread:" << QThread::currentThreadId()
178  //<< "Returning right away because map_trace_in is empty.";
179  return map_trace_out;
180  }
181 
182  // Let's check if we need to apply a filter to the input data.
183 
184  Trace filtered_trace_in(map_trace_in);
185 
187  {
188  m_filterXRange.filter(filtered_trace_in);
189 
190  if(!filtered_trace_in.size())
191  return map_trace_out;
192  }
193 
194  return combineNoFilteringStep(map_trace_out, filtered_trace_in);
195 }

References combineNoFilteringStep(), pappso::FilterResampleKeepXRange::filter(), pappso::MassDataCombinerInterface::m_filterXRange, and pappso::MassDataCombinerInterface::m_isApplyXRangeFilter.

◆ combineNoFilteringStep()

virtual MapTrace& pappso::MassSpectrumCombiner::combineNoFilteringStep ( MapTrace map_trace,
const Trace trace 
) const
privatepure virtual

◆ end() [1/2]

std::vector< pappso_double >::iterator pappso::MassSpectrumCombiner::end ( )

Definition at line 98 of file massspectrumcombiner.cpp.

99 {
100  return m_bins.end();
101 }

References m_bins.

◆ end() [2/2]

std::vector< pappso_double >::const_iterator pappso::MassSpectrumCombiner::end ( ) const

Definition at line 112 of file massspectrumcombiner.cpp.

113 {
114  return m_bins.end();
115 }

References m_bins.

◆ findBin()

std::vector< pappso_double >::iterator pappso::MassSpectrumCombiner::findBin ( pappso_double  mz)
protected

Find the bin that will contain mz.

Definition at line 128 of file massspectrumcombiner.cpp.

129 {
130  return std::find_if(m_bins.begin(), m_bins.end(), [mz](pappso_double bin) {
131  return (mz <= bin);
132  });
133 }

References m_bins, and pappso::mz.

◆ getBins()

const std::vector< pappso_double > & pappso::MassSpectrumCombiner::getBins ( ) const

Definition at line 84 of file massspectrumcombiner.cpp.

85 {
86  return m_bins;
87 }

References m_bins.

◆ setBins()

void pappso::MassSpectrumCombiner::setBins ( std::vector< pappso_double bins)

Definition at line 73 of file massspectrumcombiner.cpp.

74 {
75  m_bins.assign(bins.begin(), bins.end());
76 
77  // qDebug() << "After bins assignment, local bins are of this size:"
78  //<< m_bins.size() << "Starting at:" << m_bins.front()
79  //<< "and ending at:" << m_bins.back();
80 }

References m_bins.

Member Data Documentation

◆ m_bins


The documentation for this class was generated from the following files:
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition: types.h:69
pappso::FilterResampleKeepXRange::filter
Trace & filter(Trace &trace) const override
Definition: filterresample.cpp:162
pappso::MassSpectrumCombiner::combineNoFilteringStep
virtual MapTrace & combineNoFilteringStep(MapTrace &map_trace, const Trace &trace) const =0
pappso::MassDataCombinerInterface::m_filterXRange
FilterResampleKeepXRange m_filterXRange
Definition: massdatacombinerinterface.h:48
pappso::MassDataCombinerInterface::MassDataCombinerInterface
MassDataCombinerInterface(int decimal_places=-1)
Definition: massdatacombinerinterface.cpp:19
pappso::MassSpectrumCombiner::m_bins
std::vector< pappso_double > m_bins
Definition: massspectrumcombiner.h:58
pappso::MassDataCombinerInterface::m_isApplyXRangeFilter
bool m_isApplyXRangeFilter
Definition: massdatacombinerinterface.h:46