libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
tracepluscombiner.cpp
Go to the documentation of this file.
1
#include <numeric>
2
#include <limits>
3
#include <vector>
4
#include <map>
5
#include <cmath>
6
#include <iostream>
7
#include <iomanip>
8
9
#include <QDebug>
10
11
#include "
tracepluscombiner.h
"
12
#include "
../../trace/trace.h
"
13
#include "
../../types.h
"
14
#include "
pappsomspp/core/utils.h
"
15
#include "
pappsomspp/core/pappsoexception.h
"
16
#include "
pappsomspp/core/exception/exceptionoutofrange.h
"
17
18
19
namespace
pappso
20
{
21
22
23
TracePlusCombiner::TracePlusCombiner
() :
TraceCombiner
()
24
{
25
}
26
27
28
TracePlusCombiner::TracePlusCombiner
(
int
decimal_places) :
TraceCombiner
(decimal_places)
29
{
30
}
31
32
33
TracePlusCombiner::TracePlusCombiner
(
const
TracePlusCombiner
&other) :
TraceCombiner
(other)
34
{
35
}
36
37
38
TracePlusCombiner::TracePlusCombiner
(
TracePlusCombinerCstSPtr
other) :
TraceCombiner
(other)
39
{
40
qDebug();
41
}
42
43
44
TracePlusCombiner::~TracePlusCombiner
()
45
{
46
}
47
48
49
MapTrace
&
50
TracePlusCombiner::combine
(
MapTrace
&map_trace,
const
Trace
&trace)
const
51
{
52
// qDebug() << "With m_decimalPlaces:" << m_decimalPlaces << "map trace size:" << map_trace.size()
53
// << "trace size:" << trace.size();
54
55
if
(!trace.size())
56
return
map_trace;
57
58
for
(
auto
¤t_data_point : trace)
59
{
60
61
// If the data point is 0-intensity, then do nothing!
62
if
(!current_data_point.y)
63
continue
;
64
65
double
x
=
Utils::roundToDecimals
(current_data_point.x,
m_decimalPlaces
);
66
// double x = current_data_point.x;
67
68
std::map<double, double>::iterator map_iterator;
69
70
std::pair<std::map<pappso_double, pappso_double>::iterator,
bool
> result;
71
72
result = map_trace.insert(std::pair<pappso_double, pappso_double>(
x
, current_data_point.y));
73
74
if
(result.second)
75
{
76
// qDebug() << " The element to insert was not there already, we added it.";
77
// The new element was inserted, we have nothing to do.
78
}
79
else
80
{
81
// The key already existed! The item was not inserted. We need to
82
// update the value.
83
84
// qDebug() << " The element to insert was there already, we increment y.";
85
result.first->second += current_data_point.y;
86
}
87
}
88
89
// qDebug() << "Prior to returning map_trace, its size is:" << map_trace.size();
90
return
map_trace;
91
}
92
93
94
MapTrace
&
95
TracePlusCombiner::combine
(
MapTrace
&map_trace_out,
const
MapTrace
&map_trace_in)
const
96
{
97
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
98
//<< "map trace size:" << map_trace_out.size()
99
//<< "trace size:" << trace.size();
100
101
if
(!map_trace_in.size())
102
return
map_trace_out;
103
104
return
combine
(map_trace_out, map_trace_in.
toTrace
());
105
}
106
107
108
}
// namespace pappso
pappso::MapTrace
Definition
maptrace.h:36
pappso::MapTrace::toTrace
Trace toTrace() const
Definition
maptrace.cpp:214
pappso::MassDataCombinerInterface::m_decimalPlaces
int m_decimalPlaces
Number of decimals to use for the keys (x values).
Definition
massdatacombinerinterface.h:44
pappso::TraceCombiner::TraceCombiner
TraceCombiner()
Definition
tracecombiner.cpp:21
pappso::TracePlusCombiner::~TracePlusCombiner
virtual ~TracePlusCombiner()
Definition
tracepluscombiner.cpp:44
pappso::TracePlusCombiner::TracePlusCombiner
TracePlusCombiner()
Definition
tracepluscombiner.cpp:23
pappso::TracePlusCombiner::combine
virtual MapTrace & combine(MapTrace &map_trace, const Trace &trace) const override
Definition
tracepluscombiner.cpp:50
pappso::Trace
A simple container of DataPoint instances.
Definition
trace.h:152
pappso::Utils::roundToDecimals
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition
utils.cpp:140
exceptionoutofrange.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::TracePlusCombinerCstSPtr
std::shared_ptr< const TracePlusCombiner > TracePlusCombinerCstSPtr
Definition
tracepluscombiner.h:22
pappso::PeptideIonCter::x
@ x
Definition
peptide.h:92
pappsoexception.h
trace.h
tracepluscombiner.h
types.h
utils.h
pappsomspp
core
processing
combiners
tracepluscombiner.cpp
Generated on
for libpappsomspp by
1.17.0