libpappsomspp
Library for mass spectrometry
pappso::MzIntegrationParams Class Reference

The MzIntegrationParams class provides the parameters definining how m/z ! More...

#include <mzintegrationparams.h>

Public Types

enum class  InitializationResult { DEFAULT = 0 , FROM_SETTINGS_BIN_SIZE_MODEL_PARTIAL = 1 , FROM_SETTINGS_BIN_SIZE_MODEL_FULL = 2 , FROM_SETTINGS_FULL = 3 }
 

Public Member Functions

Q_INVOKABLE MzIntegrationParams ()
 
Q_INVOKABLE MzIntegrationParams (const QString &text)
 
Q_INVOKABLE MzIntegrationParams (pappso::pappso_double minMz, pappso::pappso_double maxMz, BinningType binningType, int decimalPlaces, pappso::PrecisionPtr precisionPtr, int binSizeDivisor, bool removeZeroValDataPoints)
 
Q_INVOKABLE MzIntegrationParams (const MzIntegrationParams &other)
 
virtual ~MzIntegrationParams ()
 
InitializationResult initialize (const QString &text)
 
MzIntegrationParamsoperator= (const MzIntegrationParams &other)
 
Q_INVOKABLE void setSmallestMz (pappso::pappso_double value)
 
Q_INVOKABLE void updateSmallestMz (pappso::pappso_double value)
 
pappso::pappso_double getSmallestMz () const
 
Q_INVOKABLE void setGreatestMz (pappso::pappso_double value)
 
Q_INVOKABLE void updateGreatestMz (pappso::pappso_double value)
 
Q_INVOKABLE pappso::pappso_double getGreatestMz () const
 
Q_INVOKABLE void setBinningType (BinningType binningType)
 
Q_INVOKABLE BinningType getBinningType () const
 
Q_INVOKABLE void setDecimalPlaces (int decimal_places)
 
Q_INVOKABLE int getDecimalPlaces () const
 
Q_INVOKABLE void setBinSizeModel (pappso::PrecisionPtr bin_size_model)
 
Q_INVOKABLE pappso::PrecisionPtr getBinSizeModel () const
 
void setBinSizeDivisor (int divisor)
 
int getBinSizeDivisor () const
 
Q_INVOKABLE void setRemoveZeroValDataPoints (bool removeOrNot=true)
 
Q_INVOKABLE bool isRemoveZeroValDataPoints () const
 
Q_INVOKABLE void reset ()
 Reset the instance to default values. More...
 
Q_INVOKABLE bool isValid () const
 
Q_INVOKABLE bool hasValidMzRange () const
 
Q_INVOKABLE std::vector< pappso::pappso_doublecreateBins ()
 
Q_INVOKABLE std::vector< pappso::pappso_doublecreateBins (pappso::MassSpectrumCstSPtr mass_spectrum_csp)
 
Q_INVOKABLE QString toString (int offset, const QString &spacer=" ") const
 
Q_INVOKABLE QString toString () const
 

Private Member Functions

std::vector< double > createArbitraryBins ()
 
std::vector< double > createDataBasedBins (pappso::MassSpectrumCstSPtr massSpectrum)
 

Private Attributes

pappso::pappso_double m_smallestMz = std::numeric_limits<double>::max()
 
pappso::pappso_double m_greatestMz = std::numeric_limits<double>::min()
 
BinningType m_binningType = BinningType::ARBITRARY
 
int m_decimalPlaces = -1
 
pappso::PrecisionPtr mp_binSizeModel
 
int m_binSizeDivisor = 1
 
bool m_removeZeroValDataPoints = true
 

Detailed Description

The MzIntegrationParams class provides the parameters definining how m/z !

Depending on the various mass spectrometer vendors, the mass spectrometry data files are structured in different ways and the software for mass data format conversion from raw files to mzML or mzXML produce mass data characterized by different behaviours.

The different characteristics of mass spectrometry data set are:

The size of the various mass spectra in the file is constant or variable;

The first m/z value of the various spectra is identical or not (that is, the spectra are root in a constant or variable root m/z value);

The m/z delta between two consecutive m/z values of a given spectrum are constant or variable;

The spectra contain or not 0-value m/z data points;

Definition at line 86 of file mzintegrationparams.h.

Member Enumeration Documentation

◆ InitializationResult

Enumerator
DEFAULT 
FROM_SETTINGS_BIN_SIZE_MODEL_PARTIAL 
FROM_SETTINGS_BIN_SIZE_MODEL_FULL 
FROM_SETTINGS_FULL 

Definition at line 90 of file mzintegrationparams.h.

91 {
92 // The order is important.
93 DEFAULT = 0,
94 FROM_SETTINGS_BIN_SIZE_MODEL_PARTIAL = 1,
95 FROM_SETTINGS_BIN_SIZE_MODEL_FULL = 2,
96 FROM_SETTINGS_FULL = 3
97 };

Constructor & Destructor Documentation

◆ MzIntegrationParams() [1/4]

pappso::MzIntegrationParams::MzIntegrationParams ( )

Definition at line 86 of file mzintegrationparams.cpp.

87{
90}
pappso::PrecisionPtr mp_binSizeModel
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition: precision.cpp:180
@ NONE
< no binning

References pappso::PrecisionFactory::getResInstance(), m_binningType, mp_binSizeModel, and pappso::NONE.

◆ MzIntegrationParams() [2/4]

pappso::MzIntegrationParams::MzIntegrationParams ( const QString &  text)

Definition at line 93 of file mzintegrationparams.cpp.

94{
95 initialize(text);
96}
InitializationResult initialize(const QString &text)

References initialize().

◆ MzIntegrationParams() [3/4]

pappso::MzIntegrationParams::MzIntegrationParams ( pappso::pappso_double  minMz,
pappso::pappso_double  maxMz,
BinningType  binningType,
int  decimalPlaces,
pappso::PrecisionPtr  precisionPtr,
int  binSizeDivisor,
bool  removeZeroValDataPoints 
)

Definition at line 98 of file mzintegrationparams.cpp.

105 : m_smallestMz(minMz),
106 m_greatestMz(maxMz),
107 m_binningType(binningType),
108 m_decimalPlaces(decimalPlaces),
109 mp_binSizeModel(precisionPtr),
110 m_binSizeDivisor(binSizeDivisor),
111 m_removeZeroValDataPoints(removeZeroValDataPoints)
112{
113 if(mp_binSizeModel == nullptr)
115
116 // qDebug() << "mp_precision:" << mp_precision->toString();
117}
pappso::pappso_double m_smallestMz
pappso::pappso_double m_greatestMz
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Definition: precision.cpp:154

References pappso::PrecisionFactory::getPpmInstance(), and mp_binSizeModel.

◆ MzIntegrationParams() [4/4]

pappso::MzIntegrationParams::MzIntegrationParams ( const MzIntegrationParams other)

Definition at line 120 of file mzintegrationparams.cpp.

121 : m_smallestMz(other.m_smallestMz),
122 m_greatestMz(other.m_greatestMz),
123 m_binningType(other.m_binningType),
124 m_decimalPlaces(other.m_decimalPlaces),
125 mp_binSizeModel(other.mp_binSizeModel),
126 m_binSizeDivisor(other.m_binSizeDivisor),
127 m_removeZeroValDataPoints(other.m_removeZeroValDataPoints)
128{
129 if(mp_binSizeModel == nullptr)
131
132 // qDebug() << "mp_precision:" << mp_precision->toString();
133}

References pappso::PrecisionFactory::getResInstance(), and mp_binSizeModel.

◆ ~MzIntegrationParams()

pappso::MzIntegrationParams::~MzIntegrationParams ( )
virtual

Definition at line 136 of file mzintegrationparams.cpp.

137{
138}

Member Function Documentation

◆ createArbitraryBins()

std::vector< double > pappso::MzIntegrationParams::createArbitraryBins ( )
private

Definition at line 493 of file mzintegrationparams.cpp.

494{
495 // Now starts the tricky stuff. Depending on how the binning has been
496 // configured, we need to take diverse actions.
497
498 // qDebug() << "Bin size specification:" << mp_precision->toString();
499
502
503 // qDebug() << "m_smallestMz:" << m_smallestMz
504 //<< "m_greatestMz:" << m_greatestMz;
505
506 // qDebug() << QString::asprintf("min_mz: %.6f\n", min_mz)
507 //<< QString::asprintf("max_mz: %.6f\n", max_mz);
508
509 pappso::pappso_double binSize;
510
512 {
513 double resolution_based_bin_size = mp_binSizeModel->delta(min_mz);
514 binSize = resolution_based_bin_size / m_binSizeDivisor;
515
516 // qDebug() << "With res-based bin size, the uncorrected bin size:"
517 //<< resolution_based_bin_size
518 //<< "and the final binSize:" << binSize;
519 }
520 else
521 binSize = mp_binSizeModel->delta(min_mz);
522
523 // qDebug() << QString::asprintf(
524 //"binSize is the precision delta for min_mz: %.6f\n", binSize);
525
526 // Only compute the decimal places if they were not configured already.
527 if(m_decimalPlaces == -1)
528 {
529 // qDebug() << "Now checking how many decimal places are needed.";
530
531 // We want as many decimal places as there are 0s between the integral
532 // part of the double and the first non-0 cipher. For example, if
533 // binSize is 0.004, zero decimals is 2 and m_decimalPlaces is set to 3,
534 // because we want decimals up to 4 included.
535
537
538 // qDebug() << "With binSize" << binSize
539 //<< " m_decimalPlaces was computed to be:" << m_decimalPlaces;
540 }
541 // else
542 // qDebug() << "m_decimalPlaces: " << m_decimalPlaces;
543
544 // Now that we have defined the value of m_decimalPlaces, let's use that
545 // value.
546
547 double first_mz =
548 ceil((min_mz * std::pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
549 double last_mz = ceil((max_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
550
551 // qDebug() << "After having accounted for the decimals, new min/max values:"
552 //<< QString::asprintf("Very first data point: %.6f\n", first_mz)
553 //<< QString::asprintf("Very last data point to reach: %.6f\n",
554 // last_mz);
555
556 // Instanciate the vector of mz double_s that we'll feed with the bins.
557
558 std::vector<pappso::pappso_double> bins;
559
560 // Store that very first value for later use in the loop.
561 // The bins are notking more than:
562 //
563 // 1. The first mz (that is the smallest mz value found in all the spectra
564 // 2. A sequence of mz values corresponding to that first mz value
565 // incremented by the bin size.
566
567 // Seed the root of the bin vector with the first mz value rounded above as
568 // requested.
569 pappso::pappso_double previous_mz_bin = first_mz;
570
571 bins.push_back(previous_mz_bin);
572
573 // Now continue adding mz values until we have reached the end of the
574 // spectrum, that is the max_mz value, as converted using the decimals to
575 // last_mz.
576
577 // debugCount value used below for debugging purposes.
578 // int debugCount = 0;
579
580 while(previous_mz_bin <= last_mz)
581 {
582
583 // qDebug() << "Now starting the bin creation loop.";
584
585 // Calculate dynamically the precision delta according to the current mz
586 // value.
587
588 // double precision_delta = mp_precision->delta(previous_mz_bin);
589 // qDebug() << "precision_delta: " << precision_delta;
590
591 // In certain circumstances, the bin size is not enough to properly render
592 // hyper-high resolution data (like the theoretical isotopic cluster data
593 // generated in silico). In that case, the bin size, computed using the
594 // precision object, is divided by the m_binSizeDivisor, which normally is
595 // set to 1 as the default, that is, it has no effect.
596
597 double current_mz;
598
600 current_mz = previous_mz_bin + (mp_binSizeModel->delta(previous_mz_bin) / m_binSizeDivisor);
601 else
602 current_mz = previous_mz_bin + mp_binSizeModel->delta(previous_mz_bin);
603
604 // qDebug() << QString::asprintf(
605 //"previous_mzBin: %.6f and current_mz: %.6f\n",
606 // previous_mz_bin,
607 // current_mz);
608
609 // Now apply on the obtained mz value the decimals that were either set
610 // or computed earlier.
611
612 double current_rounded_mz =
613 ceil((current_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
614
615 // qDebug() << QString::asprintf(
616 //"current_mz: %.6f and current_rounded_mz: %.6f and previous_mzBin "
617 //": % .6f\n ",
618 // current_mz,
619 // current_rounded_mz,
620 // previous_mz_bin);
621
622 // If rounding makes the new value identical to the previous one, then
623 // that means that we need to decrease roughness.
624
625 if(current_rounded_mz == previous_mz_bin)
626 {
628
629 current_rounded_mz =
630 ceil((current_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
631
632 // qDebug().noquote()
633 //<< "Had to increment decimal places by one while creating the bins "
634 //"in BinningType::ARBITRARY mode..";
635 }
636
637 bins.push_back(current_rounded_mz);
638
639 // Use the local_mz value for the storage of the previous mz bin.
640 previous_mz_bin = current_rounded_mz;
641 }
642
643
644#if 0
645
646 QString fileName = "/tmp/massSpecArbitraryBins.txt-at-" +
647 QDateTime::currentDateTime().toString("yyyyMMdd-HH-mm-ss");
648
649 qDebug() << "Writing the list of bins setup in the "
650 "mass spectrum in file "
651 << fileName;
652
653 QFile file(fileName);
654 file.open(QIODevice::WriteOnly);
655
656 QTextStream fileStream(&file);
657
658 for(auto &&bin : bins)
659 fileStream << QString("%1\n").arg(bin, 0, 'f', 10);
660
661 fileStream.flush();
662 file.close();
663
664#endif
665
666 // qDebug() << "Prepared bins with " << bins.size() << "elements."
667 //<< "starting with mz" << bins.front() << "ending with mz"
668 //<< bins.back();
669
670 return bins;
671}
virtual pappso_double delta(pappso_double value) const =0
virtual PrecisionUnit unit() const =0
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
Definition: utils.cpp:102
double pappso_double
A type definition for doubles.
Definition: types.h:52

References pappso::PrecisionBase::delta(), m_binSizeDivisor, m_decimalPlaces, m_greatestMz, m_smallestMz, mp_binSizeModel, pappso::res, pappso::PrecisionBase::unit(), and pappso::Utils::zeroDecimalsInValue().

Referenced by createBins().

◆ createBins() [1/2]

std::vector< double > pappso::MzIntegrationParams::createBins ( )

Definition at line 433 of file mzintegrationparams.cpp.

434{
435
436 // qDebug() << "mp_precision:" << mp_precision->toString();
437
438 std::vector<double> bins;
439
441 {
442 // If no binning is to be performed, fine.
443 return bins;
444 }
446 {
447 // Use only data in the MzIntegrationParams member data.
448 return createArbitraryBins();
449 }
451 {
452 // qDebug();
453
454 qFatal("Programming error.");
455 }
456
457 return bins;
458}
std::vector< double > createArbitraryBins()
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value

References pappso::ARBITRARY, createArbitraryBins(), pappso::DATA_BASED, m_binningType, and pappso::NONE.

◆ createBins() [2/2]

std::vector< double > pappso::MzIntegrationParams::createBins ( pappso::MassSpectrumCstSPtr  mass_spectrum_csp)

Definition at line 462 of file mzintegrationparams.cpp.

463{
464
465 // qDebug();
466
467 std::vector<double> bins;
468
470 {
471 // If no binning is to be performed, fine.
472 return bins;
473 }
475 {
476 // Use only data in the MzIntegrationParams member data.
477 return createArbitraryBins();
478 }
480 {
481 // qDebug();
482
483 // Use the first spectrum to perform the data-based bins
484
485 return createDataBasedBins(mass_spectrum_csp);
486 }
487
488 return bins;
489}
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)

References pappso::ARBITRARY, createArbitraryBins(), createDataBasedBins(), pappso::DATA_BASED, m_binningType, and pappso::NONE.

◆ createDataBasedBins()

std::vector< double > pappso::MzIntegrationParams::createDataBasedBins ( pappso::MassSpectrumCstSPtr  massSpectrum)
private

Definition at line 675 of file mzintegrationparams.cpp.

676{
677 // qDebug();
678
679 // The bins in *this mass spectrum must be calculated starting from the
680 // data in the mass_spectrum_csp parameter.
681
682 // Instanciate the vector of mz double_s that we'll feed with the bins.
683
684 std::vector<pappso::pappso_double> bins;
685
686 if(mass_spectrum_csp->size() < 2)
687 return bins;
688
689 // Make sure the spectrum is sorted, as this functions takes for granted
690 // that the DataPoint instances are sorted in ascending x (== mz) value
691 // order.
692 pappso::MassSpectrum local_mass_spectrum = *mass_spectrum_csp;
693 local_mass_spectrum.sortMz();
694
696
697 // qDebug() << "The min_mz:" << min_mz;
698
699 if(m_decimalPlaces != -1)
700 min_mz = ceil((min_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
701
702
703 // Two values for the definition of a MassSpectrumBin.
704
705 // The first value of the mz range that defines the bin. This value is part
706 // of the bin.
707 pappso::pappso_double start_mz_in = min_mz;
708
709 // The second value of the mz range that defines the bin. This value is
710 // *not* part of the bin.
711 pappso::pappso_double end_mz_out;
712
713 std::vector<pappso::DataPoint>::const_iterator it = local_mass_spectrum.begin();
714
715 pappso::pappso_double prev_mz = it->x;
716
717 if(m_decimalPlaces != -1)
718 prev_mz = ceil((prev_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
719
720 ++it;
721
722 while(it != local_mass_spectrum.end())
723 {
724 pappso::pappso_double next_mz = it->x;
725
726 if(m_decimalPlaces != -1)
727 next_mz = ceil((next_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
728
729 pappso::pappso_double step = next_mz - prev_mz;
730 end_mz_out = start_mz_in + step;
731
732 if(m_decimalPlaces != -1)
733 end_mz_out =
734 ceil((end_mz_out * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
735
736 // The data point that is crafted has a 0 y-value. The binning must
737 // indeed not create artificial intensity data.
738
739 // qDebug() << "Pushing back bin:" << start_mz_in << end_mz_out;
740
741 bins.push_back(start_mz_in);
742
743 // Prepare next bin
744 start_mz_in = end_mz_out;
745
746 // Update prev_mz to be the current one for next iteration.
747 prev_mz = next_mz;
748
749 // Now got the next DataPoint instance.
750 ++it;
751 }
752
753#if 0
754
755 QString fileName = "/tmp/massSpecDataBasedBins.txt";
756
757 qDebug() << "Writing the list of bins setup in the "
758 "mass spectrum in file "
759 << fileName;
760
761 QFile file(fileName);
762 file.open(QIODevice::WriteOnly);
763
764 QTextStream fileStream(&file);
765
766 for(auto &&bin : m_bins)
767 fileStream << QString("[%1-%2]\n")
768 .arg(bin.startMzIn, 0, 'f', 10)
769 .arg(bin.endMzOut, 0, 'f', 10);
770
771 fileStream.flush();
772 file.close();
773
774 qDebug() << "elements."
775 << "starting with mz" << m_bins.front().startMzIn << "ending with mz"
776 << m_bins.back().endMzOut;
777
778#endif
779
780 return bins;
781}
Class to represent a mass spectrum.
Definition: massspectrum.h:73
void sortMz()
Sort the DataPoint instances of this spectrum.

References m_decimalPlaces, m_smallestMz, and pappso::MassSpectrum::sortMz().

Referenced by createBins().

◆ getBinningType()

BinningType pappso::MzIntegrationParams::getBinningType ( ) const

Definition at line 309 of file mzintegrationparams.cpp.

310{
311 return m_binningType;
312}

References m_binningType.

◆ getBinSizeDivisor()

int pappso::MzIntegrationParams::getBinSizeDivisor ( ) const

Definition at line 352 of file mzintegrationparams.cpp.

353{
354 return m_binSizeDivisor;
355}

References m_binSizeDivisor.

◆ getBinSizeModel()

pappso::PrecisionPtr pappso::MzIntegrationParams::getBinSizeModel ( ) const

Definition at line 338 of file mzintegrationparams.cpp.

339{
340 return mp_binSizeModel;
341}

References mp_binSizeModel.

◆ getDecimalPlaces()

int pappso::MzIntegrationParams::getDecimalPlaces ( ) const

Definition at line 323 of file mzintegrationparams.cpp.

324{
325 return m_decimalPlaces;
326}

References m_decimalPlaces.

◆ getGreatestMz()

pappso::pappso_double pappso::MzIntegrationParams::getGreatestMz ( ) const

Definition at line 295 of file mzintegrationparams.cpp.

296{
297 return m_greatestMz;
298}

References m_greatestMz.

◆ getSmallestMz()

pappso::pappso_double pappso::MzIntegrationParams::getSmallestMz ( ) const

Definition at line 274 of file mzintegrationparams.cpp.

275{
276 return m_smallestMz;
277}

References m_smallestMz.

◆ hasValidMzRange()

bool pappso::MzIntegrationParams::hasValidMzRange ( ) const

Definition at line 425 of file mzintegrationparams.cpp.

426{
427 return (m_smallestMz != std::numeric_limits<double>::max()) &&
428 (m_greatestMz != std::numeric_limits<double>::min());
429}

References m_greatestMz, and m_smallestMz.

◆ initialize()

MzIntegrationParams::InitializationResult pappso::MzIntegrationParams::initialize ( const QString &  text)

Definition at line 141 of file mzintegrationparams.cpp.

142{
143 // Set the config to default values. We'll then change these on the
144 // basis of parsing the text.
147 m_decimalPlaces = -1;
150
151 if(text.isEmpty())
153
154 // qDebug() << "Getting text for initialization:" << text;
155
156 // Expected text: "Smallest (first) m/z:294.725158\nGreatest (last) m/z:2055.002453\nDecimal
157 // places:-1\nBinning type:2\nBin size model:0.05 dalton\nBin size divisor:1\nRemove 0-val data
158 // points:1\n"
159
160 // In order to consider that the parameters were correctly read, we need
161 // some of the members to effectively be set from the settings values.
162
163 bool smallest_mz_set = false;
164 bool greatest_mz_set = false;
165 bool binning_type_set = false;
166 bool decimal_places_set = false;
167 bool bin_size_model_set = false;
168 bool bin_size_divisor_set = false;
169 bool remove_zero_data_points_set = false;
170
171 QStringList string_list = text.split("\n");
172
173 for(int iter = 0; iter < string_list.size(); ++iter)
174 {
175 QString iter_string = string_list.at(iter);
176
177 qDebug() << "Iterating in string:" << iter_string;
178
179 if(iter_string.contains("Smallest (first) m/z:"))
180 {
181 smallest_mz_set = true;
182 m_smallestMz = iter_string.split(':').last().toDouble();
183 }
184 else if(iter_string.contains("Greatest (last) m/z:"))
185 {
186 greatest_mz_set = true;
187 m_greatestMz = iter_string.split(':').last().toDouble();
188 }
189 else if(iter_string.contains("Decimal places:"))
190 {
191 decimal_places_set = true;
192 m_decimalPlaces = iter_string.split(':').last().toInt();
193 }
194 else if(iter_string.contains("Binning type:"))
195 {
196 m_binningType = getBinningTypeFromString(iter_string.split(':').last());
197 binning_type_set = true;
198 }
199 else if(iter_string.contains("Bin size model:"))
200 {
201 mp_binSizeModel = PrecisionFactory::fromString(iter_string.split(':').last());
202 bin_size_model_set = true;
203 }
204 else if(iter_string.contains("Bin size divisor:"))
205 {
206 bin_size_divisor_set = true;
207 m_binSizeDivisor = iter_string.split(':').last().toInt();
208 }
209 else if(iter_string.contains("Remove 0-val data points:"))
210 {
211 remove_zero_data_points_set = true;
212 m_removeZeroValDataPoints = iter_string.split(':').last().toInt();
213 }
214 }
215
216 // qDebug() << "At this point the initialization is done and this"
217 // " MzIntegrationParams instance is: "
218 // << toString();
219
220 if(smallest_mz_set && greatest_mz_set && decimal_places_set && binning_type_set &&
221 bin_size_model_set && bin_size_divisor_set && remove_zero_data_points_set)
223
224 if(decimal_places_set && binning_type_set &&
225 bin_size_model_set && bin_size_divisor_set && remove_zero_data_points_set)
227
228 if(binning_type_set &&
229 bin_size_model_set)
231
233}
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition: precision.cpp:79
BinningType getBinningTypeFromString(const QString &text)

References pappso::ARBITRARY, DEFAULT, FROM_SETTINGS_BIN_SIZE_MODEL_FULL, FROM_SETTINGS_BIN_SIZE_MODEL_PARTIAL, FROM_SETTINGS_FULL, pappso::PrecisionFactory::fromString(), pappso::getBinningTypeFromString(), pappso::PrecisionFactory::getResInstance(), m_binningType, m_binSizeDivisor, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, and mp_binSizeModel.

Referenced by MzIntegrationParams().

◆ isRemoveZeroValDataPoints()

bool pappso::MzIntegrationParams::isRemoveZeroValDataPoints ( ) const

Definition at line 366 of file mzintegrationparams.cpp.

367{
369}

References m_removeZeroValDataPoints.

◆ isValid()

bool pappso::MzIntegrationParams::isValid ( ) const

Definition at line 389 of file mzintegrationparams.cpp.

390{
391 int errors = 0;
392
394 errors += 1;
395
397 {
398 // qDebug() << "m_smallestMz:" << m_smallestMz;
399 // qDebug() << "smallest is max:" << (m_smallestMz ==
400 // std::numeric_limits<double>::max());
401
402 errors += (m_smallestMz == std::numeric_limits<double>::max() ? 1 : 0);
403
404 // qDebug() << "m_greatestMz:" << m_greatestMz;
405 // qDebug() << "greatest is min:" << (m_greatestMz ==
406 // std::numeric_limits<double>::min());
407 errors += (m_greatestMz == std::numeric_limits<double>::min() ? 1 : 0);
408
409 // if(mp_precision != nullptr)
410 // qDebug() << mp_precision->toString();
411
412 errors += (mp_binSizeModel == nullptr ? 1 : 0);
413 }
414
415 if(errors)
416 {
417 qDebug() << "The m/z integration parameters are not valid or do not apply...";
418 }
419
420 return !errors;
421}

References m_binningType, m_binSizeDivisor, m_greatestMz, m_smallestMz, mp_binSizeModel, and pappso::NONE.

◆ operator=()

MzIntegrationParams & pappso::MzIntegrationParams::operator= ( const MzIntegrationParams other)

Definition at line 236 of file mzintegrationparams.cpp.

237{
238 if(this == &other)
239 return *this;
240
241 m_smallestMz = other.m_smallestMz;
242 m_greatestMz = other.m_greatestMz;
243 m_binningType = other.m_binningType;
244
245 m_decimalPlaces = other.m_decimalPlaces;
246
247 mp_binSizeModel = other.mp_binSizeModel;
248 if(mp_binSizeModel == nullptr)
250
251 m_binSizeDivisor = other.m_binSizeDivisor;
252
253 m_removeZeroValDataPoints = other.m_removeZeroValDataPoints;
254
255 return *this;
256}

References pappso::PrecisionFactory::getPpmInstance(), m_binningType, m_binSizeDivisor, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, and mp_binSizeModel.

◆ reset()

void pappso::MzIntegrationParams::reset ( )

Reset the instance to default values.

Definition at line 374 of file mzintegrationparams.cpp.

375{
376 m_smallestMz = std::numeric_limits<double>::min();
377 m_greatestMz = std::numeric_limits<double>::min();
379
380 // Special case for this member datum
382
385}

References pappso::PrecisionFactory::getPpmInstance(), m_binningType, m_binSizeDivisor, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, mp_binSizeModel, and pappso::NONE.

◆ setBinningType()

void pappso::MzIntegrationParams::setBinningType ( BinningType  binningType)

Definition at line 302 of file mzintegrationparams.cpp.

303{
304 m_binningType = binningType;
305}

References m_binningType.

◆ setBinSizeDivisor()

void pappso::MzIntegrationParams::setBinSizeDivisor ( int  divisor)

Definition at line 345 of file mzintegrationparams.cpp.

346{
347 m_binSizeDivisor = divisor;
348}

References m_binSizeDivisor.

◆ setBinSizeModel()

void pappso::MzIntegrationParams::setBinSizeModel ( pappso::PrecisionPtr  bin_size_model)

Definition at line 329 of file mzintegrationparams.cpp.

330{
331 mp_binSizeModel = precisionPtr;
332
333 if(mp_binSizeModel == nullptr)
335}
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
Definition: precision.cpp:135

References pappso::PrecisionFactory::getDaltonInstance(), and mp_binSizeModel.

◆ setDecimalPlaces()

void pappso::MzIntegrationParams::setDecimalPlaces ( int  decimal_places)

Definition at line 316 of file mzintegrationparams.cpp.

317{
318 m_decimalPlaces = decimal_places;
319}

References m_decimalPlaces.

◆ setGreatestMz()

void pappso::MzIntegrationParams::setGreatestMz ( pappso::pappso_double  value)

Definition at line 281 of file mzintegrationparams.cpp.

282{
283 m_greatestMz = value;
284}

References m_greatestMz.

◆ setRemoveZeroValDataPoints()

void pappso::MzIntegrationParams::setRemoveZeroValDataPoints ( bool  removeOrNot = true)

Definition at line 359 of file mzintegrationparams.cpp.

360{
361 m_removeZeroValDataPoints = removeOrNot;
362}

References m_removeZeroValDataPoints.

◆ setSmallestMz()

void pappso::MzIntegrationParams::setSmallestMz ( pappso::pappso_double  value)

Definition at line 260 of file mzintegrationparams.cpp.

261{
262 m_smallestMz = value;
263}

References m_smallestMz.

◆ toString() [1/2]

QString pappso::MzIntegrationParams::toString ( ) const

Definition at line 850 of file mzintegrationparams.cpp.

851{
852 QString text;
853
854 if(m_smallestMz != std::numeric_limits<double>::max())
855 text.append(QString::asprintf("Smallest (first) m/z:%.6f\n", m_smallestMz));
856 if(m_greatestMz != std::numeric_limits<double>::min())
857 text.append(QString::asprintf("Greatest (last) m/z:%.6f\n", m_greatestMz));
858 text.append(QString("Decimal places:%1\n").arg(m_decimalPlaces));
859 text.append(QString("Binning type:%1\n").arg(binningTypeMap[m_binningType]));
860
861 // Only provide the details relative to the ARBITRARY binning type.
863 {
864 text.append(QString("Bin size model:%1\n").arg(mp_binSizeModel->toString()));
865 text.append(QString("Bin size divisor:%2\n").arg(m_binSizeDivisor));
866 }
867
868 // Now other data that are independent of the bin settings.
869 text += QString("Remove 0-val data points:%1\n").arg(m_removeZeroValDataPoints);
870
871 return text;
872}
virtual QString toString() const =0
std::map< BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.

References pappso::ARBITRARY, pappso::binningTypeMap, m_binningType, m_binSizeDivisor, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, mp_binSizeModel, and pappso::PrecisionBase::toString().

◆ toString() [2/2]

QString pappso::MzIntegrationParams::toString ( int  offset,
const QString &  spacer = " " 
) const

Definition at line 785 of file mzintegrationparams.cpp.

786{
787 QString lead;
788
789 for(int iter = 0; iter < offset; ++iter)
790 lead += spacer;
791
792 QString text = lead;
793 text += "m/z integration parameters:\n";
794
795 text += lead;
796 text += spacer;
797 if(m_smallestMz != std::numeric_limits<double>::max())
798 text.append(QString::asprintf("Smallest (first) m/z: %.6f\n", m_smallestMz));
799
800 text += lead;
801 text += spacer;
802 if(m_greatestMz != std::numeric_limits<double>::min())
803 text.append(QString::asprintf("Greatest (last) m/z: %.6f\n", m_greatestMz));
804
805 text += lead;
806 text += spacer;
807 text.append(QString("Decimal places: %1\n").arg(m_decimalPlaces));
808
809 std::map<BinningType, QString>::iterator it;
810 it = binningTypeMap.find(m_binningType);
811
812 if(it == binningTypeMap.end())
813 qFatal("Programming error.");
814
815 text += lead;
816 text += spacer;
817 text.append(QString("Binning type: %1\n").arg(it->second.toLatin1().data()));
818
819 // Only provide the details relative to the ARBITRARY binning type.
820
822 {
823 text += lead;
824 text += spacer;
825 text += spacer;
826 text.append(QString("Bin nominal size: %1\n").arg(mp_binSizeModel->getNominal(), 0, 'f', 6));
827
828 text += lead;
829 text += spacer;
830 text += spacer;
831 text.append(QString("Bin size: %2\n").arg(mp_binSizeModel->toString().toLatin1().data()));
832
833 text += lead;
834 text += spacer;
835 text += spacer;
836 text.append(QString("Bin size divisor: %2\n").arg(m_binSizeDivisor));
837 }
838
839 // Now other data that are independent of the bin settings.
840
841 text += lead;
842 text += spacer;
843 text +=
844 QString("Remove 0-val data points: %1\n").arg(m_removeZeroValDataPoints ? "true" : "false");
845
846 return text;
847}
virtual pappso_double getNominal() const final
Definition: precision.cpp:72

References pappso::ARBITRARY, pappso::binningTypeMap, pappso::PrecisionBase::getNominal(), m_binningType, m_binSizeDivisor, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, mp_binSizeModel, and pappso::PrecisionBase::toString().

◆ updateGreatestMz()

void pappso::MzIntegrationParams::updateGreatestMz ( pappso::pappso_double  value)

Definition at line 288 of file mzintegrationparams.cpp.

289{
290 m_greatestMz = m_greatestMz < value ? value : m_greatestMz;
291}

References m_greatestMz.

◆ updateSmallestMz()

void pappso::MzIntegrationParams::updateSmallestMz ( pappso::pappso_double  value)

Definition at line 267 of file mzintegrationparams.cpp.

268{
269 m_smallestMz = m_smallestMz > value ? value : m_smallestMz;
270}

References m_smallestMz.

Member Data Documentation

◆ m_binningType

BinningType pappso::MzIntegrationParams::m_binningType = BinningType::ARBITRARY
private

◆ m_binSizeDivisor

int pappso::MzIntegrationParams::m_binSizeDivisor = 1
private

◆ m_decimalPlaces

int pappso::MzIntegrationParams::m_decimalPlaces = -1
private

◆ m_greatestMz

pappso::pappso_double pappso::MzIntegrationParams::m_greatestMz = std::numeric_limits<double>::min()
private

◆ m_removeZeroValDataPoints

bool pappso::MzIntegrationParams::m_removeZeroValDataPoints = true
private

◆ m_smallestMz

pappso::pappso_double pappso::MzIntegrationParams::m_smallestMz = std::numeric_limits<double>::max()
private

◆ mp_binSizeModel

pappso::PrecisionPtr pappso::MzIntegrationParams::mp_binSizeModel
private

The documentation for this class was generated from the following files: