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"
35 
36 namespace pappso
37 {
38 
39 class TimsFrameBase;
40 typedef std::shared_ptr<TimsFrameBase> TimsFrameBaseSPtr;
41 typedef std::shared_ptr<const TimsFrameBase> TimsFrameBaseCstSPtr;
42 
43 
44 /**
45  * @todo write docs
46  */
48 {
49  public:
50  /** @brief constructor for binary independant tims frame
51  * @param timsId tims frame identifier in the database
52  * @param scanNum the total number of scans contained in this frame
53  */
54  TimsFrameBase(std::size_t timsId, quint32 scanNum);
55  /**
56  * Copy constructor
57  *
58  * @param other TODO
59  */
61 
62  /**
63  * Destructor
64  */
66 
67  /** @brief tells if 2 tims frame has the same calibration data
68  * Usefull to know if raw data can be handled between frames
69  */
70  virtual bool hasSameCalibrationData(const TimsFrameBase &other) const;
71 
72  virtual std::size_t getNbrPeaks(std::size_t scanNum) const;
73  virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const;
74  virtual Trace cumulateScanToTrace(std::size_t scanNumBegin,
75  std::size_t scanNumEnd) const;
76 
77 
78  /** @brief cumulate scan list into a trace into a raw spectrum map
79  * @param rawSpectrum simple map of integers to cumulate raw counts
80  * @param scanNumBegin first scan to cumulate
81  * @param scanNumEnd last scan to cumulate
82  */
83  virtual void cumulateScansInRawMap(std::map<quint32, quint32> &rawSpectrum,
84  std::size_t scanNumBegin,
85  std::size_t scanNumEnd) const;
86 
87  bool checkScanNum(std::size_t scanNum) const;
88 
89 
90  void setAccumulationTime(double accumulation_time_ms);
91  void setMzCalibration(double T1_frame,
92  double T2_frame,
93  double digitizerTimebase,
94  double digitizerDelay,
95  double C0,
96  double C1,
97  double C2,
98  double C3,
99  double C4,
100  double T1_ref,
101  double T2_ref,
102  double dC1,
103  double dC2);
104  void setTimsCalibration(int tims_model_type,
105  double C0,
106  double C1,
107  double C2,
108  double C3,
109  double C4,
110  double C5,
111  double C6,
112  double C7,
113  double C8,
114  double C9);
115  void setTime(double time);
116  void setMsMsType(quint8 type);
117  unsigned int getMsLevel() const;
118  double getTime() const;
119 
120  std::size_t getId() const;
121 
122  /** @brief get drift time of a scan number in milliseconds
123  * @param scanNum the scan number
124  * @return time in milliseconds of mobility delay (drift time)
125  * */
126  double getDriftTime(std::size_t scanNum) const;
127 
128  /** @brief get 1/K0 value of a given scan (mobility value)
129  * @param scanNum the scan number
130  * */
131  double getOneOverK0Transformation(std::size_t scanNum) const;
132 
133 
134  /** @brief get the scan number from a given 1/Ko mobility value
135  * @param one_over_k0 the mobility value to tranform
136  * @return integer the scan number
137  */
138  std::size_t getScanNumFromOneOverK0(double one_over_k0) const;
139 
140 
141  double getVoltageTransformation(std::size_t scanNum) const;
142 
143 
144  /** @brief transform accumulation of raw scans into a real mass spectrum
145  */
147  std::map<quint32, quint32> &accumulated_scans) const;
148 
149  /** @brief transform accumulation of raw scans into a real mass spectrum with
150  * a simple centroid on raw integers
151  */
153  std::map<quint32, quint32> &accumulated_scans) const;
154 
155  /** @brief get the MzCalibration model to compute mz and TOF for this frame
156  */
157  virtual const MzCalibrationInterfaceSPtr &
158  getMzCalibrationInterfaceSPtr() const final;
159 
161 
162  protected:
163  /** @brief total number of scans contained in this frame
164  */
165  quint32 m_scanNumber;
166 
167  /** @brief Tims frame database id (the SQL identifier of this frame)
168  * @warning in sqlite, there is another field called TimsId : this is not
169  * that, because it is in fact an offset in bytes in the binary file.
170  * */
171  std::size_t m_timsId;
172 
173  /** @brief accumulation time in milliseconds
174  */
175  double m_accumulationTime = 0;
176 
177  quint8 m_msMsType = 0;
178 
179  /** @brief retention time
180  */
181  double m_time = 0;
182 
183  double m_timsDvStart = 0; // C2 from TimsCalibration
184  double m_timsSlope =
185  0; // (dv_end - dv_start) / ncycles //C3 from TimsCalibration // C2 from
186  // TimsCalibration // C1 from TimsCalibration
187  double m_timsTtrans = 0; // C4 from TimsCalibration
188  double m_timsNdelay = 0; // C0 from TimsCalibration
189  double m_timsVmin = 0; // C8 from TimsCalibration
190  double m_timsVmax = 0; // C9 from TimsCalibration
191  double m_timsC6 = 0;
192  double m_timsC7 = 0;
193 
195 };
196 } // namespace pappso
double m_accumulationTime
accumulation time in milliseconds
TimsFrameBase(const TimsFrameBase &other)
double getTime() const
double getVoltageTransformation(std::size_t scanNum) const
virtual Trace cumulateScanToTrace(std::size_t scanNumBegin, std::size_t scanNumEnd) const
virtual std::size_t getNbrPeaks(std::size_t scanNum) const
MzCalibrationInterfaceSPtr msp_mzCalibration
virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const
TimsFrameBase(std::size_t timsId, quint32 scanNum)
constructor for binary independant tims frame
double getDriftTime(std::size_t scanNum) const
get drift time of a scan number in milliseconds
pappso::Trace getTraceFromCumulatedScansBuiltinCentroid(std::map< quint32, quint32 > &accumulated_scans) const
transform accumulation of raw scans into a real mass spectrum with a simple centroid on raw integers
double m_time
retention time
void setAccumulationTime(double accumulation_time_ms)
quint32 m_scanNumber
total number of scans contained in this frame
virtual void cumulateScansInRawMap(std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const
cumulate scan list into a trace into a raw spectrum map
void setTime(double time)
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
pappso::Trace getTraceFromCumulatedScans(std::map< quint32, quint32 > &accumulated_scans) const
transform accumulation of raw scans into a real mass spectrum
virtual bool hasSameCalibrationData(const TimsFrameBase &other) const
tells if 2 tims frame has the same calibration data Usefull to know if raw data can be handled betwee...
unsigned int getMsLevel() const
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)
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
std::size_t getScanNumFromOneOverK0(double one_over_k0) const
get the scan number from a given 1/Ko mobility value
void setMsMsType(quint8 type)
void setMzCalibration(double T1_frame, double T2_frame, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3, double C4, double T1_ref, double T2_ref, double dC1, double dC2)
double getOneOverK0Transformation(std::size_t scanNum) const
get 1/K0 value of a given scan (mobility value)
bool checkScanNum(std::size_t scanNum) const
void setMzCalibrationInterfaceSPtr(MzCalibrationInterfaceSPtr mzCalibration)
std::size_t getId() const
A simple container of DataPoint instances.
Definition: trace.h:132
handles different ways to compute m/z using calibration parameters
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const TimsFrameBase > TimsFrameBaseCstSPtr
Definition: timsframebase.h:41
std::shared_ptr< TimsFrameBase > TimsFrameBaseSPtr
Definition: timsframebase.h:39
std::shared_ptr< MzCalibrationInterface > MzCalibrationInterfaceSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54