35#include <liblzf/lzf.h>
50 if(p_bytes !=
nullptr)
63 "TimsFrameType1::TimsFrameType1(%1,%2,nullptr,%3) FAILED")
84 qDebug() <<
" m_scanNumber=" <<
m_scanCount <<
" len=" << len;
89 qDebug() <<
" count=" << count;
92 qDebug() <<
" m_timsDataFrame.size()=" <<
m_binaryData.size();
107 qDebug() <<
"offset begin at last :" << count + 4;
111 std::size_t previous_offset = (*(quint32 *)(src));
112 qDebug() <<
"first offset= " << previous_offset;
113 std::size_t cumul_decompressed_size = 0;
118 offset = (*(quint32 *)(src + (i * 4)));
120 std::size_t compressed_size = offset - previous_offset;
122 qDebug() <<
"scan i=" << i <<
" previous_offset=" << previous_offset
123 <<
" offset=" << offset <<
" length=" << compressed_size;
127 if(cumul_decompressed_size < remaining_size)
129 remaining_size = remaining_size - cumul_decompressed_size;
135 qDebug() <<
" remaining_size=" << remaining_size;
136 std::size_t decompressed_size =
145 cumul_decompressed_size += decompressed_size;
146 qDebug() <<
" decompressed_size=" << decompressed_size;
149 previous_offset = offset;
170 unsigned int src_len,
172 unsigned int dest_len)
174 qDebug() <<
"src=" << src <<
" src_len=" << src_len
175 <<
" dest_len=" << dest_len;
178 unsigned int decompressed_size;
179 unsigned int more_space = src_len * 2;
180 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
181 while(decompressed_size == 0)
183 qDebug() <<
"dest_len=" << dest_len;
184 qDebug() <<
"decompressed_size=" << decompressed_size;
189 QObject::tr(
"ERROR reading TimsFrameType1 %1 TIMS binary file %2: "
190 "LZF decompression error EINVAL")
193 else if(errno == E2BIG)
195 qDebug() <<
" m_timsDataFrame.size()=" <<
m_binaryData.size()
196 <<
" more_space=" << more_space;
198 dest_len += more_space;
200 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
207 return decompressed_size;
214 return mass_spectrum_sptr.get()->size();
233 qint32 tof_index = 0;
234 for(std::size_t i = 0; i < size; i++)
236 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
241 tof_index += -1 * value;
246 quint32
x = tof_index;
261 quint32 accepted_tof_index_range_begin,
262 quint32 accepted_tof_index_range_end)
const
275 qint32 tof_index = 0;
276 for(std::size_t i = 0; i < size; i++)
278 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
283 tof_index += -1 * value;
288 quint32
x = tof_index;
292 if(
x < accepted_tof_index_range_begin)
297 if(
x > accepted_tof_index_range_end)
315 std::vector<quint32> mzindex_values;
323 return mzindex_values;
330 qDebug() <<
" offset=" << offset <<
" size=" << size;
332 return mzindex_values;
335 qint32 tof_index = 0;
337 for(std::size_t i = 0; i < size; i++)
339 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
343 tof_index += -1 * value;
347 mzindex_values.push_back(tof_index);
354 return mzindex_values;
363 .arg(error.
qwhat()));
373 qDebug() <<
" scanNum=" << scanNum;
377 std::vector<quint32> int_values;
392 qDebug() <<
" offset=" << offset <<
" size=" << size;
397 qint32 tof_index = 0;
399 for(std::size_t i = 0; i < size; i++)
401 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
405 tof_index += -1 * value;
409 int_values.push_back(value);
425 .arg(error.
qwhat()));
433 qDebug() <<
" scanNum=" << scanNum;
442 std::make_shared<pappso::MassSpectrum>();
446 return mass_spectrum_sptr;
453 qDebug() <<
" offset=" << offset <<
" size=" << size;
455 return mass_spectrum_sptr;
463 qint32 tof_index = 0;
466 for(std::size_t i = 0; i < size; i++)
468 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
472 tof_index += -1 * value;
476 data_point.
y = value;
484 mass_spectrum_sptr.get()->push_back(data_point);
490 qDebug() << mass_spectrum_sptr.get()->toString();
491 return mass_spectrum_sptr;
496 QObject::tr(
"Error TimsFrameType1::getMassSpectrumSPtr frameId=%1 "
500 .arg(error.
qwhat()));
522 qDebug() <<
" offset=" << offset <<
" size=" << size;
528 qint32 tof_index = 0;
532 for(std::size_t i = 0; i < size; i++)
534 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
538 tof_index += -1 * value;
542 data_point.
y = value;
549 data_point.
x = tof_index;
550 trace_sptr.get()->push_back(data_point);
561std::vector<TimsFrameType1::TofIndexIntensityPair>
563 quint32 accepted_tof_index_range_begin,
564 quint32 accepted_tof_index_range_end)
const
569 std::vector<TimsFrame::TofIndexIntensityPair> trace_sptr;
580 qDebug() <<
" offset=" << offset <<
" size=" << size;
586 qint32 tof_index = 0;
590 for(std::size_t i = 0; i < size; i++)
592 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
596 tof_index += -1 * value;
617 trace_sptr.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
std::size_t accumulateIntensity(quint32 tofIndex, std::size_t intensity)
accumulates intesity for the given tof index
double m_acqDurationInMilliseconds
acquisition duration in milliseconds
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
quint32 m_scanCount
total number of scans contained in this frame
std::size_t m_frameId
Tims frame database id (the SQL identifier of this frame)
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
std::size_t getId() const
virtual void cumulateScan2(std::size_t scanNum, TimsDataFastMap &accumulate_into, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const override
virtual std::size_t getScanPeakCount(std::size_t scanNum) const override
get the number of peaks in this spectrum need the binary file
virtual std::vector< quint32 > getScanIntensityList(std::size_t scanNum) const override
get raw intensities without transformation from one scan it needs intensity normalization
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::vector< quint32 > getScanTofIndexList(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
unsigned int lzfDecompressScan(const char *src, unsigned int src_len, char *dest, unsigned int dest_len)
decompress a single LZF compressed scan buffer
virtual std::vector< TofIndexIntensityPair > getRawValuePairList(std::size_t scanNum, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const override
get the raw index tof_index and intensities (normalized)
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
get the mass spectrum corresponding to a scan number
virtual void cumulateScan(std::size_t scanNum, TimsDataFastMap &accumulate_into) const override
cumulate a scan into a map
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)
virtual ~TimsFrameType1()
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