libpappsomspp
Library for mass spectrometry
timsframebase.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/vendors/tims/timsframebase.h
3  * \date 16/12/2019
4  * \author Olivier Langella
5  * \brief handle a single Bruker's TimsTof frame without binary data
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
10  *
11  * This file is part of the PAPPSOms++ library.
12  *
13  * PAPPSOms++ is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * PAPPSOms++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25  *
26  ******************************************************************************/
27 
28 #pragma once
29 
30 #include <memory>
31 #include <vector>
32 #include <QtGlobal>
33 #include "../../massspectrum/massspectrum.h"
34 
35 namespace pappso
36 {
37 
38 class TimsFrameBase;
39 typedef std::shared_ptr<TimsFrameBase> TimsFrameBaseSPtr;
40 typedef std::shared_ptr<const TimsFrameBase> TimsFrameBaseCstSPtr;
41 
42 
43 /**
44  * @todo write docs
45  */
47 {
48  public:
49  /** @brief constructor for binary independant tims frame
50  * @param timsId tims frame identifier in the database
51  * @param scanNum the total number of scans contained in this frame
52  */
53  TimsFrameBase(std::size_t timsId, quint32 scanNum);
54  /**
55  * Copy constructor
56  *
57  * @param other TODO
58  */
60 
61  /**
62  * Destructor
63  */
65 
66 
67  virtual std::size_t getNbrPeaks(std::size_t scanNum) const;
68  virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const;
69  virtual Trace cumulateScanToTrace(std::size_t scanNumBegin,
70  std::size_t scanNumEnd) const;
71 
72  bool checkScanNum(std::size_t scanNum) const;
73 
74 
75  void setAccumulationTime(double accumulation_time_ms);
76  void setMzCalibration(double temperature_correction,
77  double digitizerTimebase,
78  double digitizerDelay,
79  double C0,
80  double C1,
81  double C2,
82  double C3);
83  void setTimsCalibration(int tims_model_type,
84  double C0,
85  double C1,
86  double C2,
87  double C3,
88  double C4,
89  double C5,
90  double C6,
91  double C7,
92  double C8,
93  double C9);
94  void setTime(double time);
95  void setMsMsType(quint8 type);
96  unsigned int getMsLevel() const;
97  double getTime() const;
98 
99  std::size_t getId() const;
100 
101  /** @brief get drift time of a scan number in milliseconds
102  * @param scanNum the scan number
103  * @return time in milliseconds of mobility delay (drift time)
104  * */
105  double getDriftTime(std::size_t scanNum) const;
106 
107  /** @brief get 1/K0 value of a given scan (mobility value)
108  * @param scanNum the scan number
109  * */
110  double getOneOverK0Transformation(std::size_t scanNum) const;
111 
112 
113  /** @brief get m/z from time of flight
114  * @param tof time of flight
115  * @return m/z value
116  */
117  double getMzFromTof(double tof) const;
118 
119  /** @brief get raw index of a given m/z
120  * @param mz the mass to transform
121  * @return integer x raw value
122  */
123  quint32 getRawIndexFromMz(double mz) const;
124 
125  /** @brief get the scan number from a given 1/Ko mobility value
126  * @param one_over_k0 the mobility value to tranform
127  * @return integer the scan number
128  */
129  std::size_t getScanNumFromOneOverK0(double one_over_k0) const;
130 
131 
132  double getVoltageTransformation(std::size_t scanNum) const;
133 
134  /** @brief get time of flight from raw index
135  * @param index digitizer x raw value
136  * @return tof time of flight
137  */
138  double getTofFromIndex(quint32 index) const;
139 
140  /** @brief get time of flight from double index
141  */
142  double getTofFromIndex(double index) const;
143 
144 
145  protected:
146  /** @brief total number of scans contained in this frame
147  */
148  quint32 m_scanNumber;
149 
150  /** @brief Tims frame database id (the SQL identifier of this frame)
151  * @warning in sqlite, there is another field called TimsId : this is not
152  * that, because it is in fact an offset in bytes in the binary file.
153  * */
154  std::size_t m_timsId;
155 
156  /** @brief accumulation time in milliseconds
157  */
158  double m_accumulationTime = 0;
159 
161  double m_digitizerDelay = 0;
162 
163  /** @brief MZ calibration parameters
164  */
165  std::vector<double> m_mzCalibrationArr;
166 
167  quint8 m_msMsType = 0;
168 
169  /** @brief retention time
170  */
171  double m_time = 0;
172 
173  double m_timsDvStart = 0; // C2 from TimsCalibration
174  double m_timsSlope =
175  0; // (dv_end - dv_start) / ncycles //C3 from TimsCalibration // C2 from
176  // TimsCalibration // C1 from TimsCalibration
177  double m_timsTtrans = 0; // C4 from TimsCalibration
178  double m_timsNdelay = 0; // C0 from TimsCalibration
179  double m_timsVmin = 0; // C8 from TimsCalibration
180  double m_timsVmax = 0; // C9 from TimsCalibration
181  double m_timsC6 = 0;
182  double m_timsC7 = 0;
183 };
184 } // namespace pappso
pappso::TimsFrameBase::m_digitizerTimebase
double m_digitizerTimebase
Definition: timsframebase.h:160
pappso::TimsFrameBase::checkScanNum
bool checkScanNum(std::size_t scanNum) const
Definition: timsframebase.cpp:84
pappso::TimsFrameBase::m_timsId
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
Definition: timsframebase.h:154
pappso::TimsFrameBase::setTimsCalibration
void setTimsCalibration(int tims_model_type, double C0, double C1, double C2, double C3, double C4, double C5, double C6, double C7, double C8, double C9)
Definition: timsframebase.cpp:303
pappso::TimsFrameBase::getMsLevel
unsigned int getMsLevel() const
Definition: timsframebase.cpp:284
pappso::TimsFrameBase::cumulateScanToTrace
virtual Trace cumulateScanToTrace(std::size_t scanNumBegin, std::size_t scanNumEnd) const
Definition: timsframebase.cpp:114
pappso::TimsFrameBase
Definition: timsframebase.h:47
pappso::TimsFrameBase::m_timsSlope
double m_timsSlope
Definition: timsframebase.h:174
pappso::TimsFrameBase::m_timsC7
double m_timsC7
Definition: timsframebase.h:182
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
pappso::TimsFrameBase::setAccumulationTime
void setAccumulationTime(double accumulation_time_ms)
Definition: timsframebase.cpp:54
pappso::TimsFrameBase::setMzCalibration
void setMzCalibration(double temperature_correction, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3)
Definition: timsframebase.cpp:61
pappso::TimsFrameBaseCstSPtr
std::shared_ptr< const TimsFrameBase > TimsFrameBaseCstSPtr
Definition: timsframebase.h:40
pappso::TimsFrameBase::setTime
void setTime(double time)
Definition: timsframebase.cpp:270
pappso::TimsFrameBase::TimsFrameBase
TimsFrameBase(const TimsFrameBase &other)
pappso::TimsFrameBase::getNbrPeaks
virtual std::size_t getNbrPeaks(std::size_t scanNum) const
Definition: timsframebase.cpp:97
pappso::TimsFrameBase::getRawIndexFromMz
quint32 getRawIndexFromMz(double mz) const
get raw index of a given m/z
Definition: timsframebase.cpp:244
pappso::TimsFrameBase::getDriftTime
double getDriftTime(std::size_t scanNum) const
get drift time of a scan number in milliseconds
Definition: timsframebase.cpp:356
pappso::TimsFrameBase::m_accumulationTime
double m_accumulationTime
accumulation time in milliseconds
Definition: timsframebase.h:158
pappso::TimsFrameBase::m_time
double m_time
retention time
Definition: timsframebase.h:171
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::TimsFrameBase::getVoltageTransformation
double getVoltageTransformation(std::size_t scanNum) const
Definition: timsframebase.cpp:334
pappso::TimsFrameBase::getId
std::size_t getId() const
Definition: timsframebase.cpp:298
pappso::TimsFrameBase::m_timsDvStart
double m_timsDvStart
Definition: timsframebase.h:173
pappso::TimsFrameBase::getMassSpectrumSPtr
virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const
Definition: timsframebase.cpp:106
pappso::TimsFrameBase::getScanNumFromOneOverK0
std::size_t getScanNumFromOneOverK0(double one_over_k0) const
get the scan number from a given 1/Ko mobility value
Definition: timsframebase.cpp:369
pappso::TimsFrameBaseSPtr
std::shared_ptr< TimsFrameBase > TimsFrameBaseSPtr
Definition: timsframebase.h:38
pappso::TimsFrameBase::~TimsFrameBase
~TimsFrameBase()
Definition: timsframebase.cpp:49
pappso::TimsFrameBase::TimsFrameBase
TimsFrameBase(std::size_t timsId, quint32 scanNum)
constructor for binary independant tims frame
Definition: timsframebase.cpp:37
pappso::TimsFrameBase::setMsMsType
void setMsMsType(quint8 type)
Definition: timsframebase.cpp:276
pappso::TimsFrameBase::m_timsNdelay
double m_timsNdelay
Definition: timsframebase.h:178
pappso::TimsFrameBase::m_timsVmin
double m_timsVmin
Definition: timsframebase.h:179
pappso::TimsFrameBase::getOneOverK0Transformation
double getOneOverK0Transformation(std::size_t scanNum) const
get 1/K0 value of a given scan (mobility value)
Definition: timsframebase.cpp:362
pappso::TimsFrameBase::getMzFromTof
double getMzFromTof(double tof) const
get m/z from time of flight
Definition: timsframebase.cpp:136
pappso::TimsFrameBase::m_scanNumber
quint32 m_scanNumber
total number of scans contained in this frame
Definition: timsframebase.h:148
pappso::TimsFrameBase::m_timsC6
double m_timsC6
Definition: timsframebase.h:181
pappso::TimsFrameBase::getTofFromIndex
double getTofFromIndex(quint32 index) const
get time of flight from raw index
Definition: timsframebase.cpp:130
pappso::TimsFrameBase::m_digitizerDelay
double m_digitizerDelay
Definition: timsframebase.h:161
pappso::TimsFrameBase::m_mzCalibrationArr
std::vector< double > m_mzCalibrationArr
MZ calibration parameters.
Definition: timsframebase.h:165
pappso::TimsFrameBase::m_msMsType
quint8 m_msMsType
Definition: timsframebase.h:167
pappso::TimsFrameBase::m_timsVmax
double m_timsVmax
Definition: timsframebase.h:180
pappso::TimsFrameBase::m_timsTtrans
double m_timsTtrans
Definition: timsframebase.h:177
pappso::TimsFrameBase::getTime
double getTime() const
Definition: timsframebase.cpp:292
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54