39#include "../trace/datapoint.h"
40#include "../trace/trace.h"
42#include "../processing/combiners/massspectrumcombiner.h"
43#include "../mzrange.h"
44#include "../pappsoexception.h"
46#include "../peptide/peptidefragmentionlistbase.h"
47#include "../exception/exceptionoutofrange.h"
48#include "../processing/filters/filterresample.h"
61 std::vector<std::pair<pappso_double, pappso_double>> &data_point_vector)
111 assign(other.begin(), other.end());
119 vector<DataPoint>::operator=(std::move(other));
127 return std::make_shared<MassSpectrum>(*
this);
134 return std::make_shared<const MassSpectrum>(*
this);
220 if(size() != other.size())
222 qDebug() << __FILE__ <<
"@" << __LINE__ << __FUNCTION__ <<
"()"
223 <<
"The other mass spectrum size is not equal to *this size"
224 <<
"*this size:" << size() <<
"trace size:" << other.size();
231 auto trace_it = other.begin();
233 for(
auto &&data_point : *
this)
235 qDebug() <<
"first:" << data_point.x <<
"," << data_point.y
236 <<
" second:" << trace_it->x <<
"," << trace_it->y;
240 qDebug() <<
"x:" << data_point.x <<
" != " << trace_it->x;
246 qDebug() <<
"y:" << data_point.y <<
" != " << trace_it->y;
262 std::vector<DataPoint>::const_iterator it = begin();
263 std::vector<DataPoint>::const_iterator itEnd = end();
265 std::vector<DataPoint>::const_reverse_iterator itRev = rbegin();
266 std::vector<DataPoint>::const_reverse_iterator itRevEnd = rend();
271 while((it != itEnd) && (it->x <= itRev->x) && (itRev != itRevEnd))
279 else if(sumX > upper)
285 massSpectrum.push_back(*it);
286 massSpectrum.push_back(*itRev);
288 std::vector<DataPoint>::const_reverse_iterator itRevIn = itRev;
292 sumX = it->x + itRevIn->x;
293 while((sumX > lower) && (it->x <= itRevIn->x) &&
294 (itRevIn != itRevEnd))
296 sumX = it->x + itRevIn->x;
298 massSpectrum.push_back(*itRevIn);
306 std::sort(massSpectrum.begin(),
312 std::vector<DataPoint>::iterator itEndFix =
313 std::unique(massSpectrum.begin(),
317 return (a.x == b.x) && (a.y == b.y);
320 massSpectrum.resize(std::distance(massSpectrum.begin(), itEndFix));
330 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__ << size();
331 for(std::size_t i = 0; i < size(); i++)
333 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
334 qDebug() <<
"mz = " << this->operator[](i).x
335 <<
", int = " << this->operator[](i).y;
338 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
345 quint32 vector_size = massSpectrum.size();
346 outstream << vector_size;
347 for(
auto &&peak : massSpectrum)
363 if(!instream.atEnd())
365 instream >> vector_size;
366 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
367 <<
" vector_size=" << vector_size;
369 for(quint32 i = 0; i < vector_size; i++)
372 if(instream.status() != QDataStream::Ok)
375 QString(
"error in QDataStream unserialize operator>> of "
376 "massSpectrum :\nread datastream failed status=%1 "
379 .arg(instream.status())
384 massSpectrum.push_back(peak);
386 if(instream.status() != QDataStream::Ok)
390 "error in QDataStream unserialize operator>> of massSpectrum "
391 ":\nread datastream failed status=%1")
392 .arg(instream.status()));
generic interface to apply a filter on a MassSpectrum This is the same as FilterInterface,...
Class to represent a mass spectrum.
void sortMz()
Sort the DataPoint instances of this spectrum.
void debugPrintValues() const
MassSpectrumCstSPtr makeMassSpectrumCstSPtr() const
bool equals(const MassSpectrum &other, PrecisionPtr precision) const
Tells if this MassSpectrum is equal to massSpectrum.
MassSpectrumSPtr makeMassSpectrumSPtr() const
pappso_double tic() const
Compute the total ion current of this mass spectrum.
const DataPoint & minIntensityDataPoint() const
Find the DataPoint instance having the smallest intensity (y) value.
virtual MassSpectrum & massSpectrumFilter(const MassSpectrumFilterInterface &filter) final
apply a filter on this MassSpectrum
MassSpectrum filterSum(const MzRange &mass_range) const
virtual MassSpectrum & operator=(const MassSpectrum &other)
pappso_double totalIonCurrent() const
Compute the total ion current of this mass spectrum.
const DataPoint & maxIntensityDataPoint() const
Find the DataPoint instance having the greatest intensity (y) value.
pappso_double lower() const
pappso_double upper() const
bool contains(pappso_double) const
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
A simple container of DataPoint instances.
pappso_double sumY() const
const DataPoint & maxYDataPoint() const
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
const DataPoint & minYDataPoint() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
QDataStream & operator>>(QDataStream &instream, MassSpectrum &massSpectrum)
QDataStream & operator<<(QDataStream &outstream, const MassSpectrum &massSpectrum)
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr