Loading...
Searching...
No Matches
pappso::MzIntegrationParams Class Reference

The MzIntegrationParams class provides the parameters definining how m/z integrations must be performed. 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 , REMOVE_ZERO_DATA_POINTS = 1 << 4 , FULL = (REMOVE_ZERO_DATA_POINTS | BINNING_LOGIC_FULL) }

## Signals

void | smallestMzChanged ()
void | greatestMzChanged ()
void | binningTypeChanged ()
void | indicativeBinSizeChanged ()
void | decimalPlacesChanged ()
void | binSizeModelChanged ()
void | binSizeDivisorChanged ()
void | removeZeroValDataPointsChanged ()

## 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 MzIntegrationParams * | clone (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)
void | initialize (const MzIntegrationParams &other, QObject *parent=nullptr)
Q_INVOKABLE void | initialize (const MzIntegrationParams *other_p, QObject *parent=nullptr)
void | initialize (MzIntegrationParams &other, InitializationResult initialization_results)
Q_INVOKABLE void | setSmallestMz (double value)
Q_INVOKABLE void | updateSmallestMz (double value)
Q_INVOKABLE double | getSmallestMz () const
Q_INVOKABLE void | setGreatestMz (double value)
Q_INVOKABLE void | updateGreatestMz (double value)
Q_INVOKABLE double | getGreatestMz () const
Q_INVOKABLE void | setMzValues (double smallest, double greatest)
Q_INVOKABLE void | setBinningType (BinningType binningType)
Q_INVOKABLE BinningType | getBinningType () const
Q_INVOKABLE void | setBinSizeModel (pappso::PrecisionPtr bin_size_model_p)
Q_INVOKABLE pappso::PrecisionPtr | getBinSizeModel () const
Q_INVOKABLE void | setBinSizeDivisor (int divisor)
Q_INVOKABLE int | getBinSizeDivisor () const
Q_INVOKABLE void | setIndicativeBinSize (double value)
Q_INVOKABLE double | getIndicativeBinSize () const
Q_INVOKABLE void | setDecimalPlaces (int decimal_places)
Q_INVOKABLE int | getDecimalPlaces () const
Q_INVOKABLE void | setRemoveZeroValDataPoints (bool removeOrNot=true)
Q_INVOKABLE 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
Q_INVOKABLE QString | binsToStringWithDeltas (const std::vector< double > bins) const

## Static Public Member Functions

static void | registerJsConstructor (QJSEngine *engine)

## Protected Member Functions

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

## Protected Attributes

double | m_smallestMz = std::numeric_limits<double>::max()
double | m_greatestMz = std::numeric_limits<double>::min()
double | m_indicativeBinSize = 0
BinningType | m_binningType = BinningType::ARBITRARY
pappso::PrecisionPtr | m_binSizeModel
int | m_binSizeDivisor = 6
int | m_decimalPlaces = -1
bool | m_removeZeroValDataPoints = true

## Properties

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

## Detailed Description

The MzIntegrationParams class provides the parameters definining how m/z integrations must be performed.

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

## Member Enumeration Documentation

## BinningType

enum class pappso::MzIntegrationParams::BinningType

strong

Enumerator
NONE | < no binning
DATA_BASED | binning based on mass spectral data
ARBITRARY | binning based on arbitrary bin size value
LAST |

Definition at line 103 of file mzintegrationparams.h.

:
enum class BinningType
{
//! < no binning
NONE = 0,
//! binning based on mass spectral data

## InitializationResult

enum class pappso::MzIntegrationParams::InitializationResult : uint32_t

strong

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

: uint32_t
{
// The order is important.
// See end of class declaration for overload of bitwise operators
DEFAULT = 0x000,
BINNING_TYPE = 1 << 0,
BIN_SIZE_MODEL = 1 << 1,
BIN_SIZE_DIVISOR = 1 << 2,

## Constructor & Destructor Documentation

## MzIntegrationParams() [1/3]

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

explicit

Definition at line 85 of file mzintegrationparams.cpp.

: QObject(parent)
{
}

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

## MzIntegrationParams() [2/3]

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

explicit

Definition at line 89 of file mzintegrationparams.cpp.

: QObject(parent)
{
initialize(text);
}
pappso::MzIntegrationParams::initialize
Q_INVOKABLE InitializationResult initialize(const QString &text)
Definition mzintegrationparams.cpp:140

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 95 of file mzintegrationparams.cpp.

: QObject(parent),
m_smallestMz(min_mz),
m_greatestMz(max_mz),
m_binningType(binning_type),
m_binSizeModel(bin_size_model),
m_binSizeDivisor(bin_size_divisor),
m_decimalPlaces(decimal_places),
m_removeZeroValDataPoints(remove_zero_val_data_points)
{
if(m_binSizeModel == nullptr)
m_binSizeModel = pappso::PrecisionFactory::getPpmInstance(20);
// qDebug() << "MetaObject?" << this->metaObject()->className();
}
pappso::MzIntegrationParams::m_greatestMz
double m_greatestMz
Definition mzintegrationparams.h:232
pappso::MzIntegrationParams::m_binningType
BinningType m_binningType
Definition mzintegrationparams.h:239
pappso::MzIntegrationParams::m_binSizeDivisor
int m_binSizeDivisor
Definition mzintegrationparams.h:253
pappso::MzIntegrationParams::m_binSizeModel
pappso::PrecisionPtr m_binSizeModel
Definition mzintegrationparams.h:240
pappso::MzIntegrationParams::m_smallestMz
double m_smallestMz
Definition mzintegrationparams.h:228
pappso::MzIntegrationParams::m_decimalPlaces
int m_decimalPlaces
Definition mzintegrationparams.h:258
pappso::MzIntegrationParams::m_removeZeroValDataPoints
bool m_removeZeroValDataPoints
Definition mzintegrationparams.h:263
pappso::PrecisionFactory::getPpmInstance
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
Definition precision.cpp:155

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 119 of file mzintegrationparams.cpp.

{
}

## Member Function Documentation

## binningTypeChanged

void pappso::MzIntegrationParams::binningTypeChanged | ( |  | ) |

signal

Referenced by removeZeroValDataPointsChanged(), and setBinningType().

## binSizeDivisorChanged

void pappso::MzIntegrationParams::binSizeDivisorChanged | ( |  | ) |

signal

Referenced by setBinSizeDivisor().

## binSizeModelChanged

void pappso::MzIntegrationParams::binSizeModelChanged | ( |  | ) |

signal

Referenced by setBinSizeModel().

## binsToStringWithDeltas()

QString pappso::MzIntegrationParams::binsToStringWithDeltas | ( | const std::vector< double > | bins | ) | const

Definition at line 1219 of file mzintegrationparams.cpp.

{
QString bins_with_delta;
double previous_bin_value = 0;
for(auto &&value : bins)
{
double delta = value - previous_bin_value;
bins_with_delta += QString("%1 - %2\n")
.arg(value, 0, 'f', m_decimalPlaces)
.arg(delta, 0, 'f', m_decimalPlaces);
previous_bin_value = value;
}
return bins_with_delta;
}

References m_decimalPlaces.

Referenced by createArbitraryBins(), createDataBasedBins(), and greatestMzChanged().

## clone()

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

Definition at line 124 of file mzintegrationparams.cpp.

{
MzIntegrationParams *mz_integration_params_p =
new MzIntegrationParams(m_smallestMz,
m_greatestMz,
m_binningType,
m_binSizeModel,
m_binSizeDivisor,
m_decimalPlaces,
m_removeZeroValDataPoints,
parent);
return mz_integration_params_p;
}
pappso::MzIntegrationParams::MzIntegrationParams
Q_INVOKABLE MzIntegrationParams(QObject *parent=nullptr)
Definition mzintegrationparams.cpp:85

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 555 of file mzintegrationparams.cpp.

{
// Now starts the tricky stuff. Depending on the binning size model, we need
// to take diverse actions.
if(!isValid())
qFatal() << "Programming error. The MzIntegrationParams::BinningLogic is "
"not valid, cannot create bins.";
// qDebug() << "Binning logic:" << toString();
qDebug() << qSetRealNumberPrecision(6) << "The smallest and greatest m/z values:" << m_smallestMz
<< "-" << m_greatestMz;
// Compute the number of decimals required to faithfully account for the
// precision needed to represent the binned data. We do this by computing
// some sort of bin size and checking how many decimals we need to described it.
// We cannot have a smallest m/z that is 0 because that impairs the computation of the
// bins (see below). In case the m_smallestMz value is 0 we craft one temporary value
// by computing half of the range:
// In certain circumstances, the bin size is not enough to properly render
// hyper-high resolution data (like the theoretical isotopic cluster data
// generated in silico). In that case, the bin size, computed using the
// precision object, is divided by the m_binSizeDivisor, which normally is
// set to 6 as the default because that is the empirical observation that
// it gives the most nicely shaped peaks.
Q_ASSERT(m_binSizeDivisor >= 1);
// Instantiate the vector of mz double_s that we'll feed with the bins.
std::vector<double> bins;
double bin_size;
if(!m_smallestMz)
{
if(m_indicativeBinSize)
{
// The caller has intelligently set an indicative bin size. Use it.
bin_size = m_indicativeBinSize;
qDebug() << qSetRealNumberPrecision(6)
<< "The indicative bin size is being used:" << bin_size;
}
else
{
double half_way_mz = 0;
half_way_mz = (m_greatestMz - m_smallestMz) / 2;
qDebug() << " Target min_mz:" << m_smallestMz << "and max_mz:" << m_greatestMz
<< "half_way_mz:" << half_way_mz;
bin_size = m_binSizeModel->delta(half_way_mz) / m_binSizeDivisor;
qDebug() << qSetRealNumberPrecision(6)
<< "The m/z range half way strategy is being used for bin size:" << bin_size;
}
}
else
{
bin_size = m_binSizeModel->delta(m_smallestMz) / m_binSizeDivisor;
qDebug() << qSetRealNumberPrecision(6) << "The normally computed bin size:" << bin_size;
}
qDebug() << qSetRealNumberPrecision(6) << "The bin size was computed to be" << bin_size;
// Only compute the decimal places if they were not configured already.
if(m_decimalPlaces == -1)
{
// qDebug() << "Now checking how many decimal places are needed.";
// We want as many decimal places as there are 0s between the integral
// part of the double and the first non-0 cipher. For example, if
// binSize is 0.004, zero decimals is 2 and m_decimalPlaces is set to 3,
// because we want decimals up to 4 included.
m_decimalPlaces = pappso::Utils::zeroDecimalsInValue(bin_size) + 1;
qDebug() << "With binSize" << bin_size
<< " m_decimalPlaces was computed to be:" << m_decimalPlaces;
}
qDebug() << "m_decimalPlaces: " << m_decimalPlaces;
// Now that we have defined the value of m_decimalPlaces, let's use that
// value.
double first_mz =
Utils::roundValueToDecimalPlaces(m_smallestMz, m_decimalPlaces, /*round_up*/ false);
double last_mz =
Utils::roundValueToDecimalPlaces(m_greatestMz, m_decimalPlaces, /*round_up*/ true);
qDebug() << qSetRealNumberPrecision(10)
<< "After having accounted for the decimals, new min/max values:"
<< "Very first data point to start from:" << first_mz
<< "Very last data point to reach: " << last_mz;
double previous_mz_bin;
double current_mz;
// Store that very first value for later use in the loop.
// The bins are nothing more than:
//
// 1. The first mz (that is the smallest mz value)
// 2. A sequence of mz values corresponding to that first mz value
// incremented by the bin size calculated each time using the precision
// facility (res, ppm, dalton logic).
bins.push_back(first_mz);
// The previous_mz_bin cannot be 0, otherwise the m_binSizeModel->delta() will
// return 0 and we won't be able to create bins.
if(!first_mz)
{
bins.push_back(bin_size);
previous_mz_bin = bin_size;
}
else
{
previous_mz_bin = first_mz;
}
// qDebug() << qSetRealNumberPrecision(6) << "Pushed back first rounded mz:" << previous_mz_bin;
// Now continue adding mz values until we have reached the end of the
// spectrum, that is the max_mz value, as converted using the decimals to
// last_mz.
// debugCount value used below for debugging purposes.
// int debugCount = 0;
while(previous_mz_bin <= last_mz)
{
// The size of bin is calculated dynamically using the
// precision object that computes it with its specifications:
// res or ppm or dalton.
current_mz = previous_mz_bin + m_binSizeModel->delta(previous_mz_bin) / m_binSizeDivisor;
// qDebug() << qSetRealNumberPrecision(6) << "previous mz bin: " << previous_mz_bin
// << "and current mz: " << current_mz;
// Now apply on the obtained mz value the decimals that were either set
// or computed earlier.
double current_rounded_mz = Utils::roundValueToDecimalPlaces(current_mz,
m_decimalPlaces,
/*round_up*/ true);
// qDebug() << qSetRealNumberPrecision(50)
// << "after rounding, current mz becomes: " << current_rounded_mz;
// If rounding makes the new value identical to the previous one, then
// that means that we need to decrease roughness.
if(current_rounded_mz == previous_mz_bin)
{
++m_decimalPlaces;
qDebug() << "It was required to increment decimal places to" << m_decimalPlaces;
current_rounded_mz = Utils::roundValueToDecimalPlaces(current_mz,
m_decimalPlaces,
/*round_up*/ true);
qDebug().noquote() << "Because current rounded mz is equal to previous mz bin, we had to "
"increment decimal places by one while creating the bins "
"in MzIntegrationParams::BinningType::ARBITRARY mode.";
}
bins.push_back(current_rounded_mz);
// qDebug() << qSetRealNumberPrecision(50)
// << "Pushed back current rounded mz:" << current_rounded_mz;
// Use the local_mz value for the storage of the previous mz bin.
previous_mz_bin = current_rounded_mz;
}
// #if 0
QString bins_with_delta = binsToStringWithDeltas(bins);
QString file_name = "/tmp/massSpecArbitraryBins.txt-at-" +
QDateTime::currentDateTime().toString("yyyyMMdd-HH-mm-ss");
qDebug() << "Writing the list of bins setup in the mass spectrum in file " << file_name;
Q_ASSERT(Utils::writeToFile(bins_with_delta, file_name));
// #endif
qDebug() << "Prepared " << bins.size() << "arbitrary bins starting with mz" << bins.front()
<< "ending with mz" << bins.back();
return bins;
}
pappso::MzIntegrationParams::m_indicativeBinSize
double m_indicativeBinSize
Definition mzintegrationparams.h:237
pappso::MzIntegrationParams::binsToStringWithDeltas
Q_INVOKABLE QString binsToStringWithDeltas(const std::vector< double > bins) const
Definition mzintegrationparams.cpp:1219
pappso::MzIntegrationParams::isValid
Q_INVOKABLE bool isValid() const
Definition mzintegrationparams.cpp:466
pappso::Utils::roundValueToDecimalPlaces
static double roundValueToDecimalPlaces(double value, int decimal_places, bool round_up=true)
Definition utils.cpp:371
pappso::Utils::writeToFile
static bool writeToFile(const QString &text, const QString &file_name)
Definition utils.cpp:216
pappso::Utils::zeroDecimalsInValue
static int zeroDecimalsInValue(pappso_double value)
Determine the number of zero decimals between the decimal point and the first non-zero decimal.
Definition utils.cpp:102

References binsToStringWithDeltas(), isValid(), m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_indicativeBinSize, m_smallestMz, pappso::Utils::roundValueToDecimalPlaces(), pappso::Utils::writeToFile(), and pappso::Utils::zeroDecimalsInValue().

Referenced by createBins(), and createBins().

## createBins() [1/2]

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

Definition at line 499 of file mzintegrationparams.cpp.

{
// qDebug() << "mp_precision:" << mp_precision->toString();
std::vector<double> bins;
if(m_binningType == MzIntegrationParams::BinningType::NONE)
{
// If no binning is to be performed, fine.
return bins;
}
else if(m_binningType == MzIntegrationParams::BinningType::ARBITRARY)
{
// Use only data in the MzIntegrationParams member data.
return createArbitraryBins();
}
else if(m_binningType == MzIntegrationParams::BinningType::DATA_BASED)
{
qFatal() << "Programming error. "
"Please use the createBins(pappso::MassSpectrumCstSPtr "
"mass_spectrum_csp) overload.";
}
return bins;
}
pappso::MzIntegrationParams::createArbitraryBins
std::vector< double > createArbitraryBins()
Definition mzintegrationparams.cpp:555
pappso::MzIntegrationParams::BinningType::DATA_BASED
@ DATA_BASED
binning based on mass spectral data
Definition mzintegrationparams.h:109
pappso::MzIntegrationParams::BinningType::ARBITRARY
@ ARBITRARY
binning based on arbitrary bin size value
Definition mzintegrationparams.h:112
pappso::MzIntegrationParams::BinningType::NONE
@ NONE
< no binning
Definition mzintegrationparams.h:106

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 526 of file mzintegrationparams.cpp.

{
// qDebug();
std::vector<double> bins;
if(m_binningType == MzIntegrationParams::BinningType::NONE)
{
// If no binning is to be performed, fine.
return bins;
}
else if(m_binningType == MzIntegrationParams::BinningType::ARBITRARY)
{
// Use only data in the MzIntegrationParams member data.
return createArbitraryBins();
}
else if(m_binningType == MzIntegrationParams::BinningType::DATA_BASED)
{
// qDebug();
// Use the first spectrum to perform the data-based bins
return createDataBasedBins(mass_spectrum_csp);
}
return bins;
}
pappso::MzIntegrationParams::createDataBasedBins
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)
Definition mzintegrationparams.cpp:752

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

## createDataBasedBins()

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

protected

Definition at line 752 of file mzintegrationparams.cpp.

{
// The mass spectrum passed as parameters has intrinsic bins in it. These bins
// are nothing else than the succession of m/z values in it.
// The very first thing to do is replicate that spectrum into a local copy
// of bins (simple double values), and during that step recompute the m/z
// value (x value) according to the decimals settings in this instance, if
// that is required (that is m_decimalPlaces != -1).
QList<double> bins;
QList<double> deltas;
QList<double> resolutions;
double left_mz_value = 0;
double right_mz_value = 0;
double mz_delta = 0;
double resolution = 0;
// We need three bins to compute a number of values.
if(mass_spectrum_csp->size() < 3)
{
std::vector<double> bins_vector(bins.constBegin(), bins.constEnd());
return bins_vector;
}
// Make sure the spectrum is sorted, as this function takes for granted
// that the DataPoint instances are sorted in ascending x (== mz) value
// order.
pappso::MassSpectrum mass_spectrum_copy = *mass_spectrum_csp;
mass_spectrum_copy.sortMz();
std::vector<pappso::DataPoint>::const_iterator iterator_const =
mass_spectrum_copy.cbegin();
// We need to see the first value
left_mz_value = iterator_const->x;
if(m_decimalPlaces != -1)
left_mz_value =
Utils::roundValueToDecimalPlaces(left_mz_value, m_decimalPlaces, /*round_up*/ true);
qDebug() << qSetRealNumberPrecision(6)
<< "left_mz_value in the template mass spectrum:" << left_mz_value;
bins.append(left_mz_value);
// No delta nor resolution can be computed for the first m/z
// because their computation requires to compare the second m/z with
// the first m/z, and in turn for all the remaining m/z values.
deltas.append(0.0);
resolutions.append(0.0);
// We used the first bin, go to the next!
++iterator_const;
while(iterator_const != mass_spectrum_copy.cend())
{
right_mz_value = iterator_const->x;
qDebug() << qSetRealNumberPrecision(6)
<< "right_mz_value:" << right_mz_value;
if(m_decimalPlaces != -1)
right_mz_value =
Utils::roundValueToDecimalPlaces(right_mz_value, m_decimalPlaces, /*round_up*/ true);
bins.append(right_mz_value);
mz_delta = right_mz_value - left_mz_value;
deltas.append(mz_delta);
Q_ASSERT(mz_delta != 0.0);
resolution = right_mz_value / mz_delta;
resolutions.append(resolution);
left_mz_value = right_mz_value;
++iterator_const;
}
// At this point we have the bins that match those in the template mass
// spectrum.
// #if 0
// We want to check them.
std::vector<double> bins_vector(bins.constBegin(), bins.constEnd());
QString bins_with_delta = binsToStringWithDeltas(bins_vector);
QString file_name =
"/tmp/massSpecDataBasedTemplateBinsWithDeltas.txt-at-" +
QDateTime::currentDateTime().toString("yyyyMMdd-HH-mm-ss");
// qDebug() << "Writing the list of bins setup in the mass spectrum in file "
// << file_name;
Q_ASSERT(Utils::writeToFile(bins_with_delta, file_name));
// #endif
// Done, we now have bins and deltas in between each bin and its following
// bin.
// Now, there are specificities:
//
// If the user has set m_smallestMz and/or m_greatestMz, then we
// still have to work to do. That is because the user wants us to keep
// the binning as found in the template mass spectrum passed as parameter, but
// they also want that the m/z range of the bins be potentially larger, if
// either m_smallestMz is smaller than the first bin value or if
// m_greatestMz is larger than the last bin value, or BOTH.
// The difficulty here is that we need to know the logic that has been used
// in the first place for the generation of the bins in the template mass
// spectrum.
// Some metrics:
// We could check if the bins have the same width all along the m/z range.
// Delta should be constant if the bins were calculated with dalton logic.
bool uniform_deltas = false;
std::size_t deltas_count = deltas.size();
// We cannot really take the first delta because it is 0.00000.
double first_delta = deltas.at(1);
double middle_delta = deltas.at(deltas_count / 2);
double last_delta = deltas.at(deltas_count - 1);
if(first_delta == middle_delta && middle_delta == last_delta)
uniform_deltas = true;
// qDebug() << "Deltas are uniform or not?" << uniform_deltas;
// qDebug() << qSetRealNumberPrecision(6) << "First delta:" << first_delta
// << "Middle delta:" << middle_delta << "Last delta:" << last_delta;
// Resolution should be constant if the bins were calculated with resolution
// logic. Remember : Res = m/z / Delta m/z.
bool uniform_resolutions = false;
std::size_t resolutions_count = resolutions.size();
// We cannot really take the first resolution because it is 0.00000.
double first_resolution = resolutions.at(01);
double middle_resolution = resolutions.at(resolutions_count / 2);
double last_resolution = resolutions.at(resolutions_count - 1);
if(first_resolution == middle_resolution &&
middle_resolution == last_resolution)
uniform_resolutions = true;
// qDebug() << "Deltas are uniform or not?" << uniform_resolutions;
// qDebug() << qSetRealNumberPrecision(6) << "First resolution:" <<
// first_resolution
// << "Middle resolution:" << middle_resolution << "Last resolution:"
// << last_resolution;
// Now that we have the metric about the bins, we can start checking the other
// parameters of the creation of bins:
// m_smallestMz vs m_greatestMz
// In theory, m_smallestMz and m_greatestMz were designed for the arbitrary
// binning method, but it is imaginable that one would want to combine to an
// existing spectrum a new spectrum that is larger than the existing
// one, either on the left or on the right.
double first_bin_mz = bins.first();
double last_bin_mz = bins.last();
// qDebug() << qSetRealNumberPrecision(6) << "smallest_mz:" << m_smallestMz
// << "greatest_mz:" << m_greatestMz;
// Now we can check if the [m_smallestMz -- m_greatestMz] m/z value range
// extends farther on the left or on the right or both compared to the bins
// range.
// Now that we have the real smallest and greatest m/z values that might be
// std::max() and std::min() respectively if not set by the user. So all we
// have to do is check them against the first and last bin values.
// The list of prepended bins on the left of the existing bins. By starting
// with first_bin_mz, we maintain the phase with the bins in the mass spectrum
// passed as parameter.
if(m_smallestMz < first_bin_mz)
{
// qDebug() << "A starting m/z value is smaller than the first bin in the
// "
// "spectrum";
// We will have to craft bins to the left of first_bin_mz up to
// smallest_mz. There are going to be different strategies depending on
// what we discovered above. We will prepend the newly created bins to the
// bins QList (thanks QList).
double bin_mz = first_bin_mz;
if(uniform_deltas)
{
// That is the simplest situation.
while(bin_mz > m_smallestMz)
{
double new_bin_mz = bin_mz - first_delta;
bins.prepend(new_bin_mz);
bin_mz = new_bin_mz;
}
}
else if(uniform_resolutions)
{
// Remember: Res = m/z / Delta m/z.
while(bin_mz > m_smallestMz)
{
double new_bin_mz = bin_mz - (bin_mz / first_resolution);
bins.prepend(new_bin_mz);
bin_mz = new_bin_mz;
}
}
}
// Now make sure we append any necessary bin (same logic as above).
// By starting with last_bin_mz, we maintain the phase with the bins in the
// mass spectrum passed as parameter.
if(m_greatestMz > last_bin_mz)
{
// qDebug() << "A stopping m/z value is greater than the last bin in the "
// "spectrum";
// Craft bins to the right of the bins m/z range, that is append
// new bins.
double bin_mz = last_bin_mz;
if(uniform_deltas)
{
// That is the simplest situation.
while(bin_mz < m_greatestMz)
{
double new_bin_mz = bin_mz + first_delta;
bins.append(new_bin_mz);
bin_mz = new_bin_mz;
}
}
else if(uniform_resolutions)
{
// Remember: Res = m/z / Delta m/z.
while(bin_mz > m_greatestMz)
{
double new_bin_mz = bin_mz + (bin_mz / first_resolution);
bins.append(new_bin_mz);
bin_mz = new_bin_mz;
}
}
}
// At this point we should have bins over the full range of m/z values
// required by the user and in phase with those transmitted via the
// mass spectrum argument.
// Convert to std::vector<double> and return.
std::vector<double> full_bins_vector(bins.constBegin(), bins.constEnd());
#if 0
bins_with_delta = binsToStringWithDeltas(full_bins_vector);
file_name = "/tmp/massSpecDataBasedFullBinsWithDeltas.txt-at-" +
QDateTime::currentDateTime().toString("yyyyMMdd-HH-mm-ss");
qDebug() << "Writing the list of bins setup in the mass spectrum in file "
<< file_name;
Q_ASSERT(Utils::writeToFile(bins_with_delta, file_name));
#endif
// qDebug() << "Prepared " << bins.size() << "data-based bins starting with
// mz"
// << bins.front() << "ending with mz" << bins.back();
return full_bins_vector;
}
pappso::MassSpectrum::sortMz
void sortMz()
Sort the DataPoint instances of this spectrum.
Definition massspectrum.cpp:204

References binsToStringWithDeltas(), m_decimalPlaces, m_greatestMz, m_smallestMz, pappso::Utils::roundValueToDecimalPlaces(), pappso::MassSpectrum::sortMz(), and pappso::Utils::writeToFile().

Referenced by createBins().

## createDataBasedBinsOld()

std::vector< double > pappso::MzIntegrationParams::createDataBasedBinsOld | ( | pappso::MassSpectrumCstSPtr | massSpectrum | ) |

protected

Definition at line 1038 of file mzintegrationparams.cpp.

{
// The bins must be calculated using those in mass_spectrum_csp as a template.
// qDebug();
std::vector<double> bins;
if(mass_spectrum_csp->size() < 2)
return bins;
// Make sure the spectrum is sorted, as this function takes for granted
// that the DataPoint instances are sorted in ascending x (== mz) value
// order.
pappso::MassSpectrum sorted_mass_spectrum = *mass_spectrum_csp;
sorted_mass_spectrum.sortMz();
double min_mz = m_smallestMz;
// qDebug() << "The min_mz:" << min_mz;
if(m_decimalPlaces != -1)
min_mz = ceil((min_mz * pow(10, m_decimalPlaces)) - 0.49) /
pow(10, m_decimalPlaces);
// Two values for the definition of a MassSpectrumBin.
// The first value of the mz range that defines the bin. This value is part
// of the bin.
double start_mz_in = min_mz;
// The second value of the mz range that defines the bin. This value is
// *not* part of the bin.
double end_mz_out;
std::vector<pappso::DataPoint>::const_iterator it =
sorted_mass_spectrum.begin();
double prev_mz = it->x;
if(m_decimalPlaces != -1)
prev_mz = ceil((prev_mz * pow(10, m_decimalPlaces)) - 0.49) /
pow(10, m_decimalPlaces);
++it;
while(it != sorted_mass_spectrum.end())
{
double next_mz = it->x;
if(m_decimalPlaces != -1)
next_mz = ceil((next_mz * pow(10, m_decimalPlaces)) - 0.49) /
pow(10, m_decimalPlaces);
double step = next_mz - prev_mz;
end_mz_out = start_mz_in + step;
if(m_decimalPlaces != -1)
end_mz_out = ceil((end_mz_out * pow(10, m_decimalPlaces)) - 0.49) /
pow(10, m_decimalPlaces);
// The data point that is crafted has a 0 y-value. The binning must
// indeed not create artificial intensity data.
// qDebug() << "Pushing back bin:" << start_mz_in << end_mz_out;
bins.push_back(start_mz_in);
// Prepare next bin
start_mz_in = end_mz_out;
// Update prev_mz to be the current one for next iteration.
prev_mz = next_mz;
// Now go to the next DataPoint instance.
++it;
}
#if 0
QString fileName = "/tmp/massSpecDataBasedBins.txt";
qDebug() << "Writing the list of bins setup in the "
"mass spectrum in file "
<< fileName;
QFile file(fileName);
file.open(QIODevice::WriteOnly);
QTextStream fileStream(&file);
for(auto &&bin : m_bins)
fileStream << QString("[%1-%2]\n")
.arg(bin.startMzIn, 0, 'f', 10)
.arg(bin.endMzOut, 0, 'f', 10);
fileStream.flush();
file.close();
qDebug() << "elements."
<< "starting with mz" << m_bins.front().startMzIn << "ending with mz"
<< m_bins.back().endMzOut;
#endif
return bins;
}

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

## decimalPlacesChanged

void pappso::MzIntegrationParams::decimalPlacesChanged | ( |  | ) |

signal

References registerJsConstructor().

Referenced by removeZeroValDataPointsChanged(), and setDecimalPlaces().

## getBinningType()

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

Definition at line 363 of file mzintegrationparams.cpp.

{
return m_binningType;
}

References m_binningType.

## getBinSizeDivisor()

int pappso::MzIntegrationParams::getBinSizeDivisor | ( |  | ) | const

Definition at line 406 of file mzintegrationparams.cpp.

{
return m_binSizeDivisor;
}

References m_binSizeDivisor.

## getBinSizeModel()

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

Definition at line 390 of file mzintegrationparams.cpp.

{
return m_binSizeModel;
}

References m_binSizeModel.

## getDecimalPlaces()

int pappso::MzIntegrationParams::getDecimalPlaces | ( |  | ) | const

Definition at line 370 of file mzintegrationparams.cpp.

{
return m_decimalPlaces;
}

References m_decimalPlaces.

## getGreatestMz()

double pappso::MzIntegrationParams::getGreatestMz | ( |  | ) | const

Definition at line 339 of file mzintegrationparams.cpp.

{
return m_greatestMz;
}

References m_greatestMz.

## getIndicativeBinSize()

double pappso::MzIntegrationParams::getIndicativeBinSize | ( |  | ) | const

Definition at line 419 of file mzintegrationparams.cpp.

{
return m_indicativeBinSize;
}

References m_indicativeBinSize.

## getSmallestMz()

double pappso::MzIntegrationParams::getSmallestMz | ( |  | ) | const

Definition at line 313 of file mzintegrationparams.cpp.

{
return m_smallestMz;
}

References m_smallestMz.

## greatestMzChanged

void pappso::MzIntegrationParams::greatestMzChanged | ( |  | ) |

signal

References binsToStringWithDeltas().

Referenced by removeZeroValDataPointsChanged(), setGreatestMz(), and updateGreatestMz().

## hasValidMzRange()

bool pappso::MzIntegrationParams::hasValidMzRange | ( |  | ) | const

Definition at line 492 of file mzintegrationparams.cpp.

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

References m_greatestMz, and m_smallestMz.

## indicativeBinSizeChanged

void pappso::MzIntegrationParams::indicativeBinSizeChanged | ( |  | ) |

signal

Referenced by removeZeroValDataPointsChanged(), and setIndicativeBinSize().

## initialize() [1/5]

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

Definition at line 242 of file mzintegrationparams.cpp.

{
setSmallestMz(other.m_smallestMz);
setGreatestMz(other.m_greatestMz);
setBinningType(other.m_binningType);
setBinSizeModel(other.m_binSizeModel);
setBinSizeDivisor(other.m_binSizeDivisor);
setDecimalPlaces(other.m_decimalPlaces);
setRemoveZeroValDataPoints(other.m_removeZeroValDataPoints);
setParent(parent);
}
pappso::MzIntegrationParams::setBinSizeModel
Q_INVOKABLE void setBinSizeModel(pappso::PrecisionPtr bin_size_model_p)
Definition mzintegrationparams.cpp:376
pappso::MzIntegrationParams::setBinSizeDivisor
Q_INVOKABLE void setBinSizeDivisor(int divisor)
Definition mzintegrationparams.cpp:396
pappso::MzIntegrationParams::setGreatestMz
Q_INVOKABLE void setGreatestMz(double value)
Definition mzintegrationparams.cpp:319
pappso::MzIntegrationParams::setSmallestMz
Q_INVOKABLE void setSmallestMz(double value)
Definition mzintegrationparams.cpp:294
pappso::MzIntegrationParams::setBinningType
Q_INVOKABLE void setBinningType(BinningType binningType)
Definition mzintegrationparams.cpp:352
pappso::MzIntegrationParams::setDecimalPlaces
Q_INVOKABLE void setDecimalPlaces(int decimal_places)
Definition mzintegrationparams.cpp:425
pappso::MzIntegrationParams::setRemoveZeroValDataPoints
Q_INVOKABLE void setRemoveZeroValDataPoints(bool removeOrNot=true)
Definition mzintegrationparams.cpp:435

References MzIntegrationParams(), m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, m_greatestMz, m_removeZeroValDataPoints, m_smallestMz, setBinningType(), setBinSizeDivisor(), setBinSizeModel(), setDecimalPlaces(), setGreatestMz(), setRemoveZeroValDataPoints(), and setSmallestMz().

## initialize() [2/5]

void pappso::MzIntegrationParams::initialize | ( | const MzIntegrationParams * | other_p,
|  | QObject * | parent = nullptr )

Definition at line 258 of file mzintegrationparams.cpp.

{
Q_ASSERT(other_p != nullptr);
initialize(*other_p, parent);
}

References MzIntegrationParams(), and initialize().

## initialize() [3/5]

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

Definition at line 140 of file mzintegrationparams.cpp.

{
// qDebug() << "Initializing MzIntegrationParams using text:" << text;
InitializationResult initialization_result = InitializationResult::DEFAULT;
if(text.isEmpty())
return initialization_result;
reset();
// Expected text: "Smallest (first) m/z:294.725158\nGreatest (last)
// m/z:2055.002453\nDecimal places:-1\nBinning type:2\nBin size model:0.05
// dalton\nBin size divisor:1\nRemove 0-val data points:1\n"
// In order to consider that the parameters were correctly read, we need
// some of the members to effectively be set from the settings values.
bool binning_type_set = false;
bool decimal_places_set = false;
bool bin_size_model_set = false;
bool bin_size_divisor_set = false;
bool remove_zero_data_points_set = false;
QStringList string_list = text.split("\n");
for(int iter = 0; iter < string_list.size(); ++iter)
{
QString iter_string = string_list.at(iter);
// qDebug() << "Iterating in string:" << iter_string;
if(iter_string.contains("Binning type:"))
{
setBinningType(
getBinningTypeFromString(iter_string.split(':').last()));
binning_type_set = true;
}
else if(iter_string.contains("Bin size model:"))
{
setBinSizeModel(
PrecisionFactory::fromString(iter_string.split(':').last()));
bin_size_model_set = true;
}
else if(iter_string.contains("Bin size divisor:"))
{
setBinSizeDivisor(iter_string.split(':').last().toInt());
bin_size_divisor_set = true;
}
else if(iter_string.contains("Decimal places:"))
{
setDecimalPlaces(iter_string.split(':').last().toInt());
decimal_places_set = true;
}
else if(iter_string.contains("Remove 0-val data points:"))
{
setRemoveZeroValDataPoints(iter_string.split(':').last().toInt());
remove_zero_data_points_set = true;
}
}
// qDebug() << "At this point the initialization is done and this"
// " MzIntegrationParams instance is: "
// << toString();
if(binning_type_set)
initialization_result |= InitializationResult::BINNING_TYPE;
if(bin_size_model_set)
initialization_result |= InitializationResult::BIN_SIZE_MODEL;
if(bin_size_divisor_set)
initialization_result |= InitializationResult::BIN_SIZE_DIVISOR;
if(decimal_places_set)
initialization_result |= InitializationResult::DECIMAL_PLACES;
if(remove_zero_data_points_set)
initialization_result |= InitializationResult::REMOVE_ZERO_DATA_POINTS;
return initialization_result;
}
pappso::MzIntegrationParams::InitializationResult
InitializationResult
Definition mzintegrationparams.h:119
pappso::MzIntegrationParams::InitializationResult::BINNING_TYPE
@ BINNING_TYPE
Definition mzintegrationparams.h:123
pappso::MzIntegrationParams::InitializationResult::DEFAULT
@ DEFAULT
Definition mzintegrationparams.h:122
pappso::MzIntegrationParams::InitializationResult::BIN_SIZE_DIVISOR
@ BIN_SIZE_DIVISOR
Definition mzintegrationparams.h:125
pappso::MzIntegrationParams::InitializationResult::DECIMAL_PLACES
@ DECIMAL_PLACES
Definition mzintegrationparams.h:126
pappso::MzIntegrationParams::InitializationResult::BIN_SIZE_MODEL
@ BIN_SIZE_MODEL
Definition mzintegrationparams.h:124
pappso::MzIntegrationParams::InitializationResult::REMOVE_ZERO_DATA_POINTS
@ REMOVE_ZERO_DATA_POINTS
Definition mzintegrationparams.h:130
pappso::MzIntegrationParams::reset
Q_INVOKABLE void reset()
Reset the instance to default values.
Definition mzintegrationparams.cpp:452
pappso::PrecisionFactory::fromString
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:80
pappso::getBinningTypeFromString
MzIntegrationParams::BinningType getBinningTypeFromString(const QString &text)
Definition mzintegrationparams.cpp:68

References BIN_SIZE_DIVISOR, BIN_SIZE_MODEL, BINNING_TYPE, DECIMAL_PLACES, DEFAULT, pappso::PrecisionFactory::fromString(), pappso::getBinningTypeFromString(), REMOVE_ZERO_DATA_POINTS, reset(), setBinningType(), setBinSizeDivisor(), setBinSizeModel(), setDecimalPlaces(), and setRemoveZeroValDataPoints().

Referenced by MzIntegrationParams(), and initialize().

## initialize() [4/5]

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 221 of file mzintegrationparams.cpp.

{
setSmallestMz(min_mz);
setGreatestMz(max_mz);
setBinningType(binning_type);
setBinSizeModel(bin_size_model);
setBinSizeDivisor(bin_size_divisor);
setDecimalPlaces(decimal_places);
setRemoveZeroValDataPoints(remove_zero_val_data_points);
setParent(parent);
}

References setBinningType(), setBinSizeDivisor(), setBinSizeModel(), setDecimalPlaces(), setGreatestMz(), setRemoveZeroValDataPoints(), and setSmallestMz().

## initialize() [5/5]

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

Definition at line 269 of file mzintegrationparams.cpp.

{
if(static_cast<bool>(
initialization_results &
pappso::MzIntegrationParams::InitializationResult::BINNING_TYPE))
setBinningType(other.m_binningType);
if(static_cast<bool>(
initialization_results &
pappso::MzIntegrationParams::InitializationResult::BIN_SIZE_MODEL))
setBinSizeModel(other.m_binSizeModel);
if(static_cast<bool>(
initialization_results &
pappso::MzIntegrationParams::InitializationResult::BIN_SIZE_DIVISOR))
setBinSizeDivisor(other.m_binSizeDivisor);
if(static_cast<bool>(
initialization_results &
pappso::MzIntegrationParams::InitializationResult::DECIMAL_PLACES))
setDecimalPlaces(other.m_decimalPlaces);
}

References MzIntegrationParams(), BIN_SIZE_DIVISOR, BIN_SIZE_MODEL, BINNING_TYPE, DECIMAL_PLACES, m_binningType, m_binSizeDivisor, m_binSizeModel, m_decimalPlaces, setBinningType(), setBinSizeDivisor(), setBinSizeModel(), and setDecimalPlaces().

## isRemoveZeroValDataPoints()

bool pappso::MzIntegrationParams::isRemoveZeroValDataPoints | ( |  | ) | const

Definition at line 445 of file mzintegrationparams.cpp.

{
return m_removeZeroValDataPoints;
}

References m_removeZeroValDataPoints.

## isValid()

bool pappso::MzIntegrationParams::isValid | ( |  | ) | const

Definition at line 466 of file mzintegrationparams.cpp.

{
int errors = 0;
if(m_binningType != MzIntegrationParams::BinningType::NONE)
{
// qDebug() << "m_smallestMz:" << m_smallestMz;
// qDebug() << "smallest is max:" << (m_smallestMz ==
// std::numeric_limits<double>::max());
errors += (m_smallestMz == std::numeric_limits<double>::max() ? 1 : 0);
// qDebug() << "m_greatestMz:" << m_greatestMz;
// qDebug() << "greatest is min:" << (m_greatestMz ==
// std::numeric_limits<double>::min());
errors += (m_greatestMz == std::numeric_limits<double>::min() ? 1 : 0);
}
if(errors)
{
qCritical() << "The m/z integration parameters are invalid.";
}
return !errors;
}

References m_binningType, m_greatestMz, m_smallestMz, and NONE.

Referenced by createArbitraryBins().

## registerJsConstructor()

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

static

Definition at line 1238 of file mzintegrationparams.cpp.

{
// qDebug() << "registerJsConstructor for MzIntegrationParams to QJSEngine.";
if(engine == nullptr)
{
qFatal() << "Cannot register class: engine is null";
}
QJSValue pappso_root_property;
QJSValue pappso_enums_property;
if(engine->globalObject().hasProperty("pappso"))
{
qDebug() << "Global object property 'pappso' already exists.";
pappso_root_property = engine->globalObject().property("pappso");
if(pappso_root_property.hasProperty("Enums"))
{
pappso_enums_property = pappso_root_property.property("Enums");
}
else
{
pappso_enums_property = engine->newObject();
pappso_root_property.setProperty("Enums", pappso_enums_property);
}
}
else
{
qDebug() << "Global object property 'pappso' not found.";
pappso_root_property = engine->newObject();
pappso_enums_property = engine->newObject();
pappso_root_property.setProperty("Enums", pappso_enums_property);
engine->globalObject().setProperty("pappso", pappso_root_property);
}
QJSValue enumObject;
// First the BinningType enum
enumObject = engine->newObject();
enumObject.setProperty(
"NONE", static_cast<int>(pappso::MzIntegrationParams::BinningType::NONE));
enumObject.setProperty(
"DATA_BASED",
static_cast<int>(pappso::MzIntegrationParams::BinningType::DATA_BASED));
enumObject.setProperty(
"ARBITRARY",
static_cast<int>(pappso::MzIntegrationParams::BinningType::ARBITRARY));
pappso_enums_property.setProperty("BinningType", enumObject);
// Second the InitializationResult enum
enumObject = engine->newObject();
enumObject.setProperty(
"DEFAULT",
static_cast<int>(
pappso::MzIntegrationParams::InitializationResult::DEFAULT));
enumObject.setProperty(
"fromSettingsBinSizeModelPartial",
static_cast<int>(pappso::MzIntegrationParams::InitializationResult::
BINNING_LOGIC_PARTIAL));
enumObject.setProperty(
"fromSettingsBinSizeModelFull",
static_cast<int>(
pappso::MzIntegrationParams::InitializationResult::BINNING_LOGIC_FULL));
enumObject.setProperty(
"fromSettingsFull",
static_cast<int>(pappso::MzIntegrationParams::InitializationResult::FULL));
pappso_enums_property.setProperty("InitializationResult", enumObject);
// Finally gegister the class meta object as a constructor for the class
QJSValue jsMetaObject =
engine->newQMetaObject(&MzIntegrationParams::staticMetaObject);
engine->globalObject().setProperty("MzIntegrationParams", jsMetaObject);
}
pappso::MzIntegrationParams::InitializationResult::BINNING_LOGIC_FULL
@ BINNING_LOGIC_FULL
Definition mzintegrationparams.h:128
pappso::MzIntegrationParams::InitializationResult::BINNING_LOGIC_PARTIAL
@ BINNING_LOGIC_PARTIAL
Definition mzintegrationparams.h:127
pappso::MzIntegrationParams::InitializationResult::FULL
@ FULL
Definition mzintegrationparams.h:131

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

Referenced by decimalPlacesChanged().

## removeZeroValDataPointsChanged

void pappso::MzIntegrationParams::removeZeroValDataPointsChanged | ( |  | ) |

signal

References binningTypeChanged(), decimalPlacesChanged(), greatestMzChanged(), indicativeBinSizeChanged(), and smallestMzChanged().

Referenced by setRemoveZeroValDataPoints().

## reset()

void pappso::MzIntegrationParams::reset | ( |  | ) |

Reset the instance to default values.

Definition at line 452 of file mzintegrationparams.cpp.

{
// Each function handles the emission of the corresponding changed
// notification.
setSmallestMz(std::numeric_limits<double>::max());
setGreatestMz(std::numeric_limits<double>::min());
setBinningType(BinningType::ARBITRARY);
setBinSizeModel(pappso::PrecisionFactory::getResInstance(40000));
setBinSizeDivisor(1);
setDecimalPlaces(-1);
setRemoveZeroValDataPoints(true);
}
pappso::PrecisionFactory::getResInstance
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
Definition precision.cpp:181

References ARBITRARY, pappso::PrecisionFactory::getResInstance(), setBinningType(), setBinSizeDivisor(), setBinSizeModel(), setDecimalPlaces(), setGreatestMz(), setRemoveZeroValDataPoints(), and setSmallestMz().

Referenced by initialize().

## setBinningType()

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

Definition at line 352 of file mzintegrationparams.cpp.

{
if(m_binningType == binning_type)
return;
m_binningType = binning_type;
emit binningTypeChanged();
}
pappso::MzIntegrationParams::binningTypeChanged
void binningTypeChanged()

References binningTypeChanged(), and m_binningType.

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

## setBinSizeDivisor()

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

Definition at line 396 of file mzintegrationparams.cpp.

{
if(m_binSizeDivisor == divisor)
return;
m_binSizeDivisor = divisor;
emit binSizeDivisorChanged();
}
pappso::MzIntegrationParams::binSizeDivisorChanged
void binSizeDivisorChanged()

References binSizeDivisorChanged(), and m_binSizeDivisor.

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

## setBinSizeModel()

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

Definition at line 376 of file mzintegrationparams.cpp.

{
if(m_binSizeModel == bin_size_model_p)
return;
m_binSizeModel = bin_size_model_p;
if(m_binSizeModel == nullptr)
m_binSizeModel = pappso::PrecisionFactory::getResInstance(40000);
emit binSizeModelChanged();
}
pappso::MzIntegrationParams::binSizeModelChanged
void binSizeModelChanged()

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

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

## setDecimalPlaces()

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

Definition at line 425 of file mzintegrationparams.cpp.

{
if(m_decimalPlaces == decimal_places)
return;
m_decimalPlaces = decimal_places;
emit decimalPlacesChanged();
}
pappso::MzIntegrationParams::decimalPlacesChanged
void decimalPlacesChanged()

References decimalPlacesChanged(), and m_decimalPlaces.

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

## setGreatestMz()

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

Definition at line 319 of file mzintegrationparams.cpp.

{
if(m_greatestMz == value)
return;
m_greatestMz = value;
emit greatestMzChanged();
}
pappso::MzIntegrationParams::greatestMzChanged
void greatestMzChanged()

References greatestMzChanged(), and m_greatestMz.

Referenced by initialize(), initialize(), reset(), and setMzValues().

## setIndicativeBinSize()

void pappso::MzIntegrationParams::setIndicativeBinSize | ( | double | value | ) |

Definition at line 412 of file mzintegrationparams.cpp.

{
m_indicativeBinSize = value;
emit indicativeBinSizeChanged();
}
pappso::MzIntegrationParams::indicativeBinSizeChanged
void indicativeBinSizeChanged()

References indicativeBinSizeChanged(), and m_indicativeBinSize.

## setMzValues()

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

Definition at line 345 of file mzintegrationparams.cpp.

{
setSmallestMz(smallest);
setGreatestMz(greatest);
}

References setGreatestMz(), and setSmallestMz().

## setRemoveZeroValDataPoints()

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

Definition at line 435 of file mzintegrationparams.cpp.

{
if(m_removeZeroValDataPoints == removeOrNot)
return;
m_removeZeroValDataPoints = removeOrNot;
emit removeZeroValDataPointsChanged();
}
pappso::MzIntegrationParams::removeZeroValDataPointsChanged
void removeZeroValDataPointsChanged()

References m_removeZeroValDataPoints, and removeZeroValDataPointsChanged().

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

## setSmallestMz()

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

Definition at line 294 of file mzintegrationparams.cpp.

{
if(m_smallestMz != value)
m_smallestMz = value;
emit smallestMzChanged();
}
pappso::MzIntegrationParams::smallestMzChanged
void smallestMzChanged()

References m_smallestMz, and smallestMzChanged().

Referenced by initialize(), initialize(), reset(), and setMzValues().

## smallestMzChanged

void pappso::MzIntegrationParams::smallestMzChanged | ( |  | ) |

signal

Referenced by removeZeroValDataPointsChanged(), setSmallestMz(), and updateSmallestMz().

## toString() [1/2]

QString pappso::MzIntegrationParams::toString | ( |  | ) | const

Definition at line 1200 of file mzintegrationparams.cpp.

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

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

## toString() [2/2]

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

Definition at line 1150 of file mzintegrationparams.cpp.

{
// The space-containing string that reflects the offset at which
// new text lines should be added to start with.
QString offset_lead;
for(int iter = 0; iter < offset; ++iter)
offset_lead += spacer;
QString text = offset_lead;
text += "m/z integration parameters:\n";
QString new_lead = QString("%1%2").arg(offset_lead, spacer);
text += new_lead;
if(m_smallestMz != std::numeric_limits<double>::max())
text.append(
QString::asprintf("Smallest (first) m/z: %.6f\n", m_smallestMz));
text += new_lead;
if(m_greatestMz != std::numeric_limits<double>::min())
text.append(QString::asprintf("Greatest (last) m/z: %.6f\n", m_greatestMz));
text += new_lead;
text += QString("Remove 0-val data points: %1\n")
.arg(m_removeZeroValDataPoints ? "true" : "false");
text += new_lead;
text.append("Binning logic:\n");
new_lead += spacer;
text += new_lead;
text.append(
QString("Binning type:%1\n").arg(::pappso::binningTypeMap[m_binningType]));
text += new_lead;
text.append(QString("Bin size model: %1\n").arg(m_binSizeModel->toString()));
text += new_lead;
text.append(QString("Bin size divisor: %2\n").arg(m_binSizeDivisor));
text += new_lead;
text.append(QString("Decimal places: %1\n").arg(m_decimalPlaces));
return text;
}

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 329 of file mzintegrationparams.cpp.

{
if(value > m_greatestMz)
{
m_greatestMz = value;
emit greatestMzChanged();
}
}

References greatestMzChanged(), and m_greatestMz.

## updateSmallestMz()

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

Definition at line 303 of file mzintegrationparams.cpp.

{
if(value == m_smallestMz)
return;
m_smallestMz = value;
emit smallestMzChanged();
}

References m_smallestMz, and smallestMzChanged().

## Member Data Documentation

## m_binningType

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

protected

Definition at line 239 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), createBins(), createBins(), getBinningType(), initialize(), initialize(), isValid(), setBinningType(), toString(), and toString().

## m_binSizeDivisor

int pappso::MzIntegrationParams::m_binSizeDivisor = 6

protected

Definition at line 253 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), createArbitraryBins(), getBinSizeDivisor(), initialize(), initialize(), setBinSizeDivisor(), toString(), and toString().

## m_binSizeModel

pappso::PrecisionPtr pappso::MzIntegrationParams::m_binSizeModel

protected

Initial value:
=
pappso::PrecisionFactory::getResInstance(40000)

Definition at line 240 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), createArbitraryBins(), getBinSizeModel(), initialize(), initialize(), setBinSizeModel(), toString(), and toString().

## m_decimalPlaces

int pappso::MzIntegrationParams::m_decimalPlaces = -1

protected

Definition at line 258 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), binsToStringWithDeltas(), clone(), createArbitraryBins(), createDataBasedBins(), createDataBasedBinsOld(), getDecimalPlaces(), initialize(), initialize(), setDecimalPlaces(), toString(), and toString().

## m_greatestMz

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

protected

Definition at line 232 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), createArbitraryBins(), createDataBasedBins(), getGreatestMz(), hasValidMzRange(), initialize(), isValid(), setGreatestMz(), toString(), and updateGreatestMz().

## m_indicativeBinSize

double pappso::MzIntegrationParams::m_indicativeBinSize = 0

protected

Definition at line 237 of file mzintegrationparams.h.

Referenced by createArbitraryBins(), getIndicativeBinSize(), and setIndicativeBinSize().

## m_removeZeroValDataPoints

bool pappso::MzIntegrationParams::m_removeZeroValDataPoints = true

protected

Definition at line 263 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), initialize(), isRemoveZeroValDataPoints(), setRemoveZeroValDataPoints(), toString(), and toString().

## m_smallestMz

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

protected

Definition at line 228 of file mzintegrationparams.h.

Referenced by MzIntegrationParams(), clone(), createArbitraryBins(), createDataBasedBins(), createDataBasedBinsOld(), getSmallestMz(), hasValidMzRange(), initialize(), isValid(), setSmallestMz(), toString(), and updateSmallestMz().

## Property Documentation

## binningType

BinningType pappso::MzIntegrationParams::binningType

read write

Definition at line 93 of file mzintegrationparams.h.

## binSizeDivisor

int pappso::MzIntegrationParams::binSizeDivisor

read write

Definition at line 97 of file mzintegrationparams.h.

## binSizeModel

pappso::PrecisionPtr pappso::MzIntegrationParams::binSizeModel

read write

Definition at line 96 of file mzintegrationparams.h.

## decimalPlaces

int pappso::MzIntegrationParams::decimalPlaces

read write

Definition at line 95 of file mzintegrationparams.h.

## greatestMz

double pappso::MzIntegrationParams::greatestMz

read write

Definition at line 92 of file mzintegrationparams.h.

## indicativeBinSize

double pappso::MzIntegrationParams::indicativeBinSize

read write

Definition at line 94 of file mzintegrationparams.h.

## removeZeroValDataPoints

bool pappso::MzIntegrationParams::removeZeroValDataPoints

read write

Definition at line 98 of file mzintegrationparams.h.

## smallestMz

double pappso::MzIntegrationParams::smallestMz

read write

Definition at line 89 of file mzintegrationparams.h.

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

- pappsomspp/core/processing/combiners/mzintegrationparams.h
- pappsomspp/core/processing/combiners/mzintegrationparams.cpp