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"
52 qRegisterMetaType<pappso::MassSpectrum>(
"pappso::MassSpectrum");
54 qRegisterMetaType<pappso::MassSpectrum *>(
"pappso::MassSpectrum *");
67 std::vector<std::pair<pappso_double, pappso_double>> &data_point_vector)
117 assign(other.begin(), other.end());
125 vector<DataPoint>::operator=(std::move(other));
133 return std::make_shared<MassSpectrum>(*
this);
140 return std::make_shared<const MassSpectrum>(*
this);
226 if(size() != other.size())
228 qDebug() << __FILE__ <<
"@" << __LINE__ << __FUNCTION__ <<
"()"
229 <<
"The other mass spectrum size is not equal to *this size"
230 <<
"*this size:" << size() <<
"trace size:" << other.size();
237 auto trace_it = other.begin();
239 for(
auto &&data_point : *
this)
241 qDebug() <<
"first:" << data_point.x <<
"," << data_point.y
242 <<
" second:" << trace_it->x <<
"," << trace_it->y;
246 qDebug() <<
"x:" << data_point.x <<
" != " << trace_it->x;
252 qDebug() <<
"y:" << data_point.y <<
" != " << trace_it->y;
268 std::vector<DataPoint>::const_iterator it = begin();
269 std::vector<DataPoint>::const_iterator itEnd = end();
271 std::vector<DataPoint>::const_reverse_iterator itRev = rbegin();
272 std::vector<DataPoint>::const_reverse_iterator itRevEnd = rend();
277 while((it != itEnd) && (it->x <= itRev->x) && (itRev != itRevEnd))
285 else if(sumX > upper)
291 massSpectrum.push_back(*it);
292 massSpectrum.push_back(*itRev);
294 std::vector<DataPoint>::const_reverse_iterator itRevIn = itRev;
298 sumX = it->x + itRevIn->x;
299 while((sumX > lower) && (it->x <= itRevIn->x) &&
300 (itRevIn != itRevEnd))
302 sumX = it->x + itRevIn->x;
304 massSpectrum.push_back(*itRevIn);
312 std::sort(massSpectrum.begin(),
318 std::vector<DataPoint>::iterator itEndFix =
319 std::unique(massSpectrum.begin(),
323 return (a.x == b.x) && (a.y == b.y);
326 massSpectrum.resize(std::distance(massSpectrum.begin(), itEndFix));
336 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__ << size();
337 for(std::size_t i = 0; i < size(); i++)
339 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
340 qDebug() <<
"mz = " << this->operator[](i).x
341 <<
", int = " << this->operator[](i).y;
344 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
351 quint32 vector_size = massSpectrum.size();
352 outstream << vector_size;
353 for(
auto &&peak : massSpectrum)
369 if(!instream.atEnd())
371 instream >> vector_size;
372 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
373 <<
" vector_size=" << vector_size;
375 for(quint32 i = 0; i < vector_size; i++)
378 if(instream.status() != QDataStream::Ok)
381 QString(
"error in QDataStream unserialize operator>> of "
382 "massSpectrum :\nread datastream failed status=%1 "
385 .arg(instream.status())
390 massSpectrum.push_back(peak);
392 if(instream.status() != QDataStream::Ok)
396 "error in QDataStream unserialize operator>> of massSpectrum "
397 ":\nread datastream failed status=%1")
398 .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
int massSpectrumPtrMetaTypeId
int massSpectrumMetaTypeId
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
QDataStream & operator<<(QDataStream &outstream, const MassSpectrum &massSpectrum)
QDataStream & operator>>(QDataStream &instream, MassSpectrum &massSpectrum)
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr