30 #include "../../../pappsomspp/pappsoexception.h"
31 #include "../../../pappsomspp/exception/exceptionoutofrange.h"
32 #include "../../../pappsomspp/exception/exceptionnotimplemented.h"
34 #include <liblzf/lzf.h>
49 if(p_bytes !=
nullptr)
62 "TimsFrameType1::TimsFrameType1(%1,%2,nullptr,%3) FAILED")
83 qDebug() <<
" m_scanNumber=" <<
m_scanNumber <<
" len=" << len;
88 qDebug() <<
" count=" << count;
106 qDebug() <<
"offset begin at last :" << count + 4;
110 std::size_t previous_offset = (*(quint32 *)(src));
111 qDebug() <<
"first offset= " << previous_offset;
112 std::size_t cumul_decompressed_size = 0;
117 offset = (*(quint32 *)(src + (i * 4)));
119 std::size_t compressed_size = offset - previous_offset;
121 qDebug() <<
"scan i=" << i <<
" previous_offset=" << previous_offset
122 <<
" offset=" << offset <<
" length=" << compressed_size;
126 if(cumul_decompressed_size < remaining_size)
128 remaining_size = remaining_size - cumul_decompressed_size;
134 qDebug() <<
" remaining_size=" << remaining_size;
135 std::size_t decompressed_size =
144 cumul_decompressed_size += decompressed_size;
145 qDebug() <<
" decompressed_size=" << decompressed_size;
148 previous_offset = offset;
169 unsigned int src_len,
171 unsigned int dest_len)
173 qDebug() <<
"src=" << src <<
" src_len=" << src_len
174 <<
" dest_len=" << dest_len;
177 unsigned int decompressed_size;
178 unsigned int more_space = src_len * 2;
179 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
180 while(decompressed_size == 0)
182 qDebug() <<
"dest_len=" << dest_len;
183 qDebug() <<
"decompressed_size=" << decompressed_size;
188 QObject::tr(
"ERROR reading TimsFrameType1 %1 TIMS binary file %2: "
189 "LZF decompression error EINVAL")
192 else if(errno == E2BIG)
195 <<
" more_space=" << more_space;
197 dest_len += more_space;
199 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
206 return decompressed_size;
213 return mass_spectrum_sptr.get()->size();
219 std::map<quint32, quint32> &accumulate_into)
const
232 qint32 tof_index = 0;
233 for(std::size_t i = 0; i < size; i++)
240 tof_index += -1 * value;
245 quint32
x = tof_index;
248 auto ret = accumulate_into.insert(std::pair<quint32, quint32>(
x,
y));
250 if(ret.second ==
false)
253 ret.first->second +=
y;
283 qDebug() <<
" scanNum=" << scanNum;
292 std::make_shared<pappso::MassSpectrum>();
296 return mass_spectrum_sptr;
303 qDebug() <<
" offset=" << offset <<
" size=" << size;
305 return mass_spectrum_sptr;
313 qint32 tof_index = 0;
316 for(std::size_t i = 0; i < size; i++)
322 tof_index += -1 * value;
326 data_point.
y = value;
334 mass_spectrum_sptr.get()->push_back(data_point);
340 qDebug() << mass_spectrum_sptr.get()->toString();
341 return mass_spectrum_sptr;
346 QObject::tr(
"Error TimsFrameType1::getMassSpectrumSPtr frameId=%1 "
350 .arg(error.
qwhat()));
372 qDebug() <<
" offset=" << offset <<
" size=" << size;
378 qint32 tof_index = 0;
382 for(std::size_t i = 0; i < size; i++)
388 tof_index += -1 * value;
392 data_point.
y = value;
399 data_point.
x = tof_index;
400 trace_sptr.get()->push_back(data_point);
virtual double getMzFromTofIndex(quint32 tof_index)=0
get m/z from time of flight raw index
virtual const QString & qwhat() const
double m_accumulationTime
accumulation time in milliseconds
quint32 m_scanNumber
total number of scans contained in this frame
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
std::size_t getId() const
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)
QByteArray m_timsDataFrame
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< Trace > TraceSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
handle a single Bruker's TimsTof frame type 1 compression