libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzintegrationparams.cpp
Go to the documentation of this file.
1/* BEGIN software license
2 *
3 * msXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright(C) 2009,...,2018 Filippo Rusconi
6 *
7 * http://www.msxpertsuite.org
8 *
9 * This file is part of the msXpertSuite project.
10 *
11 * The msXpertSuite project is the successor of the massXpert project. This
12 * project now includes various independent modules:
13 *
14 * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15 * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16 *
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * END software license
31 */
32
33
34/////////////////////// StdLib includes
35#include <map>
36#include <cmath>
37
38
39/////////////////////// Qt includes
40#include <QDebug>
41#include <QString>
42#include <QFile>
43#include <QDateTime>
44#include <QtQml>
45
46
47/////////////////////// pappsomspp includes
50
51
52/////////////////////// Local includes
53#include "mzintegrationparams.h"
54
55/*
56int mzIntegrationParamsMetaTypeId =
57 qRegisterMetaType<pappso::MzIntegrationParams>("pappso::MzIntegrationParams");
58int mzIntegrationParamsPtrMetaTypeId =
59 qRegisterMetaType<pappso::MzIntegrationParams *>("pappso::MzIntegrationParams *");*/
60
61
62namespace pappso
63{
64
65
66//! Map relating the BinningType to a textual representation
67std::map<MzIntegrationParams::BinningType, QString> binningTypeMap{
71
73getBinningTypeFromString(const QString &text)
74{
75 std::map<MzIntegrationParams::MzIntegrationParams::BinningType, QString>::const_iterator
76 the_iterator_const =
77 std::find_if(binningTypeMap.begin(),
78 binningTypeMap.end(),
79 [text](const std::pair<MzIntegrationParams::BinningType, QString> &pair) {
80 return pair.second == text;
81 });
82
83 if(the_iterator_const != binningTypeMap.end())
84 return the_iterator_const->first;
85
87}
88
89
90MzIntegrationParams::MzIntegrationParams(QObject *parent) : QObject(parent)
91{
92}
93
94MzIntegrationParams::MzIntegrationParams(const QString &text, QObject *parent) : QObject(parent)
95{
96 initialize(text);
97}
98
100 double max_mz,
102 pappso::PrecisionPtr bin_size_model,
103 int bin_size_divisor,
104 int decimal_places,
105 bool remove_zero_val_data_points,
106 QObject *parent)
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}
121
125
127MzIntegrationParams::clone(QObject *parent) const
128{
129 MzIntegrationParams *mz_integration_params_p = new MzIntegrationParams(m_smallestMz,
136 parent);
137
138 return mz_integration_params_p;
139}
140
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}
221
222void
224 double max_mz,
226 pappso::PrecisionPtr bin_size_model,
227 int bin_size_divisor,
228 int decimal_places,
229 bool remove_zero_val_data_points,
230 QObject *parent)
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}
242
243void
256
257// Initialize this MzIntegrationParams using other but only for members that were
258// effectively set upon reading from a text string (see initialize (QString)).
259void
261 InitializationResult initialization_results)
262{
263 if(static_cast<bool>(initialization_results &
266
267 if(static_cast<bool>(initialization_results &
270
271 if(static_cast<bool>(initialization_results &
274
275 if(static_cast<bool>(initialization_results &
278}
279
280void
282{
283 if(m_smallestMz != value)
284 m_smallestMz = value;
285
286 emit smallestMzChanged();
287}
288
289
290void
292{
293 if(value == m_smallestMz)
294 return;
295
296 m_smallestMz = value;
297 emit smallestMzChanged();
298}
299
300
301double
306
307
308void
310{
311 if(m_greatestMz == value)
312 return;
313
314 m_greatestMz = value;
315 emit greatestMzChanged();
316}
317
318
319void
321{
322 if(value > m_greatestMz)
323 {
324 m_greatestMz = value;
325 emit greatestMzChanged();
326 }
327}
328
329
330double
335
336void
337MzIntegrationParams::setMzValues(double smallest, double greatest)
338{
339 setSmallestMz(smallest);
340 setGreatestMz(greatest);
341}
342
343void
345{
346 if(m_binningType == binning_type)
347 return;
348
349 m_binningType = binning_type;
350 return binningTypeChanged();
351}
352
353
359
360
361int
366
367void
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}
378
384
385void
387{
388 if(m_binSizeDivisor == divisor)
389 return;
390
391 m_binSizeDivisor = divisor;
393}
394
395int
400
401void
403{
404 if(m_decimalPlaces == decimal_places)
405 return;
406
407 m_decimalPlaces = decimal_places;
409}
410
411void
413{
414 if(m_removeZeroValDataPoints == removeOrNot)
415 return;
416
417 m_removeZeroValDataPoints = removeOrNot;
419}
420
421
422bool
427
428
429//! Reset the instance to default values.
430void
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}
445
446
447bool
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}
472
473
474bool
476{
477 return (m_smallestMz < std::numeric_limits<double>::max()) &&
478 (m_greatestMz >= std::numeric_limits<double>::min());
479}
480
481
482std::vector<double>
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}
509
510
511std::vector<double>
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}
540
541
542std::vector<double>
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}
727
728
729std::vector<double>
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}
837
838// This is for documentation, not for outputting the string used in the
839// settings that are saved on disk.
840QString
841MzIntegrationParams::toString(int offset, const QString &spacer) const
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}
886
887// This version is used to craft the string that enables the initialization.
888QString
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}
904
905
906void
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}
944
945} // namespace pappso
Class to represent a mass spectrum.
void sortMz()
Sort the DataPoint instances of this spectrum.
The MzIntegrationParams class provides the parameters definining how m/z !
Q_INVOKABLE MzIntegrationParams(QObject *parent=nullptr)
Q_INVOKABLE void updateGreatestMz(double value)
Q_INVOKABLE InitializationResult initialize(const QString &text)
void setBinSizeModel(pappso::PrecisionPtr bin_size_model_p)
std::vector< double > createArbitraryBins()
pappso::PrecisionPtr m_binSizeModel
Q_INVOKABLE bool isValid() const
pappso::PrecisionPtr getBinSizeModel() const
Q_INVOKABLE bool hasValidMzRange() const
@ DATA_BASED
binning based on mass spectral data
@ ARBITRARY
binning based on arbitrary bin size value
static void registerJsConstructor(QJSEngine *engine)
Q_INVOKABLE void updateSmallestMz(double value)
Q_INVOKABLE MzIntegrationParams * clone(QObject *parent=nullptr) const
Q_INVOKABLE void setMzValues(double smallest, double greatest)
void setBinningType(BinningType binningType)
Q_INVOKABLE void reset()
Reset the instance to default values.
std::vector< double > createDataBasedBins(pappso::MassSpectrumCstSPtr massSpectrum)
Q_INVOKABLE QString toString() const
void setDecimalPlaces(int decimal_places)
Q_INVOKABLE std::vector< double > createBins()
void setRemoveZeroValDataPoints(bool removeOrNot=true)
static PrecisionPtr getResInstance(pappso_double value)
get a resolution precision pointer
static PrecisionPtr fromString(const QString &str)
get a precision pointer from a string
Definition precision.cpp:79
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
static int zeroDecimalsInValue(pappso_double value)
0.11 would return 0 (no empty decimal) 2.001 would return 2 1000.0001254 would return 3
Definition utils.cpp:102
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
MzIntegrationParams::BinningType getBinningTypeFromString(const QString &text)
std::map< MzIntegrationParams::BinningType, QString > binningTypeMap
Map relating the BinningType to a textual representation.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122