libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::MzIntegrationParams Class Reference

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

#include <mzintegrationparams.h>

Inheritance diagram for pappso::MzIntegrationParams:

Public Types

enum class  BinningType { NONE = 0 , DATA_BASED , ARBITRARY , LAST }
 
enum class  InitializationResult : uint32_t {
  DEFAULT = 0x000 , BINNING_TYPE = 1 << 0 , BIN_SIZE_MODEL = 1 << 1 , BIN_SIZE_DIVISOR = 1 << 2 ,
  DECIMAL_PLACES = 1 << 3 , BINNING_LOGIC_PARTIAL = (BINNING_TYPE | BIN_SIZE_MODEL) , BINNING_LOGIC_FULL = (BINNING_LOGIC_PARTIAL | BIN_SIZE_DIVISOR | DECIMAL_PLACES) , REMOVE_ZERO_DATA_POINTS = 1 << 4 ,
  FULL = (REMOVE_ZERO_DATA_POINTS | BINNING_LOGIC_FULL)
}
 

Signals

void smallestMzChanged ()
 
void greatestMzChanged ()
 
void binningTypeChanged ()
 
void decimalPlacesChanged ()
 
void binSizeModelChanged ()
 
void binSizeDivisorChanged ()
 
void removeZeroValDataPointsChanged ()
 
void wasReset ()
 

Public Member Functions

Q_INVOKABLE MzIntegrationParams (QObject *parent=nullptr)
 
Q_INVOKABLE MzIntegrationParams (const QString &text, QObject *parent=nullptr)
 
Q_INVOKABLE MzIntegrationParams (double minMz, double maxMz, BinningType binningType, pappso::PrecisionPtr precisionPtr, int binSizeDivisor, int decimalPlaces, bool removeZeroValDataPoints, QObject *parent=nullptr)
 
virtual ~MzIntegrationParams ()
 
Q_INVOKABLE MzIntegrationParamsclone (QObject *parent=nullptr) const
 
Q_INVOKABLE InitializationResult initialize (const QString &text)
 
Q_INVOKABLE void initialize (double minMz, double maxMz, BinningType binningType, pappso::PrecisionPtr precisionPtr, int binSizeDivisor, int decimalPlaces, bool removeZeroValDataPoints, QObject *parent=nullptr)
 
Q_INVOKABLE void initialize (const MzIntegrationParams &other, QObject *parent=nullptr)
 
void initialize (MzIntegrationParams &other, InitializationResult initialization_results)
 
void setSmallestMz (double value)
 
Q_INVOKABLE void updateSmallestMz (double value)
 
double getSmallestMz () const
 
void setGreatestMz (double value)
 
Q_INVOKABLE void updateGreatestMz (double value)
 
double getGreatestMz () const
 
Q_INVOKABLE void setMzValues (double smallest, double greatest)
 
void setBinningType (BinningType binningType)
 
BinningType getBinningType () const
 
void setBinSizeModel (pappso::PrecisionPtr bin_size_model_p)
 
pappso::PrecisionPtr getBinSizeModel () const
 
void setBinSizeDivisor (int divisor)
 
int getBinSizeDivisor () const
 
void setDecimalPlaces (int decimal_places)
 
int getDecimalPlaces () const
 
void setRemoveZeroValDataPoints (bool removeOrNot=true)
 
bool isRemoveZeroValDataPoints () const
 
Q_INVOKABLE void reset ()
 Reset the instance to default values.
 
Q_INVOKABLE bool isValid () const
 
Q_INVOKABLE bool hasValidMzRange () const
 
Q_INVOKABLE std::vector< double > createBins ()
 
Q_INVOKABLE std::vector< double > createBins (pappso::MassSpectrumCstSPtr mass_spectrum_csp)
 
Q_INVOKABLE QString toString (int offset, const QString &spacer=" ") const
 
Q_INVOKABLE QString toString () const
 

Static Public Member Functions

static void registerJsConstructor (QJSEngine *engine)
 

Protected Member Functions

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

Protected Attributes

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

Properties

double smallestMz
 
double greatestMz
 
BinningType binningType
 
int decimalPlaces
 
pappso::PrecisionPtr binSizeModel
 
int binSizeDivisor
 
bool removeZeroValDataPoints
 

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 85 of file mzintegrationparams.h.

Member Enumeration Documentation

◆ BinningType

Enumerator
NONE 

< no binning

DATA_BASED 

binning based on mass spectral data

ARBITRARY 

binning based on arbitrary bin size value

LAST 

Definition at line 109 of file mzintegrationparams.h.

110 {
111 //! < no binning
112 NONE = 0,
113
114 //! binning based on mass spectral data
115 DATA_BASED,
116
117 //! binning based on arbitrary bin size value
118 ARBITRARY,
119
120 LAST,
121 };

◆ InitializationResult

Enumerator
DEFAULT 
BINNING_TYPE 
BIN_SIZE_MODEL 
BIN_SIZE_DIVISOR 
DECIMAL_PLACES 
BINNING_LOGIC_PARTIAL 
BINNING_LOGIC_FULL 
REMOVE_ZERO_DATA_POINTS 
FULL 

Definition at line 124 of file mzintegrationparams.h.

125 {
126 // The order is important.
127 // See end of class declaration for overload of bitwise operators
128 DEFAULT = 0x000,
129 BINNING_TYPE = 1 << 0,
130 BIN_SIZE_MODEL = 1 << 1,
131 BIN_SIZE_DIVISOR = 1 << 2,
132 DECIMAL_PLACES = 1 << 3,
133 BINNING_LOGIC_PARTIAL = (BINNING_TYPE | BIN_SIZE_MODEL),
134 BINNING_LOGIC_FULL = (BINNING_LOGIC_PARTIAL | BIN_SIZE_DIVISOR | DECIMAL_PLACES),
135 REMOVE_ZERO_DATA_POINTS = 1 << 4,
136 FULL = (REMOVE_ZERO_DATA_POINTS | BINNING_LOGIC_FULL),
137 };

Constructor & Destructor Documentation

◆ MzIntegrationParams() [1/3]

pappso::MzIntegrationParams::MzIntegrationParams ( QObject * parent = nullptr)
explicit

Definition at line 90 of file mzintegrationparams.cpp.

90 : QObject(parent)
91{
92}

Referenced by clone(), initialize(), and initialize().

◆ MzIntegrationParams() [2/3]

pappso::MzIntegrationParams::MzIntegrationParams ( const QString & text,
QObject * parent = nullptr )
explicit

Definition at line 94 of file mzintegrationparams.cpp.

94 : QObject(parent)
95{
96 initialize(text);
97}
Q_INVOKABLE InitializationResult initialize(const QString &text)

References initialize().

◆ MzIntegrationParams() [3/3]

pappso::MzIntegrationParams::MzIntegrationParams ( double minMz,
double maxMz,
MzIntegrationParams::BinningType binning_type,
pappso::PrecisionPtr precisionPtr,
int binSizeDivisor,
int decimalPlaces,
bool removeZeroValDataPoints,
QObject * parent = nullptr )
explicit

Definition at line 99 of file mzintegrationparams.cpp.

107 : QObject(parent),
108 m_smallestMz(min_mz),
109 m_greatestMz(max_mz),
110 m_binningType(binning_type),
111 m_binSizeModel(bin_size_model),
112 m_binSizeDivisor(bin_size_divisor),
113 m_decimalPlaces(decimal_places),
114 m_removeZeroValDataPoints(remove_zero_val_data_points)
115{
116 if(m_binSizeModel == nullptr)
118
119 // qDebug() << "MetaObject?" << this->metaObject()->className();
120}
pappso::PrecisionPtr m_binSizeModel
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer

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

◆ ~MzIntegrationParams()

pappso::MzIntegrationParams::~MzIntegrationParams ( )
virtual

Definition at line 122 of file mzintegrationparams.cpp.

123{
124}

Member Function Documentation

◆ binningTypeChanged

void pappso::MzIntegrationParams::binningTypeChanged ( )
signal

Referenced by setBinningType().

◆ binSizeDivisorChanged

void pappso::MzIntegrationParams::binSizeDivisorChanged ( )
signal

Referenced by setBinSizeDivisor().

◆ binSizeModelChanged

void pappso::MzIntegrationParams::binSizeModelChanged ( )
signal

◆ clone()

MzIntegrationParams * pappso::MzIntegrationParams::clone ( QObject * parent = nullptr) const

Definition at line 127 of file mzintegrationparams.cpp.

128{
129 MzIntegrationParams *mz_integration_params_p = new MzIntegrationParams(m_smallestMz,
136 parent);
137
138 return mz_integration_params_p;
139}
Q_INVOKABLE MzIntegrationParams(QObject *parent=nullptr)

References MzIntegrationParams(), m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, and m_smallestMz.

◆ createArbitraryBins()

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

Definition at line 543 of file mzintegrationparams.cpp.

544{
545 // Now starts the tricky stuff. Depending on the binning size model, we need to take diverse
546 // actions.
547
548 if(!isValid())
549 qFatal() << "Programming error. The MzIntegrationParams::BinningLogic is not valid, cannot "
550 "create bins.";
551
552 qDebug() << "Binning logic:" << toString();
553
554 double min_mz = m_smallestMz;
555 double max_mz = m_greatestMz;
556
557 qDebug() << "m_smallestMz:" << m_smallestMz << "m_greatestMz:" << m_greatestMz;
558
559 double bin_size;
560
562 {
563 double resolution_based_bin_size = m_binSizeModel->delta(min_mz);
564 bin_size = resolution_based_bin_size / m_binSizeDivisor;
565
566 // qDebug() << "With res-based bin size, the uncorrected bin size:"
567 //<< resolution_based_bin_size
568 //<< "and the final binSize:" << binSize;
569 }
570 else
571 bin_size = m_binSizeModel->delta(min_mz);
572
573 // qDebug() << QString::asprintf(
574 //"binSize is the precision delta for min_mz: %.6f\n", binSize);
575
576 // Only compute the decimal places if they were not configured already.
577 if(m_decimalPlaces == -1)
578 {
579 // qDebug() << "Now checking how many decimal places are needed.";
580
581 // We want as many decimal places as there are 0s between the integral
582 // part of the double and the first non-0 cipher. For example, if
583 // binSize is 0.004, zero decimals is 2 and m_decimalPlaces is set to 3,
584 // because we want decimals up to 4 included.
585
587
588 // qDebug() << "With binSize" << binSize
589 //<< " m_decimalPlaces was computed to be:" << m_decimalPlaces;
590 }
591 // else
592 // qDebug() << "m_decimalPlaces: " << m_decimalPlaces;
593
594 // Now that we have defined the value of m_decimalPlaces, let's use that
595 // value.
596
597 double first_mz =
598 ceil((min_mz * std::pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
599 double last_mz = ceil((max_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
600
601 // qDebug() << "After having accounted for the decimals, new min/max values:"
602 //<< QString::asprintf("Very first data point: %.6f\n", first_mz)
603 //<< QString::asprintf("Very last data point to reach: %.6f\n",
604 // last_mz);
605
606 // Instanciate the vector of mz double_s that we'll feed with the bins.
607
608 std::vector<double> bins;
609
610 // Store that very first value for later use in the loop.
611 // The bins are notking more than:
612 //
613 // 1. The first mz (that is the smallest mz value found in all the spectra
614 // 2. A sequence of mz values corresponding to that first mz value
615 // incremented by the bin size.
616
617 // Seed the root of the bin vector with the first mz value rounded above as
618 // requested.
619 double previous_mz_bin = first_mz;
620
621 bins.push_back(previous_mz_bin);
622
623 // Now continue adding mz values until we have reached the end of the
624 // spectrum, that is the max_mz value, as converted using the decimals to
625 // last_mz.
626
627 // debugCount value used below for debugging purposes.
628 // int debugCount = 0;
629
630 while(previous_mz_bin <= last_mz)
631 {
632
633 // qDebug() << "Now starting the bin creation loop.";
634
635 // Calculate dynamically the precision delta according to the current mz
636 // value.
637
638 // double precision_delta = mp_precision->delta(previous_mz_bin);
639 // qDebug() << "precision_delta: " << precision_delta;
640
641 // In certain circumstances, the bin size is not enough to properly render
642 // hyper-high resolution data (like the theoretical isotopic cluster data
643 // generated in silico). In that case, the bin size, computed using the
644 // precision object, is divided by the m_binSizeDivisor, which normally is
645 // set to 1 as the default, that is, it has no effect.
646
647 double current_mz;
648
650 {
651 current_mz =
652 previous_mz_bin + (m_binSizeModel->delta(previous_mz_bin) / m_binSizeDivisor);
653 }
654 else
655 {
656 current_mz = previous_mz_bin + m_binSizeModel->delta(previous_mz_bin);
657 }
658
659 // qDebug() << QString::asprintf(
660 //"previous_mzBin: %.6f and current_mz: %.6f\n",
661 // previous_mz_bin,
662 // current_mz);
663
664 // Now apply on the obtained mz value the decimals that were either set
665 // or computed earlier.
666
667 double current_rounded_mz =
668 ceil((current_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
669
670 // qDebug() << QString::asprintf(
671 //"current_mz: %.6f and current_rounded_mz: %.6f and previous_mzBin "
672 //": % .6f\n ",
673 // current_mz,
674 // current_rounded_mz,
675 // previous_mz_bin);
676
677 // If rounding makes the new value identical to the previous one, then
678 // that means that we need to decrease roughness.
679
680 if(current_rounded_mz == previous_mz_bin)
681 {
683
684 current_rounded_mz =
685 ceil((current_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
686
687 // qDebug().noquote()
688 //<< "Had to increment decimal places by one while creating the bins "
689 //"in MzIntegrationParams::BinningType::ARBITRARY mode..";
690 }
691
692 bins.push_back(current_rounded_mz);
693
694 // Use the local_mz value for the storage of the previous mz bin.
695 previous_mz_bin = current_rounded_mz;
696 }
697
698
699#if 0
700
701 QString fileName = "/tmp/massSpecArbitraryBins.txt-at-" +
702 QDateTime::currentDateTime().toString("yyyyMMdd-HH-mm-ss");
703
704 qDebug() << "Writing the list of bins setup in the "
705 "mass spectrum in file "
706 << fileName;
707
708 QFile file(fileName);
709 file.open(QIODevice::WriteOnly);
710
711 QTextStream fileStream(&file);
712
713 for(auto &&bin : bins)
714 fileStream << QString("%1\n").arg(bin, 0, 'f', 10);
715
716 fileStream.flush();
717 file.close();
718
719#endif
720
721 // qDebug() << "Prepared bins with " << bins.size() << "elements."
722 //<< "starting with mz" << bins.front() << "ending with mz"
723 //<< bins.back();
724
725 return bins;
726}
Q_INVOKABLE bool isValid() const
Q_INVOKABLE QString toString() const
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

References isValid(), m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_smallestMz, pappso::Enums::res, toString(), and pappso::Utils::zeroDecimalsInValue().

Referenced by createBins(), and createBins().

◆ createBins() [1/2]

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

Definition at line 483 of file mzintegrationparams.cpp.

484{
485
486 // qDebug() << "mp_precision:" << mp_precision->toString();
487
488 std::vector<double> bins;
489
491 {
492 // If no binning is to be performed, fine.
493 return bins;
494 }
496 {
497 // Use only data in the MzIntegrationParams member data.
498 return createArbitraryBins();
499 }
501 {
502 // qDebug();
503
504 qFatal("Programming error. This kind of binning is not supported.");
505 }
506
507 return bins;
508}
std::vector< double > createArbitraryBins()
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value

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

◆ createBins() [2/2]

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

Definition at line 512 of file mzintegrationparams.cpp.

513{
514
515 // qDebug();
516
517 std::vector<double> bins;
518
520 {
521 // If no binning is to be performed, fine.
522 return bins;
523 }
525 {
526 // Use only data in the MzIntegrationParams member data.
527 return createArbitraryBins();
528 }
530 {
531 // qDebug();
532
533 // Use the first spectrum to perform the data-based bins
534
535 return createDataBasedBins(mass_spectrum_csp);
536 }
537
538 return bins;
539}
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)

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

◆ createDataBasedBins()

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

Definition at line 730 of file mzintegrationparams.cpp.

731{
732 // qDebug();
733
734 // The bins in *this mass spectrum must be calculated starting from the
735 // data in the mass_spectrum_csp parameter.
736
737 // Instanciate the vector of mz double_s that we'll feed with the bins.
738
739 std::vector<double> bins;
740
741 if(mass_spectrum_csp->size() < 2)
742 return bins;
743
744 // Make sure the spectrum is sorted, as this functions takes for granted
745 // that the DataPoint instances are sorted in ascending x (== mz) value
746 // order.
747 pappso::MassSpectrum local_mass_spectrum = *mass_spectrum_csp;
748 local_mass_spectrum.sortMz();
749
750 double min_mz = m_smallestMz;
751
752 // qDebug() << "The min_mz:" << min_mz;
753
754 if(m_decimalPlaces != -1)
755 min_mz = ceil((min_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
756
757
758 // Two values for the definition of a MassSpectrumBin.
759
760 // The first value of the mz range that defines the bin. This value is part
761 // of the bin.
762 double start_mz_in = min_mz;
763
764 // The second value of the mz range that defines the bin. This value is
765 // *not* part of the bin.
766 double end_mz_out;
767
768 std::vector<pappso::DataPoint>::const_iterator it = local_mass_spectrum.begin();
769
770 double prev_mz = it->x;
771
772 if(m_decimalPlaces != -1)
773 prev_mz = ceil((prev_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
774
775 ++it;
776
777 while(it != local_mass_spectrum.end())
778 {
779 double next_mz = it->x;
780
781 if(m_decimalPlaces != -1)
782 next_mz = ceil((next_mz * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
783
784 double step = next_mz - prev_mz;
785 end_mz_out = start_mz_in + step;
786
787 if(m_decimalPlaces != -1)
788 end_mz_out =
789 ceil((end_mz_out * pow(10, m_decimalPlaces)) - 0.49) / pow(10, m_decimalPlaces);
790
791 // The data point that is crafted has a 0 y-value. The binning must
792 // indeed not create artificial intensity data.
793
794 // qDebug() << "Pushing back bin:" << start_mz_in << end_mz_out;
795
796 bins.push_back(start_mz_in);
797
798 // Prepare next bin
799 start_mz_in = end_mz_out;
800
801 // Update prev_mz to be the current one for next iteration.
802 prev_mz = next_mz;
803
804 // Now got the next DataPoint instance.
805 ++it;
806 }
807
808#if 0
809
810 QString fileName = "/tmp/massSpecDataBasedBins.txt";
811
812 qDebug() << "Writing the list of bins setup in the "
813 "mass spectrum in file "
814 << fileName;
815
816 QFile file(fileName);
817 file.open(QIODevice::WriteOnly);
818
819 QTextStream fileStream(&file);
820
821 for(auto &&bin : m_bins)
822 fileStream << QString("[%1-%2]\n")
823 .arg(bin.startMzIn, 0, 'f', 10)
824 .arg(bin.endMzOut, 0, 'f', 10);
825
826 fileStream.flush();
827 file.close();
828
829 qDebug() << "elements."
830 << "starting with mz" << m_bins.front().startMzIn << "ending with mz"
831 << m_bins.back().endMzOut;
832
833#endif
834
835 return bins;
836}
void sortMz()
Sort the DataPoint instances of this spectrum.

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

Referenced by createBins().

◆ decimalPlacesChanged

void pappso::MzIntegrationParams::decimalPlacesChanged ( )
signal

Referenced by setDecimalPlaces().

◆ getBinningType()

MzIntegrationParams::BinningType pappso::MzIntegrationParams::getBinningType ( ) const

Definition at line 355 of file mzintegrationparams.cpp.

356{
357 return m_binningType;
358}

References m_binningType.

◆ getBinSizeDivisor()

int pappso::MzIntegrationParams::getBinSizeDivisor ( ) const

Definition at line 396 of file mzintegrationparams.cpp.

397{
398 return m_binSizeDivisor;
399}

References m_binSizeDivisor.

◆ getBinSizeModel()

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

Definition at line 380 of file mzintegrationparams.cpp.

381{
382 return m_binSizeModel;
383}

References m_binSizeModel.

◆ getDecimalPlaces()

int pappso::MzIntegrationParams::getDecimalPlaces ( ) const

Definition at line 362 of file mzintegrationparams.cpp.

363{
364 return m_decimalPlaces;
365}

References m_decimalPlaces.

◆ getGreatestMz()

double pappso::MzIntegrationParams::getGreatestMz ( ) const

Definition at line 331 of file mzintegrationparams.cpp.

332{
333 return m_greatestMz;
334}

References m_greatestMz.

◆ getSmallestMz()

double pappso::MzIntegrationParams::getSmallestMz ( ) const

Definition at line 302 of file mzintegrationparams.cpp.

303{
304 return m_smallestMz;
305}

References m_smallestMz.

◆ greatestMzChanged

void pappso::MzIntegrationParams::greatestMzChanged ( )
signal

Referenced by setGreatestMz(), and updateGreatestMz().

◆ hasValidMzRange()

bool pappso::MzIntegrationParams::hasValidMzRange ( ) const

Definition at line 475 of file mzintegrationparams.cpp.

476{
477 return (m_smallestMz < std::numeric_limits<double>::max()) &&
478 (m_greatestMz >= std::numeric_limits<double>::min());
479}

References m_greatestMz, and m_smallestMz.

◆ initialize() [1/4]

void pappso::MzIntegrationParams::initialize ( const MzIntegrationParams & other,
QObject * parent = nullptr )

Definition at line 244 of file mzintegrationparams.cpp.

245{
246 m_smallestMz = other.m_smallestMz;
247 m_greatestMz = other.m_greatestMz;
248 m_binningType = other.m_binningType;
249 m_binSizeModel = other.m_binSizeModel;
250 m_binSizeDivisor = other.m_binSizeDivisor;
251 m_decimalPlaces = other.m_decimalPlaces;
252 m_removeZeroValDataPoints = other.m_removeZeroValDataPoints;
253
254 setParent(parent);
255}

References MzIntegrationParams(), m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, and m_smallestMz.

◆ initialize() [2/4]

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

Definition at line 142 of file mzintegrationparams.cpp.

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

References BIN_SIZE_DIVISOR, BIN_SIZE_MODEL, BINNING_TYPE, DECIMAL_PLACES, DEFAULT, pappso::PrecisionFactory::fromString(), pappso::getBinningTypeFromString(), m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_removeZeroValDataPoints, REMOVE_ZERO_DATA_POINTS, and reset().

Referenced by MzIntegrationParams().

◆ initialize() [3/4]

void pappso::MzIntegrationParams::initialize ( double minMz,
double maxMz,
MzIntegrationParams::BinningType binning_type,
pappso::PrecisionPtr precisionPtr,
int binSizeDivisor,
int decimalPlaces,
bool removeZeroValDataPoints,
QObject * parent = nullptr )

Definition at line 223 of file mzintegrationparams.cpp.

231{
232 m_smallestMz = min_mz;
233 m_greatestMz = max_mz;
234 m_binningType = binning_type;
235 m_binSizeModel = bin_size_model;
236 m_binSizeDivisor = bin_size_divisor;
237 m_decimalPlaces = decimal_places;
238 m_removeZeroValDataPoints = remove_zero_val_data_points;
239
240 setParent(parent);
241}

References m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, and m_smallestMz.

◆ initialize() [4/4]

void pappso::MzIntegrationParams::initialize ( MzIntegrationParams & other,
InitializationResult initialization_results )

Definition at line 260 of file mzintegrationparams.cpp.

262{
263 if(static_cast<bool>(initialization_results &
265 m_binningType = other.m_binningType;
266
267 if(static_cast<bool>(initialization_results &
269 m_binSizeModel = other.m_binSizeModel;
270
271 if(static_cast<bool>(initialization_results &
273 m_binSizeDivisor = other.m_binSizeDivisor;
274
275 if(static_cast<bool>(initialization_results &
277 m_decimalPlaces = other.m_decimalPlaces;
278}

References MzIntegrationParams(), BIN_SIZE_DIVISOR, BIN_SIZE_MODEL, BINNING_TYPE, DECIMAL_PLACES, m_binningType, m_binSizeDivisor, m_binSizeModel, and m_decimalPlaces.

◆ isRemoveZeroValDataPoints()

bool pappso::MzIntegrationParams::isRemoveZeroValDataPoints ( ) const

Definition at line 423 of file mzintegrationparams.cpp.

424{
426}

References m_removeZeroValDataPoints.

◆ isValid()

bool pappso::MzIntegrationParams::isValid ( ) const

Definition at line 448 of file mzintegrationparams.cpp.

449{
450 int errors = 0;
451
453 {
454 // qDebug() << "m_smallestMz:" << m_smallestMz;
455 // qDebug() << "smallest is max:" << (m_smallestMz ==
456 // std::numeric_limits<double>::max());
457 errors += (m_smallestMz == std::numeric_limits<double>::max() ? 1 : 0);
458
459 // qDebug() << "m_greatestMz:" << m_greatestMz;
460 // qDebug() << "greatest is min:" << (m_greatestMz ==
461 // std::numeric_limits<double>::min());
462 errors += (m_greatestMz == std::numeric_limits<double>::min() ? 1 : 0);
463 }
464
465 if(errors)
466 {
467 qCritical() << "The m/z integration parameters are invalid.";
468 }
469
470 return !errors;
471}

References m_binningType, m_greatestMz, m_smallestMz, and NONE.

Referenced by createArbitraryBins().

◆ registerJsConstructor()

void pappso::MzIntegrationParams::registerJsConstructor ( QJSEngine * engine)
static

Definition at line 907 of file mzintegrationparams.cpp.

908{
909 qDebug() << "registerJsConstructor for MzIntegrationParams to QJSEngine.";
910
911 if(!engine)
912 {
913 qWarning() << "Cannot register class: engine is null";
914 return;
915 }
916
917 QJSValue enumObject;
918
919 enumObject = engine->newObject();
920 enumObject.setProperty("none", static_cast<int>(pappso::MzIntegrationParams::BinningType::NONE));
921 enumObject.setProperty("dataBased",
923 enumObject.setProperty("arbitrary",
925 engine->globalObject().setProperty("BinningType", enumObject);
926
927 enumObject = engine->newObject();
928 enumObject.setProperty(
930 enumObject.setProperty(
931 "fromSettingsBinSizeModelPartial",
933 enumObject.setProperty(
934 "fromSettingsBinSizeModelFull",
936 enumObject.setProperty("fromSettingsFull",
938 engine->globalObject().setProperty("InitializationResult", enumObject);
939
940 // Register the meta object as a constructor
941 QJSValue jsMetaObject = engine->newQMetaObject(&MzIntegrationParams::staticMetaObject);
942 engine->globalObject().setProperty("MzIntegrationParams", jsMetaObject);
943}

References ARBITRARY, BINNING_LOGIC_FULL, BINNING_LOGIC_PARTIAL, DATA_BASED, DEFAULT, FULL, and NONE.

◆ removeZeroValDataPointsChanged

void pappso::MzIntegrationParams::removeZeroValDataPointsChanged ( )
signal

◆ reset()

void pappso::MzIntegrationParams::reset ( )

Reset the instance to default values.

Definition at line 431 of file mzintegrationparams.cpp.

432{
433 m_smallestMz = std::numeric_limits<double>::max();
434 m_greatestMz = std::numeric_limits<double>::min();
435
439 m_decimalPlaces = -1;
440
442
443 emit wasReset();
444}
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer

References ARBITRARY, pappso::PrecisionFactory::getResInstance(), m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, and wasReset().

Referenced by initialize().

◆ setBinningType()

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

Definition at line 344 of file mzintegrationparams.cpp.

345{
346 if(m_binningType == binning_type)
347 return;
348
349 m_binningType = binning_type;
350 return binningTypeChanged();
351}

References binningTypeChanged(), and m_binningType.

◆ setBinSizeDivisor()

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

Definition at line 386 of file mzintegrationparams.cpp.

387{
388 if(m_binSizeDivisor == divisor)
389 return;
390
391 m_binSizeDivisor = divisor;
393}

References binSizeDivisorChanged(), and m_binSizeDivisor.

◆ setBinSizeModel()

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

Definition at line 368 of file mzintegrationparams.cpp.

369{
370 if(m_binSizeModel == bin_size_model_p)
371 return;
372
373 m_binSizeModel = bin_size_model_p;
374
375 if(m_binSizeModel == nullptr)
377}

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

◆ setDecimalPlaces()

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

Definition at line 402 of file mzintegrationparams.cpp.

403{
404 if(m_decimalPlaces == decimal_places)
405 return;
406
407 m_decimalPlaces = decimal_places;
409}

References decimalPlacesChanged(), and m_decimalPlaces.

◆ setGreatestMz()

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

Definition at line 309 of file mzintegrationparams.cpp.

310{
311 if(m_greatestMz == value)
312 return;
313
314 m_greatestMz = value;
315 emit greatestMzChanged();
316}

References greatestMzChanged(), and m_greatestMz.

Referenced by setMzValues().

◆ setMzValues()

void pappso::MzIntegrationParams::setMzValues ( double smallest,
double greatest )

Definition at line 337 of file mzintegrationparams.cpp.

338{
339 setSmallestMz(smallest);
340 setGreatestMz(greatest);
341}

References setGreatestMz(), and setSmallestMz().

◆ setRemoveZeroValDataPoints()

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

Definition at line 412 of file mzintegrationparams.cpp.

413{
414 if(m_removeZeroValDataPoints == removeOrNot)
415 return;
416
417 m_removeZeroValDataPoints = removeOrNot;
419}

References m_removeZeroValDataPoints, and removeZeroValDataPointsChanged().

◆ setSmallestMz()

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

Definition at line 281 of file mzintegrationparams.cpp.

282{
283 if(m_smallestMz != value)
284 m_smallestMz = value;
285
286 emit smallestMzChanged();
287}

References m_smallestMz, and smallestMzChanged().

Referenced by setMzValues().

◆ smallestMzChanged

void pappso::MzIntegrationParams::smallestMzChanged ( )
signal

Referenced by setSmallestMz(), and updateSmallestMz().

◆ toString() [1/2]

QString pappso::MzIntegrationParams::toString ( ) const

Definition at line 889 of file mzintegrationparams.cpp.

890{
891 QString text;
892
893 // In the string for saving settings, we do not ouput the m/z values.
894 text.append(QString("Binning type:%1\n").arg(::pappso::binningTypeMap[m_binningType]));
895 text.append(QString("Bin size model: %1\n").arg(m_binSizeModel->toString()));
896 text.append(QString("Bin size divisor: %2\n").arg(m_binSizeDivisor));
897 text.append(QString("Decimal places:%1\n").arg(m_decimalPlaces));
898 text.append(QString("Remove 0-val data points:%1\n").arg(m_removeZeroValDataPoints));
899
900 // qDebug().noquote() << "Returning text:\n" << text;
901
902 return text;
903}
std::map< MzIntegrationParams::BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.

References pappso::binningTypeMap, m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, and m_removeZeroValDataPoints.

Referenced by createArbitraryBins().

◆ toString() [2/2]

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

Definition at line 841 of file mzintegrationparams.cpp.

842{
843 // The space-containing string that reflects the offset at which
844 // new text lines should be added to start with.
845 QString offset_lead;
846
847 for(int iter = 0; iter < offset; ++iter)
848 offset_lead += spacer;
849
850 QString text = offset_lead;
851 text += "m/z integration parameters:\n";
852
853 QString new_lead = QString("%1%2").arg(offset_lead).arg(spacer);
854
855 text += new_lead;
856 if(m_smallestMz != std::numeric_limits<double>::max())
857 text.append(QString::asprintf("Smallest (first) m/z: %.6f\n", m_smallestMz));
858
859 text += new_lead;
860 if(m_greatestMz != std::numeric_limits<double>::min())
861 text.append(QString::asprintf("Greatest (last) m/z: %.6f\n", m_greatestMz));
862
863 text += new_lead;
864 text +=
865 QString("Remove 0-val data points: %1\n").arg(m_removeZeroValDataPoints ? "true" : "false");
866
867 text += new_lead;
868 text.append("Binning logic:\n");
869
870 new_lead += spacer;
871
872 text += new_lead;
873 text.append(QString("Binning type:%1\n").arg(::pappso::binningTypeMap[m_binningType]));
874
875 text += new_lead;
876 text.append(QString("Bin size model: %1\n").arg(m_binSizeModel->toString()));
877
878 text += new_lead;
879 text.append(QString("Bin size divisor: %2\n").arg(m_binSizeDivisor));
880
881 text += new_lead;
882 text.append(QString("Decimal places: %1\n").arg(m_decimalPlaces));
883
884 return text;
885}

References pappso::binningTypeMap, m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, and m_smallestMz.

◆ updateGreatestMz()

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

Definition at line 320 of file mzintegrationparams.cpp.

321{
322 if(value > m_greatestMz)
323 {
324 m_greatestMz = value;
325 emit greatestMzChanged();
326 }
327}

References greatestMzChanged(), and m_greatestMz.

◆ updateSmallestMz()

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

Definition at line 291 of file mzintegrationparams.cpp.

292{
293 if(value == m_smallestMz)
294 return;
295
296 m_smallestMz = value;
297 emit smallestMzChanged();
298}

References m_smallestMz, and smallestMzChanged().

◆ wasReset

void pappso::MzIntegrationParams::wasReset ( )
signal

Referenced by reset().

Member Data Documentation

◆ m_binningType

◆ m_binSizeDivisor

int pappso::MzIntegrationParams::m_binSizeDivisor = 1
protected

◆ m_binSizeModel

◆ m_decimalPlaces

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

◆ m_greatestMz

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

◆ m_removeZeroValDataPoints

bool pappso::MzIntegrationParams::m_removeZeroValDataPoints = true
protected

◆ m_smallestMz

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

Property Documentation

◆ binningType

BinningType pappso::MzIntegrationParams::binningType
readwrite

Definition at line 95 of file mzintegrationparams.h.

◆ binSizeDivisor

int pappso::MzIntegrationParams::binSizeDivisor
readwrite

Definition at line 101 of file mzintegrationparams.h.

◆ binSizeModel

pappso::PrecisionPtr pappso::MzIntegrationParams::binSizeModel
readwrite

Definition at line 99 of file mzintegrationparams.h.

◆ decimalPlaces

int pappso::MzIntegrationParams::decimalPlaces
readwrite

Definition at line 97 of file mzintegrationparams.h.

◆ greatestMz

double pappso::MzIntegrationParams::greatestMz
readwrite

Definition at line 94 of file mzintegrationparams.h.

◆ removeZeroValDataPoints

bool pappso::MzIntegrationParams::removeZeroValDataPoints
read

Definition at line 103 of file mzintegrationparams.h.

◆ smallestMz

double pappso::MzIntegrationParams::smallestMz
readwrite

Definition at line 91 of file mzintegrationparams.h.


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