libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzcalibrationstore.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/vendors/tims/mzcalibration/mzcalibratiostore.cpp
3 * \date 12/11/2020
4 * \author Olivier Langella
5 * \brief store a collection of MzCalibration models
6 */
7
8
9/*******************************************************************************
10 * Copyright (c) 2020 Olivier Langella <Olivier.Langella@u-psud.fr>.
11 *
12 * This file is part of the PAPPSOms++ library.
13 *
14 * PAPPSOms++ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * PAPPSOms++ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
29#include "mzcalibrationstore.h"
30#include <QVariant>
31#include "mzcalibrationmodel1.h"
32#include "../../../pappsoexception.h"
33#include <QDebug>
34
35namespace pappso
36{
40
44
47 double T2_frame,
48 const QSqlRecord &mz_calibration_record)
49{
50 // qDebug();
51 MzCalibrationInterfaceSPtr msp_mzCalibration = nullptr;
52
53 QString mz_calibration_key =
54 QString("%1-%2-%3-%4")
55 .arg(mz_calibration_record.value("Id").toInt())
56 .arg(mz_calibration_record.value("ModelType").toInt())
57 .arg(QString::number(T1_frame, 'g', 10))
58 .arg(QString::number(T2_frame, 'g', 10));
59
60
61 auto itmap = m_mapMzCalibrationSPtr.find(mz_calibration_key);
62 if(itmap != m_mapMzCalibrationSPtr.end())
63 {
64 // qDebug() << mz_calibration_key << " calibration object found";
65 msp_mzCalibration = itmap->second;
66 }
67 else
68 {
69 if(mz_calibration_record.value("ModelType").toInt() == 1)
70 {
71 msp_mzCalibration = std::make_shared<MzCalibrationModel1>(
72 T1_frame,
73 T2_frame,
74 mz_calibration_record.value("DigitizerTimebase")
75 .toDouble(), // MzCalibration.DigitizerTimebase
76 mz_calibration_record.value("DigitizerDelay")
77 .toDouble(), // MzCalibration.DigitizerDelay
78 mz_calibration_record.value("C0").toDouble(), // MzCalibration.C0
79 mz_calibration_record.value("C1").toDouble(), // MzCalibration.C1
80 mz_calibration_record.value("C2").toDouble(), // MzCalibration.C2
81 mz_calibration_record.value("C3").toDouble(), // MzCalibration.C3
82 mz_calibration_record.value("C4").toDouble(), // MzCalibration.C4
83 mz_calibration_record.value("T1").toDouble(),
84 mz_calibration_record.value("T2").toDouble(),
85 mz_calibration_record.value("dC1").toDouble(),
86 mz_calibration_record.value("dC2").toDouble());
87 }
88 else
89 {
90 // qDebug();
91 throw PappsoException(
92 QObject::tr(
93 "ERROR in MzCalibrationStore::getInstance : MzCalibration "
94 "ModelType \"%1\" not available")
95 .arg(mz_calibration_record.value("ModelType").toInt()));
96 }
97
99 std::pair<QString, MzCalibrationInterfaceSPtr>(mz_calibration_key,
100 msp_mzCalibration));
101 }
102
103 if(msp_mzCalibration == nullptr)
104 {
105 // qDebug();
106 throw PappsoException(QObject::tr(
107 "ERROR in MzCalibrationStore::getInstance MzCalibration is NULL"));
108 }
109
110 // qDebug();
111 return (msp_mzCalibration);
112}
113
114} // namespace pappso
std::map< QString, MzCalibrationInterfaceSPtr > m_mapMzCalibrationSPtr
MzCalibrationInterfaceSPtr getInstance(double T1_frame, double T2_frame, const QSqlRecord &mzcalibration_record)
implement Bruker's model type 1 formula to compute m/z
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< MzCalibrationInterface > MzCalibrationInterfaceSPtr