114 assign(other.begin(), other.end());
122 vector<DataPoint>::operator=(std::move(other));
130 return std::make_shared<MassSpectrum>(*
this);
137 return std::make_shared<const MassSpectrum>(*
this);
223 if(size() != other.size())
225 qDebug() << __FILE__ <<
"@" << __LINE__ << __FUNCTION__ <<
"()"
226 <<
"The other mass spectrum size is not equal to *this size"
227 <<
"*this size:" << size() <<
"trace size:" << other.size();
234 auto trace_it = other.begin();
236 for(
auto &&data_point : *
this)
238 qDebug() <<
"first:" << data_point.x <<
"," << data_point.y <<
" second:" << trace_it->x
239 <<
"," << trace_it->y;
243 qDebug() <<
"x:" << data_point.x <<
" != " << trace_it->x;
249 qDebug() <<
"y:" << data_point.y <<
" != " << trace_it->y;
265 std::vector<DataPoint>::const_iterator it = begin();
266 std::vector<DataPoint>::const_iterator itEnd = end();
268 std::vector<DataPoint>::const_reverse_iterator itRev = rbegin();
269 std::vector<DataPoint>::const_reverse_iterator itRevEnd = rend();
274 while((it != itEnd) && (it->x <= itRev->x) && (itRev != itRevEnd))
282 else if(sumX > upper)
288 massSpectrum.push_back(*it);
289 massSpectrum.push_back(*itRev);
291 std::vector<DataPoint>::const_reverse_iterator itRevIn = itRev;
295 sumX = it->x + itRevIn->x;
296 while((sumX > lower) && (it->x <= itRevIn->x) && (itRevIn != itRevEnd))
298 sumX = it->x + itRevIn->x;
300 massSpectrum.push_back(*itRevIn);
308 std::sort(massSpectrum.begin(), massSpectrum.end(), [](
const DataPoint &
a,
const DataPoint &
b) {
314 std::vector<DataPoint>::iterator itEndFix = std::unique(
317 return (a.x == b.x) && (a.y == b.y);
320 massSpectrum.resize(std::distance(massSpectrum.begin(), itEndFix));
331 for(std::size_t i = 0; i < size(); i++)
333 qDebug() <<
"(" << this->operator[](i).x <<
"," << this->operator[](i).y <<
")";
341 quint32 vector_size = massSpectrum.size();
342 outstream << vector_size;
343 for(
auto &&peak : massSpectrum)
357 if(!instream.atEnd())
360 instream >> vector_size;
361 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
362 <<
" vector_size=" << vector_size;
364 for(quint32 i = 0; i < vector_size; i++)
367 if(instream.status() != QDataStream::Ok)
369 throw PappsoException(QString(
"error in QDataStream unserialize operator>> of "
370 "massSpectrum :\nread datastream failed status=%1 "
373 .arg(instream.status())
378 massSpectrum.push_back(peak);
380 if(instream.status() != QDataStream::Ok)
383 QString(
"error in QDataStream unserialize operator>> of massSpectrum "
384 ":\nread datastream failed status=%1")
385 .arg(instream.status()));
396 return filter.filter(*
this);
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
pappso_double sumY() const
const DataPoint & maxYDataPoint() const
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
void sortX(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
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
const PrecisionBase * PrecisionPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr