47 #include "../../utils.h"
48 #include "../../massspectrum/massspectrum.h"
61 {BinningType::NONE,
"NONE"},
62 {BinningType::DATA_BASED,
"DATA_BASED"},
63 {BinningType::ARBITRARY,
"ARBITRARY"}};
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),
104 m_applySavGolFilter(other.m_applySavGolFilter)
295 int nL,
int nR,
int m,
int lD,
bool convolveWithNr)
359 errors += (
m_smallestMz == std::numeric_limits<double>::max() ? 1 : 0);
364 errors += (
m_greatestMz == std::numeric_limits<double>::min() ? 1 : 0);
375 <<
"The m/z integration parameters are not valid or do not apply...";
385 return (
m_smallestMz != std::numeric_limits<double>::max()) &&
396 std::vector<double> bins;
412 qFatal(
"Programming error.");
425 std::vector<double> bins;
490 double first_mz = ceil((min_mz * std::pow(10,
m_decimalPlaces)) - 0.49) /
502 std::vector<pappso::pappso_double> bins;
515 bins.push_back(previous_mz_bin);
524 while(previous_mz_bin <= last_mz)
541 double current_rounded_mz =
555 if(current_rounded_mz == previous_mz_bin)
564 <<
"Had to increment decimal places by one while creating the bins "
565 "in BinningType::ARBITRARY mode..";
568 bins.push_back(current_rounded_mz);
571 previous_mz_bin = current_rounded_mz;
577 QString fileName =
"/tmp/massSpecArbitraryBins.txt-at-" +
578 QDateTime::currentDateTime().toString(
"yyyyMMdd-HH-mm-ss");
580 qDebug() <<
"Writing the list of bins setup in the "
581 "mass spectrum in file "
584 QFile file(fileName);
585 file.open(QIODevice::WriteOnly);
587 QTextStream fileStream(&file);
589 for(
auto &&bin : bins)
590 fileStream << QString(
"%1\n").arg(bin, 0,
'f', 10);
616 std::vector<pappso::pappso_double> bins;
618 if(mass_spectrum_csp->size() < 2)
625 local_mass_spectrum.
sortMz();
646 std::vector<pappso::DataPoint>::const_iterator it =
647 local_mass_spectrum.begin();
657 while(it != local_mass_spectrum.end())
666 end_mz_out = start_mz_in + step;
677 bins.push_back(start_mz_in);
680 start_mz_in = end_mz_out;
691 QString fileName =
"/tmp/massSpecDataBasedBins.txt";
693 qDebug() <<
"Writing the list of bins setup in the "
694 "mass spectrum in file "
697 QFile file(fileName);
698 file.open(QIODevice::WriteOnly);
700 QTextStream fileStream(&file);
702 for(
auto &&bin : m_bins)
703 fileStream << QString(
"[%1-%2]\n")
704 .arg(bin.startMzIn, 0,
'f', 10)
705 .arg(bin.endMzOut, 0,
'f', 10);
710 qDebug() <<
"elements."
711 <<
"starting with mz" << m_bins.front().startMzIn <<
"ending with mz"
712 << m_bins.back().endMzOut;
725 for(
int iter = 0; iter < offset; ++iter)
729 text +=
"m/z integration parameters:\n";
735 QString::asprintf(
"Smallest (first) m/z: %.6f\n",
m_smallestMz));
740 text.append(QString::asprintf(
"Greatest (last) m/z: %.6f\n",
m_greatestMz));
746 std::map<BinningType, QString>::iterator it;
750 qFatal(
"Programming error.");
754 text.append(QString(
"Binning type: %1\n").arg(it->second.toLatin1().data()));
763 text.append(QString(
"Bin nominal size: %1\n")
769 text.append(QString(
"Bin size: %2\n")
778 QString(
"Apply m/z shift: %1\n").arg(
m_applyMzShift ?
"true" :
"false");
785 text += QString(
"m/z shift: %1").arg(
m_mzShift, 0,
'f', 6);
790 text += QString(
"Remove 0-val data points: %1\n")
799 text.append(
"Savitzky-Golay parameters\n");
804 QString(
"nL = %1 ; nR = %2 ; m = %3 ; lD = %4 ; convolveWithNr = %5\n")