libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
massspectrumcombiner.cpp
Go to the documentation of this file.
1
#include <cmath>
2
3
#include <QDebug>
4
#include <QFile>
5
6
#if 0
7
// For debugging purposes.
8
#include <QFile>
9
#endif
10
11
#include "
../../types.h
"
12
#include "
massspectrumcombiner.h
"
13
14
namespace
pappso
15
{
16
17
18
//! Construct an uninitialized instance.
19
MassSpectrumCombiner::MassSpectrumCombiner
(QObject *parent_p): QObject(parent_p)
20
{
21
}
22
23
MassSpectrumCombiner::MassSpectrumCombiner
(
int
decimal_places,
24
QObject *parent_p)
25
: QObject(parent_p),
MassDataCombinerInterface
(decimal_places)
26
{
27
}
28
29
MassSpectrumCombiner::MassSpectrumCombiner
(std::vector<pappso_double> bins,
30
int
decimalPlaces,
31
QObject *parent_p)
32
: QObject(parent_p),
MassDataCombinerInterface
(decimalPlaces)
33
{
34
m_bins
.assign(bins.begin(), bins.end());
35
}
36
37
MassSpectrumCombiner::MassSpectrumCombiner
(
const
MassSpectrumCombiner
&other,
38
QObject *parent_p)
39
: QObject(parent_p),
MassDataCombinerInterface
(other.
m_decimalPlaces
)
40
{
41
m_bins
.assign(other.
m_bins
.begin(), other.
m_bins
.end());
42
43
// QString debug_string = QString(
44
//"Number of bins: %1\n"
45
//"First bins: %2 %3 %4 -- Last bins: %5 %6 %7\n")
46
//.arg(m_bins.size())
47
//.arg(m_bins[0], 0, 'f', 6)
48
//.arg(m_bins[1], 0, 'f', 6)
49
//.arg(m_bins[2], 0, 'f', 6)
50
//.arg(m_bins[m_bins.size() - 3], 0, 'f', 6)
51
//.arg(m_bins[m_bins.size() - 2], 0, 'f', 6)
52
//.arg(m_bins[m_bins.size() - 1], 0, 'f', 6);
53
54
// qDebug().noquote() << debug_string;
55
}
56
57
MassSpectrumCombiner::MassSpectrumCombiner
(
MassSpectrumCombinerCstSPtr
other,
58
QObject *parent_p)
59
: QObject(parent_p),
MassDataCombinerInterface
(other->
m_decimalPlaces
)
60
{
61
m_bins
.assign(other->m_bins.begin(), other->m_bins.end());
62
}
63
64
//! Destruct the instance.
65
MassSpectrumCombiner::~MassSpectrumCombiner
()
66
{
67
m_bins
.clear();
68
}
69
70
void
71
MassSpectrumCombiner::setBins
(std::vector<pappso_double> bins)
72
{
73
m_bins
.assign(bins.begin(), bins.end());
74
75
// QString debug_string = QString(
76
//"Number of bins: %1\n"
77
//"First bins: %2 %3 %4 -- Last bins: %5 %6 %7\n")
78
//.arg(m_bins.size())
79
//.arg(m_bins[0], 0, 'f', 6)
80
//.arg(m_bins[1], 0, 'f', 6)
81
//.arg(m_bins[2], 0, 'f', 6)
82
//.arg(m_bins[m_bins.size() - 3], 0, 'f', 6)
83
//.arg(m_bins[m_bins.size() - 2], 0, 'f', 6)
84
//.arg(m_bins[m_bins.size() - 1], 0, 'f', 6);
85
86
// qDebug().noquote() << debug_string;
87
88
emit
binCountChanged
();
89
}
90
91
const
std::vector<pappso_double> &
92
MassSpectrumCombiner::getBins
()
const
93
{
94
return
m_bins
;
95
}
96
97
std::size_t
98
MassSpectrumCombiner::binCount
()
const
99
{
100
return
m_bins
.size();
101
}
102
103
//! Find the bin that will contain \p mz.
104
std::vector<pappso_double>::iterator
105
MassSpectrumCombiner::findBin
(
pappso_double
mz)
106
{
107
return
std::find_if(
m_bins
.begin(),
m_bins
.end(), [mz](
pappso_double
bin) {
108
return (mz <= bin);
109
});
110
}
111
112
QString
113
MassSpectrumCombiner::binsAsString
()
const
114
{
115
QString text;
116
117
for
(
auto
&bin :
m_bins
)
118
text += QString(
"%1\n"
).arg(bin, 0,
'f'
, 6);
119
120
text +=
"\n"
;
121
122
return
text;
123
}
124
125
}
// namespace pappso
pappso::MassDataCombinerInterface::m_decimalPlaces
int m_decimalPlaces
Number of decimals to use for the keys (x values).
Definition
massdatacombinerinterface.h:44
pappso::MassDataCombinerInterface::MassDataCombinerInterface
MassDataCombinerInterface(int decimal_places=-1)
Definition
massdatacombinerinterface.cpp:19
pappso::MassSpectrumCombiner::MassSpectrumCombiner
MassSpectrumCombiner(QObject *parent_p=nullptr)
Construct an uninitialized instance.
Definition
massspectrumcombiner.cpp:19
pappso::MassSpectrumCombiner::m_bins
std::vector< pappso_double > m_bins
Definition
massspectrumcombiner.h:54
pappso::MassSpectrumCombiner::setBins
void setBins(std::vector< pappso_double > bins)
Definition
massspectrumcombiner.cpp:71
pappso::MassSpectrumCombiner::binCountChanged
void binCountChanged()
pappso::MassSpectrumCombiner::binCount
std::size_t binCount() const
Definition
massspectrumcombiner.cpp:98
pappso::MassSpectrumCombiner::getBins
const std::vector< pappso_double > & getBins() const
Definition
massspectrumcombiner.cpp:92
pappso::MassSpectrumCombiner::~MassSpectrumCombiner
virtual ~MassSpectrumCombiner()
Destruct the instance.
Definition
massspectrumcombiner.cpp:65
pappso::MassSpectrumCombiner::binsAsString
QString binsAsString() const
Definition
massspectrumcombiner.cpp:113
pappso::MassSpectrumCombiner::findBin
std::vector< pappso_double >::iterator findBin(pappso_double mz)
Find the bin that will contain mz.
Definition
massspectrumcombiner.cpp:105
massspectrumcombiner.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition
types.h:60
pappso::MassSpectrumCombinerCstSPtr
std::shared_ptr< const MassSpectrumCombiner > MassSpectrumCombinerCstSPtr
Definition
massspectrumcombiner.h:21
types.h
pappsomspp
core
processing
combiners
massspectrumcombiner.cpp
Generated on
for libpappsomspp by
1.17.0