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"
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 = QString("%1-%2-%3-%4")
54 .arg(mz_calibration_record.value("Id").toInt())
55 .arg(mz_calibration_record.value("ModelType").toInt())
56 .arg(QString::number(T1_frame, 'g', 10))
57 .arg(QString::number(T2_frame, 'g', 10));
58
59
60 auto itmap = m_mapMzCalibrationSPtr.find(mz_calibration_key);
61 if(itmap != m_mapMzCalibrationSPtr.end())
62 {
63 // qDebug() << mz_calibration_key << " calibration object found";
64 msp_mzCalibration = itmap->second;
65 }
66 else
67 {
68 if(mz_calibration_record.value("ModelType").toInt() == 1)
69 {
70 msp_mzCalibration = std::make_shared<MzCalibrationModel1>(
71 T1_frame,
72 T2_frame,
73 mz_calibration_record.value("DigitizerTimebase")
74 .toDouble(), // MzCalibration.DigitizerTimebase
75 mz_calibration_record.value("DigitizerDelay")
76 .toDouble(), // MzCalibration.DigitizerDelay
77 mz_calibration_record.value("C0").toDouble(), // MzCalibration.C0
78 mz_calibration_record.value("C1").toDouble(), // MzCalibration.C1
79 mz_calibration_record.value("C2").toDouble(), // MzCalibration.C2
80 mz_calibration_record.value("C3").toDouble(), // MzCalibration.C3
81 mz_calibration_record.value("C4").toDouble(), // MzCalibration.C4
82 mz_calibration_record.value("T1").toDouble(),
83 mz_calibration_record.value("T2").toDouble(),
84 mz_calibration_record.value("dC1").toDouble(),
85 mz_calibration_record.value("dC2").toDouble());
86 }
87 else
88 {
89 // qDebug();
90 throw PappsoException(
91 QObject::tr("ERROR in MzCalibrationStore::getInstance : MzCalibration "
92 "ModelType \"%1\" not available")
93 .arg(mz_calibration_record.value("ModelType").toInt()));
94 }
95
97 std::pair<QString, MzCalibrationInterfaceSPtr>(mz_calibration_key, msp_mzCalibration));
98 }
99
100 if(msp_mzCalibration == nullptr)
101 {
102 // qDebug();
103 throw PappsoException(
104 QObject::tr("ERROR in MzCalibrationStore::getInstance MzCalibration is NULL"));
105 }
106
107 // qDebug();
108 return (msp_mzCalibration);
109}
110
111} // namespace pappso
std::map< QString, MzCalibrationInterfaceSPtr > m_mapMzCalibrationSPtr
MzCalibrationInterfaceSPtr getInstance(double T1_frame, double T2_frame, const QSqlRecord &mzcalibration_record)
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