Loading...
Searching...
No Matches
tracepluscombiner.cpp
Go to the documentation of this file.
#include <numeric>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <QDebug>
#include "tracepluscombiner.h"
#include "../../trace/trace.h"
#include "../../types.h"
#include "../../utils.h"
#include "../../pappsoexception.h"
#include "../../exception/exceptionoutofrange.h"
namespace pappso
{
TracePlusCombiner::TracePlusCombiner() : TraceCombiner()
{
}
TracePlusCombiner::TracePlusCombiner(int decimal_places)
: TraceCombiner(decimal_places)
{
}
TracePlusCombiner::TracePlusCombiner(const TracePlusCombiner &other)
: TraceCombiner(other)
{
}
TracePlusCombiner::TracePlusCombiner(TracePlusCombinerCstSPtr other)
: TraceCombiner(other)
{
qDebug();
}
TracePlusCombiner::~TracePlusCombiner()
{
}
MapTrace &
TracePlusCombiner::combine(MapTrace &map_trace, const Trace &trace) const
{
// qDebug() << "With m_decimalPlaces:" << m_decimalPlaces;
if(!trace.size())
return map_trace;
for(auto &current_data_point : trace)
{
// If the data point is 0-intensity, then do nothing!
if(!current_data_point.y)
continue;
double x = Utils::roundToDecimals(current_data_point.x, m_decimalPlaces);
std::map<double, double>::iterator map_iterator;
std::pair<std::map<pappso_double, pappso_double>::iterator, bool> result;
result = map_trace.insert(
std::pair<pappso_double, pappso_double>(x, current_data_point.y));
if(result.second)
{
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
// The new element was inserted, we have nothing to do.
}
else
{
// The key already existed! The item was not inserted. We need to
// update the value.
result.first->second += current_data_point.y;
}
}
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
//<< "Prior to returning map_trace, its size is:" << map_trace.size();
// qDebug();
return map_trace;
}
MapTrace &
TracePlusCombiner::combine(MapTrace &map_trace_out,
const MapTrace &map_trace_in) const
{
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
//<< "map trace size:" << map_trace_out.size()
//<< "trace size:" << trace.size();
if(!map_trace_in.size())
return map_trace_out;
return combine(map_trace_out, map_trace_in.toTrace());
}
} // namespace pappso
pappso::MapTrace
Definition maptrace.h:34
pappso::MapTrace::toTrace
Trace toTrace() const
Definition maptrace.cpp:219
pappso::MassDataCombinerInterface::m_decimalPlaces
int m_decimalPlaces
Number of decimals to use for the keys (x values)
Definition massdatacombinerinterface.h:44
pappso::TraceCombiner
Definition tracecombiner.h:28
pappso::TracePlusCombiner
Definition tracepluscombiner.h:27
pappso::TracePlusCombiner::~TracePlusCombiner
virtual ~TracePlusCombiner()
Definition tracepluscombiner.cpp:47
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:53
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:148
pappso::Utils::roundToDecimals
static pappso_double roundToDecimals(pappso_double value, int decimal_places)
Definition utils.cpp:142
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
tracepluscombiner.h