pappsomspp
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 
36 namespace pappso
37 {
38 
39 class TimsFrame;
40 typedef std::shared_ptr<TimsFrame> TimsFrameSPtr;
41 typedef std::shared_ptr<const TimsFrame> TimsFrameCstSPtr;
42 
43 class TimsBinDec;
44 
45 struct TimsXicStructure;
46 class TimsDirectXicExtractor;
47 
48 /**
49  * @todo write docs
50  */
51 class TimsFrame : public TimsFrameBase
52 {
54 
55  public:
56  /**
57  * Default constructor
58  */
59  TimsFrame(std::size_t timsId,
60  quint32 scanNum,
61  char *p_bytes,
62  std::size_t len);
63  /**
64  * Copy constructor
65  *
66  * @param other TODO
67  */
68  TimsFrame(const TimsFrame &other);
69 
70  /**
71  * Destructor
72  */
73  ~TimsFrame();
74 
75 
76  virtual std::size_t getNbrPeaks(std::size_t scanNum) const override;
77 
78  /** @brief cumulate scan list into a trace
79  */
80  virtual Trace cumulateScanToTrace(std::size_t scanNumBegin,
81  std::size_t scanNumEnd) const override;
82 
83  /** @brief get raw index list for one given scan
84  * index are not TOF nor m/z, just index on digitizer
85  */
86  std::vector<quint32> getScanIndexList(std::size_t scanNum) const;
87 
88  /** @brief get raw intensities without transformation from one scan
89  * it needs intensity normalization
90  */
91  std::vector<quint32> getScanIntensities(std::size_t scanNum) const;
92 
93  /** @brief get the mass spectrum corresponding to a scan number
94  * @param scanNum the scan number to retrieve
95  * */
96  pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr(std::size_t scanNum) const;
98  getMassSpectrumSPtr(std::size_t scanNum) const override;
99 
100 
101  /** @brief transform accumulation of raw scans into a real mass spectrum
102  */
104  std::map<quint32, quint32> &accumulated_scans) const;
105 
106  protected:
108  std::vector<TimsXicStructure>::iterator &itXicListbegin,
109  std::vector<TimsXicStructure>::iterator &itXicListend,
110  XicExtractMethod method) const;
111 
112  private:
113  void unshufflePacket(const char *src);
114 
115  std::size_t getScanOffset(std::size_t scanNum) const;
116 
117 
118  /** @brief cumulate a scan into a map
119  */
120  void cumulateScan(std::size_t scanNum,
121  std::map<quint32, quint32> &accumulate_into) const;
122 
123 
124  private:
125  QByteArray m_timsDataFrame;
126 };
127 } // namespace pappso
pappso::TimsFrame::getScanIntensities
std::vector< quint32 > getScanIntensities(std::size_t scanNum) const
get raw intensities without transformation from one scan it needs intensity normalization
Definition: timsframe.cpp:193
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:74
pappso::TimsFrame::getTraceFromCumulatedScans
pappso::Trace getTraceFromCumulatedScans(std::map< quint32, quint32 > &accumulated_scans) const
transform accumulation of raw scans into a real mass spectrum
Definition: timsframe.cpp:305
pappso::TimsFrameSPtr
std::shared_ptr< TimsFrame > TimsFrameSPtr
Definition: timsframe.h:55
pappso
Definition: aa.cpp:38
pappso::TimsFrame::getMassSpectrumSPtr
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
Definition: timsframe.cpp:430
pappso::TimsFrame::getMassSpectrumCstSPtr
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr(std::size_t scanNum) const
get the mass spectrum corresponding to a scan number
Definition: timsframe.cpp:423
pappso::TimsFrame::TimsFrame
TimsFrame(std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
Definition: timsframe.cpp:58
pappso::TimsFrame
Definition: timsframe.h:67
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:125
pappso::XicExtractMethod
XicExtractMethod
Definition: types.h:201
pappso::TimsFrame::m_timsDataFrame
QByteArray m_timsDataFrame
Definition: timsframe.h:141
pappso::TimsFrame::unshufflePacket
void unshufflePacket(const char *src)
Definition: timsframe.cpp:99
pappso::TimsFrame::getNbrPeaks
virtual std::size_t getNbrPeaks(std::size_t scanNum) const override
Definition: timsframe.cpp:126
timsframebase.h
handle a single Bruker's TimsTof frame without binary data
pappso::TimsFrame::cumulateScanToTrace
virtual Trace cumulateScanToTrace(std::size_t scanNumBegin, std::size_t scanNumEnd) const override
cumulate scan list into a trace
Definition: timsframe.cpp:255
pappso::TimsFrame::getScanIndexList
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:168
pappso::TimsFrame::TimsDirectXicExtractor
friend TimsDirectXicExtractor
Definition: timsframe.h:69
pappso::TimsFrame::getScanOffset
std::size_t getScanOffset(std::size_t scanNum) const
Definition: timsframe.cpp:156
pappso::TimsFrame::~TimsFrame
~TimsFrame()
Definition: timsframe.cpp:93
pappso::TimsFrameCstSPtr
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition: timsframe.h:57
pappso::TimsFrame::cumulateScan
void cumulateScan(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
cumulate a scan into a map
Definition: timsframe.cpp:217
pappso::TimsFrame::extractTimsXicListInRtRange
void extractTimsXicListInRtRange(std::vector< TimsXicStructure >::iterator &itXicListbegin, std::vector< TimsXicStructure >::iterator &itXicListend, XicExtractMethod method) const
Definition: timsframe.cpp:478
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:73