libpappsomspp
Library for mass spectrometry
massspectrumcombiner.cpp
Go to the documentation of this file.
1 #include <numeric>
2 #include <limits>
3 #include <vector>
4 #include <map>
5 #include <cmath>
6 
7 #include <QDebug>
8 #include <QFile>
9 
10 #if 0
11 // For debugging purposes.
12 #include <QFile>
13 #endif
14 
15 #include "massspectrumcombiner.h"
16 #include "../../types.h"
17 #include "../../utils.h"
18 #include "../../pappsoexception.h"
19 #include "../../exception/exceptionoutofrange.h"
20 #include "../../exception/exceptionnotpossible.h"
21 
22 
23 namespace pappso
24 {
25 
26 
27 //! Construct an uninitialized instance.
29 {
30 }
31 
32 
34  : MassDataCombinerInterface(decimal_places)
35 {
36 }
37 
38 
39 MassSpectrumCombiner::MassSpectrumCombiner(std::vector<pappso_double> bins,
40  int decimalPlaces)
41  : MassDataCombinerInterface(decimalPlaces)
42 {
43  m_bins.assign(bins.begin(), bins.end());
44 }
45 
46 
48  : MassDataCombinerInterface(other.m_decimalPlaces)
49 {
50  m_bins.assign(other.m_bins.begin(), other.m_bins.end());
51 }
52 
53 
55  : MassDataCombinerInterface(other->m_decimalPlaces)
56 {
57  m_bins.assign(other->m_bins.begin(), other->m_bins.end());
58 }
59 
60 
61 //! Destruct the instance.
63 {
64  m_bins.clear();
65 }
66 
67 
68 void
69 MassSpectrumCombiner::setBins(std::vector<pappso_double> bins)
70 {
71  m_bins.assign(bins.begin(), bins.end());
72 
73  // qDebug() << "After bins assignment, local bins are of this size:"
74  //<< m_bins.size() << "Starting at:" << m_bins.front()
75  //<< "and ending at:" << m_bins.back();
76 }
77 
78 
79 const std::vector<pappso_double> &
81 {
82  return m_bins;
83 }
84 
85 
86 std::size_t
88 {
89  return m_bins.size();
90 }
91 
92 
93 //! Find the bin that will contain \p mz.
94 std::vector<pappso_double>::iterator
96 {
97  return std::find_if(m_bins.begin(), m_bins.end(), [mz](pappso_double bin) {
98  return (mz <= bin);
99  });
100 }
101 
102 
103 } // namespace pappso
MassSpectrumCombiner()
Construct an uninitialized instance.
std::vector< pappso_double > m_bins
void setBins(std::vector< pappso_double > bins)
const std::vector< pappso_double > & getBins() const
virtual ~MassSpectrumCombiner()
Destruct the instance.
std::vector< pappso_double >::iterator findBin(pappso_double mz)
Find the bin that will contain mz.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
double pappso_double
A type definition for doubles.
Definition: types.h:48
std::shared_ptr< const MassSpectrumCombiner > MassSpectrumCombinerCstSPtr