libpappsomspp
Library for mass spectrometry
timsframetype1.h
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/vendors/tims/timsframetype1.h
3  * \date 3/10/2021
4  * \author Olivier Langella
5  * \brief handle a single Bruker's TimsTof frame type 1 compression
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2021 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 "timsframe.h"
31 
32 namespace pappso
33 {
34 /**
35  * @todo write docs
36  */
37 class TimsFrameType1 : public TimsFrame
38 {
39  public:
40  /**
41  * @param timsId tims frame id
42  * @param scanNum total number of scans in this frame
43  * @param p_bytes pointer on the decompressed binary buffer
44  * @param len size of the decompressed binary buffer
45  */
46  TimsFrameType1(std::size_t timsId,
47  quint32 scanNum,
48  char *p_bytes,
49  std::size_t len);
50 
51  /**
52  * Copy constructor
53  *
54  * @param other TODO
55  */
56  TimsFrameType1(const TimsFrameType1 &other);
57 
58  /**
59  * Destructor
60  */
61  virtual ~TimsFrameType1();
62 
63 
64  virtual std::size_t getNbrPeaks(std::size_t scanNum) const override;
65 
66 
67  /** @brief get raw index list for one given scan
68  * index are not TOF nor m/z, just index on digitizer
69  */
70  virtual std::vector<quint32>
71  getScanIndexList(std::size_t scanNum) const override;
72 
73  /** @brief get raw intensities without transformation from one scan
74  * it needs intensity normalization
75  */
76  virtual std::vector<quint32>
77  getScanIntensities(std::size_t scanNum) const override;
78 
79  /** @brief get the mass spectrum corresponding to a scan number
80  * @param scanNum the scan number to retrieve
81  * */
82 
84  getMassSpectrumSPtr(std::size_t scanNum) const override;
85 
86 
87  protected:
88  /** @brief cumulate a scan into a map
89  *
90  * @param scanNum scan number 0 to (m_scanNumber-1)
91  */
92  virtual void
93  cumulateScan(std::size_t scanNum,
94  std::map<quint32, quint32> &accumulate_into) const override;
95 
96 
97  /** @brief get the raw index tof_index and intensities (normalized)
98  *
99  * @param scanNum the scan number to extract
100  * @return trace vector
101  *
102  */
103  virtual pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const override;
104 
105  private:
106  /** @brief copy buffer header and lzf decompress each scan for tims
107  * compression type 1
108  * @param src raw data buffer containing scan offsets and LZF compressed scans
109  * @param len length of the data buffer
110  */
111  void copyAndLzfDecompress(const char *src, std::size_t len);
112 
113  /** @brief decompress a single LZF compressed scan buffer
114  * @param src pointer on the LZF compressed buffer
115  * @param src_len length of the source buffer
116  * @param dest pointer to the destination buffer (in the qbyte array)
117  * @param dest_len length of the destination buffer (max possible in the
118  * qbytearray)
119  * @return scan decompressed size
120  */
121  unsigned int lzfDecompressScan(const char *src,
122  unsigned int src_len,
123  char *dest,
124  unsigned int dest_len);
125 
126  private:
127  std::vector<std::size_t> m_scanOffsetList;
128  std::vector<std::size_t> m_scanSizeList;
129 };
130 } // namespace pappso
virtual std::vector< quint32 > getScanIndexList(std::size_t scanNum) const override
get raw index list for one given scan index are not TOF nor m/z, just index on digitizer
std::vector< std::size_t > m_scanSizeList
TimsFrameType1(std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
void copyAndLzfDecompress(const char *src, std::size_t len)
copy buffer header and lzf decompress each scan for tims compression type 1
virtual std::size_t getNbrPeaks(std::size_t scanNum) const override
get the number of peaks in this spectrum need the binary file
virtual void cumulateScan(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const override
cumulate a scan into a map
unsigned int lzfDecompressScan(const char *src, unsigned int src_len, char *dest, unsigned int dest_len)
decompress a single LZF compressed scan buffer
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
get the mass spectrum corresponding to a scan number
virtual std::vector< quint32 > getScanIntensities(std::size_t scanNum) const override
get raw intensities without transformation from one scan it needs intensity normalization
std::vector< std::size_t > m_scanOffsetList
virtual pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const override
get the raw index tof_index and intensities (normalized)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:135
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54
handle a single Bruker's TimsTof frame