47 #include "../../utils.h"
48 #include "../../massspectrum/massspectrum.h"
80 bool removeZeroValDataPoints)
81 : m_smallestMz(minMz),
83 m_binningType(binningType),
84 m_decimalPlaces(decimalPlaces),
85 mp_precision(precisionPtr),
86 m_applyMzShift(applyMzShift),
88 m_removeZeroValDataPoints(removeZeroValDataPoints)
96 : m_smallestMz(other.m_smallestMz),
97 m_greatestMz(other.m_greatestMz),
98 m_binningType(other.m_binningType),
99 m_decimalPlaces(other.m_decimalPlaces),
100 mp_precision(other.mp_precision),
101 m_applyMzShift(other.m_applyMzShift),
102 m_mzShift(other.m_mzShift),
103 m_removeZeroValDataPoints(other.m_removeZeroValDataPoints)
291 errors += (
m_smallestMz == std::numeric_limits<double>::max() ? 1 : 0);
296 errors += (
m_greatestMz == std::numeric_limits<double>::min() ? 1 : 0);
307 <<
"The m/z integration parameters are not valid or do not apply...";
317 return (
m_smallestMz != std::numeric_limits<double>::max()) &&
328 std::vector<double> bins;
344 qFatal(
"Programming error.");
357 std::vector<double> bins;
423 double first_mz = ceil((min_mz * std::pow(10,
m_decimalPlaces)) - 0.49) /
435 std::vector<pappso::pappso_double> bins;
448 bins.push_back(previous_mz_bin);
457 while(previous_mz_bin <= last_mz)
478 double current_rounded_mz =
492 if(current_rounded_mz == previous_mz_bin)
505 bins.push_back(current_rounded_mz);
508 previous_mz_bin = current_rounded_mz;
514 QString fileName =
"/tmp/massSpecArbitraryBins.txt-at-" +
515 QDateTime::currentDateTime().toString(
"yyyyMMdd-HH-mm-ss");
517 qDebug() <<
"Writing the list of bins setup in the "
518 "mass spectrum in file "
521 QFile file(fileName);
522 file.open(QIODevice::WriteOnly);
524 QTextStream fileStream(&file);
526 for(
auto &&bin : bins)
527 fileStream << QString(
"%1\n").arg(bin, 0,
'f', 10);
553 std::vector<pappso::pappso_double> bins;
555 if(mass_spectrum_csp->size() < 2)
562 local_mass_spectrum.
sortMz();
583 std::vector<pappso::DataPoint>::const_iterator it =
584 local_mass_spectrum.begin();
594 while(it != local_mass_spectrum.end())
603 end_mz_out = start_mz_in + step;
614 bins.push_back(start_mz_in);
617 start_mz_in = end_mz_out;
628 QString fileName =
"/tmp/massSpecDataBasedBins.txt";
630 qDebug() <<
"Writing the list of bins setup in the "
631 "mass spectrum in file "
634 QFile file(fileName);
635 file.open(QIODevice::WriteOnly);
637 QTextStream fileStream(&file);
639 for(
auto &&bin : m_bins)
640 fileStream << QString(
"[%1-%2]\n")
641 .arg(bin.startMzIn, 0,
'f', 10)
642 .arg(bin.endMzOut, 0,
'f', 10);
647 qDebug() <<
"elements."
648 <<
"starting with mz" << m_bins.front().startMzIn <<
"ending with mz"
649 << m_bins.back().endMzOut;
662 for(
int iter = 0; iter < offset; ++iter)
666 text +=
"m/z integration parameters:\n";
672 QString::asprintf(
"Smallest (first) m/z: %.6f\n",
m_smallestMz));
677 text.append(QString::asprintf(
"Greatest (last) m/z: %.6f\n",
m_greatestMz));
683 std::map<BinningType, QString>::iterator it;
687 qFatal(
"Programming error.");
691 text.append(QString(
"Binning type: %1\n").arg(it->second.toLatin1().data()));
700 text.append(QString(
"Bin nominal size: %1\n")
706 text.append(QString(
"Bin size: %2\n")
715 QString(
"Apply m/z shift: %1\n").arg(
m_applyMzShift ?
"true" :
"false");
722 text += QString(
"m/z shift: %1").arg(
m_mzShift, 0,
'f', 6);
727 text += QString(
"Remove 0-val data points: %1\n")
Class to represent a mass spectrum.
void sortMz()
Sort the DataPoint instances of this spectrum.
The MzIntegrationParams class provides the parameters definining how m/z !
BinningType getBinningType() const
int getDecimalPlaces() const
pappso::pappso_double getSmallestMz() const
pappso::pappso_double m_smallestMz
MzIntegrationParams & operator=(const MzIntegrationParams &other)
BinningType m_binningType
pappso::pappso_double getGreatestMz() const
pappso::pappso_double m_greatestMz
pappso::PrecisionPtr getPrecision() const
bool isApplyMzShift() const
std::vector< double > createArbitraryBins()
void setPrecision(pappso::PrecisionPtr precisionPtr)
double getMzShift() const
void updateSmallestMz(pappso::pappso_double value)
void updateGreatestMz(pappso::pappso_double value)
bool isRemoveZeroValDataPoints() const
bool hasValidMzRange() const
QString toString(int offset=0, const QString &spacer=QString()) const
pappso::PrecisionPtr mp_precision
void setSmallestMz(pappso::pappso_double value)
bool m_removeZeroValDataPoints
void setBinningType(BinningType binningType)
void reset()
Reset the instance to default values.
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)
void setApplyMzShift(bool applyMzShift)
void setDecimalPlaces(int decimal_places)
std::vector< pappso::pappso_double > createBins()
void setMzShift(double value)
void setRemoveZeroValDataPoints(bool removeOrNot=true)
virtual ~MzIntegrationParams()
void setGreatestMz(pappso::pappso_double value)
pappso::pappso_double m_mzShift
virtual QString toString() const =0
virtual pappso_double getNominal() const final
virtual pappso_double delta(pappso_double value) const =0
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
BinningType
Type of binning when performing integrations to a mass spectrum.
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::map< BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.