libpappsomspp
Library for mass spectrometry
timsframe.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/vendors/tims/timsframe.h
3  * \date 23/08/2019
4  * \author Olivier Langella
5  * \brief handle a single Bruker's TimsTof frame
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 <QByteArray>
32 #include <vector>
33 #include "../../massspectrum/qualifiedmassspectrum.h"
34 #include "timsframebase.h"
35 #include "../../xic/xic.h"
36 
37 namespace pappso
38 {
39 
40 class TimsFrame;
41 typedef std::shared_ptr<TimsFrame> TimsFrameSPtr;
42 typedef std::shared_ptr<const TimsFrame> TimsFrameCstSPtr;
43 
44 class TimsBinDec;
45 
46 struct TimsXicStructure;
48 
49 /**
50  * @todo write docs
51  */
52 class TimsFrame : public TimsFrameBase
53 {
55 
56  public:
57  /**
58  * Default constructor
59  */
60  TimsFrame(std::size_t timsId,
61  quint32 scanNum,
62  char *p_bytes,
63  std::size_t len);
64  /**
65  * Copy constructor
66  *
67  * @param other TODO
68  */
69  TimsFrame(const TimsFrame &other);
70 
71  /**
72  * Destructor
73  */
74  ~TimsFrame();
75 
76 
77  virtual std::size_t getNbrPeaks(std::size_t scanNum) const override;
78 
79  /** @brief cumulate scan list into a trace
80  * @param scanNumBegin first scan to cumulate
81  * @param scanNumEnd last scan to cumulate
82  * @return Trace mz and intensity values
83  */
84  virtual Trace cumulateScanToTrace(std::size_t scanNumBegin,
85  std::size_t scanNumEnd) const override;
86 
87  /** @brief cumulate scan list into a trace into a raw spectrum map
88  * @param rawSpectrum simple map of integers to cumulate raw counts
89  * @param scanNumBegin first scan to cumulate
90  * @param scanNumEnd last scan to cumulate
91  */
92  virtual void cumulateScansInRawMap(std::map<quint32, quint32> &rawSpectrum,
93  std::size_t scanNumBegin,
94  std::size_t scanNumEnd) const override;
95 
96  /** @brief cumulate a scan list into a map of integers
97  * @param scanNumBegin first scan to cumulate
98  * @param scanNumEnd last scan to cumulate
99  * @param accumulate_into map of x and y integer values
100  */
101  void cumulateScans(std::size_t scanNumBegin,
102  std::size_t scanNumEnd,
103  std::map<quint32, quint32> &accumulate_into) const;
104 
105  /** @brief get raw index list for one given scan
106  * index are not TOF nor m/z, just index on digitizer
107  */
108  std::vector<quint32> getScanIndexList(std::size_t scanNum) const;
109 
110  /** @brief get raw intensities without transformation from one scan
111  * it needs intensity normalization
112  */
113  std::vector<quint32> getScanIntensities(std::size_t scanNum) const;
114 
115  /** @brief get the mass spectrum corresponding to a scan number
116  * @param scanNum the scan number to retrieve
117  * */
118  pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr(std::size_t scanNum) const;
120  getMassSpectrumSPtr(std::size_t scanNum) const override;
121 
122 
123  protected:
125  std::vector<TimsXicStructure>::iterator &itXicListbegin,
126  std::vector<TimsXicStructure>::iterator &itXicListend,
127  XicExtractMethod method) const;
128 
129  private:
130  void unshufflePacket(const char *src);
131 
132  std::size_t getScanOffset(std::size_t scanNum) const;
133 
134 
135  /** @brief cumulate a scan into a map
136  */
137  void cumulateScan(std::size_t scanNum,
138  std::map<quint32, quint32> &accumulate_into) const;
139 
140  pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const;
141 
142  private:
144  {
145  XicComputeStructure(const TimsFrame *fram_p,
146  const TimsXicStructure &xic_struct);
147 
148 
149  Xic *xic_ptr = nullptr;
150  std::size_t mobilityIndexBegin;
151  std::size_t mobilityIndexEnd;
152  std::size_t mzIndexLowerBound;
153  std::size_t mzIndexUpperBound;
154  double tmpIntensity = 0;
155  };
156 
157  private:
158  QByteArray m_timsDataFrame;
159 };
160 } // namespace pappso
QByteArray m_timsDataFrame
Definition: timsframe.h:158
virtual std::size_t getNbrPeaks(std::size_t scanNum) const override
Definition: timsframe.cpp:125
void cumulateScan(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
cumulate a scan into a map
Definition: timsframe.cpp:216
TimsFrame(std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
Definition: timsframe.cpp:57
friend TimsDirectXicExtractor
Definition: timsframe.h:54
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
Definition: timsframe.cpp:351
void extractTimsXicListInRtRange(std::vector< TimsXicStructure >::iterator &itXicListbegin, std::vector< TimsXicStructure >::iterator &itXicListend, XicExtractMethod method) const
Definition: timsframe.cpp:404
void unshufflePacket(const char *src)
Definition: timsframe.cpp:98
std::size_t getScanOffset(std::size_t scanNum) const
Definition: timsframe.cpp:155
virtual void cumulateScansInRawMap(std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const override
cumulate scan list into a trace into a raw spectrum map
Definition: timsframe.cpp:310
virtual Trace cumulateScanToTrace(std::size_t scanNumBegin, std::size_t scanNumEnd) const override
cumulate scan list into a trace
Definition: timsframe.cpp:254
std::vector< quint32 > getScanIndexList(std::size_t scanNum) const
get raw index list for one given scan index are not TOF nor m/z, just index on digitizer
Definition: timsframe.cpp:167
void cumulateScans(std::size_t scanNumBegin, std::size_t scanNumEnd, std::map< quint32, quint32 > &accumulate_into) const
cumulate a scan list into a map of integers
std::vector< quint32 > getScanIntensities(std::size_t scanNum) const
get raw intensities without transformation from one scan it needs intensity normalization
Definition: timsframe.cpp:192
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr(std::size_t scanNum) const
get the mass spectrum corresponding to a scan number
Definition: timsframe.cpp:344
pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const
Definition: timsframe.cpp:496
A simple container of DataPoint instances.
Definition: trace.h:132
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< TimsFrame > TimsFrameSPtr
Definition: timsframe.h:40
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:119
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:55
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54
XicExtractMethod
Definition: types.h:200
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition: timsframe.h:42
XicComputeStructure(const TimsFrame *fram_p, const TimsXicStructure &xic_struct)
Definition: timsframe.cpp:41
structure needed to extract XIC from Tims data
Definition: timsdata.h:49
handle a single Bruker's TimsTof frame without binary data