35#include <liblzf/lzf.h>
47 if(p_bytes !=
nullptr)
59 QObject::tr(
"TimsFrameType1::TimsFrameType1(%1,%2,nullptr,%3) FAILED")
80 qDebug() <<
" m_scanNumber=" <<
m_scanCount <<
" len=" << len;
85 qDebug() <<
" count=" << count;
88 qDebug() <<
" m_timsDataFrame.size()=" <<
m_binaryData.size();
103 qDebug() <<
"offset begin at last :" << count + 4;
107 std::size_t previous_offset = (*(quint32 *)(src));
108 qDebug() <<
"first offset= " << previous_offset;
109 std::size_t cumul_decompressed_size = 0;
114 offset = (*(quint32 *)(src + (i * 4)));
116 std::size_t compressed_size = offset - previous_offset;
118 qDebug() <<
"scan i=" << i <<
" previous_offset=" << previous_offset <<
" offset=" << offset
119 <<
" length=" << compressed_size;
123 if(cumul_decompressed_size < remaining_size)
125 remaining_size = remaining_size - cumul_decompressed_size;
131 qDebug() <<
" remaining_size=" << remaining_size;
132 std::size_t decompressed_size =
141 cumul_decompressed_size += decompressed_size;
142 qDebug() <<
" decompressed_size=" << decompressed_size;
145 previous_offset = offset;
166 unsigned int src_len,
168 unsigned int dest_len)
170 qDebug() <<
"src=" << src <<
" src_len=" << src_len <<
" dest_len=" << dest_len;
173 unsigned int decompressed_size;
174 unsigned int more_space = src_len * 2;
175 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
176 while(decompressed_size == 0)
178 qDebug() <<
"dest_len=" << dest_len;
179 qDebug() <<
"decompressed_size=" << decompressed_size;
183 throw PappsoException(QObject::tr(
"ERROR reading TimsFrameType1 %1 TIMS binary file %2: "
184 "LZF decompression error EINVAL")
187 else if(errno == E2BIG)
189 qDebug() <<
" m_timsDataFrame.size()=" <<
m_binaryData.size()
190 <<
" more_space=" << more_space;
192 dest_len += more_space;
194 decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
201 return decompressed_size;
208 return mass_spectrum_sptr.get()->size();
226 qint32 tof_index = 0;
227 for(std::size_t i = 0; i < size; i++)
229 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
234 tof_index += -1 * value;
239 quint32
x = tof_index;
254 quint32 accepted_tof_index_range_begin,
255 quint32 accepted_tof_index_range_end)
const
268 qint32 tof_index = 0;
269 for(std::size_t i = 0; i < size; i++)
271 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
276 tof_index += -1 * value;
281 quint32
x = tof_index;
285 if(
x < accepted_tof_index_range_begin)
290 if(
x > accepted_tof_index_range_end)
308 std::vector<quint32> mzindex_values;
316 return mzindex_values;
323 qDebug() <<
" offset=" << offset <<
" size=" << size;
325 return mzindex_values;
328 qint32 tof_index = 0;
330 for(std::size_t i = 0; i < size; i++)
332 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
336 tof_index += -1 * value;
340 mzindex_values.push_back(tof_index);
347 return mzindex_values;
356 .arg(error.
qwhat()));
366 qDebug() <<
" scanNum=" << scanNum;
370 std::vector<quint32> int_values;
385 qDebug() <<
" offset=" << offset <<
" size=" << size;
390 qint32 tof_index = 0;
392 for(std::size_t i = 0; i < size; i++)
394 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
398 tof_index += -1 * value;
402 int_values.push_back(value);
418 .arg(error.
qwhat()));
426 qDebug() <<
" scanNum=" << scanNum;
438 return mass_spectrum_sptr;
445 qDebug() <<
" offset=" << offset <<
" size=" << size;
447 return mass_spectrum_sptr;
454 qint32 tof_index = 0;
457 for(std::size_t i = 0; i < size; i++)
459 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
463 tof_index += -1 * value;
467 data_point.
y = value;
475 mass_spectrum_sptr.get()->push_back(data_point);
481 qDebug() << mass_spectrum_sptr.get()->toString();
482 return mass_spectrum_sptr;
487 QObject::tr(
"Error TimsFrameType1::getMassSpectrumSPtr frameId=%1 "
491 .arg(error.
qwhat()));
513 qDebug() <<
" offset=" << offset <<
" size=" << size;
519 qint32 tof_index = 0;
523 for(std::size_t i = 0; i < size; i++)
525 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
529 tof_index += -1 * value;
533 data_point.
y = value;
540 data_point.
x = tof_index;
541 trace_sptr.get()->push_back(data_point);
552std::vector<TimsFrameType1::TofIndexIntensityPair>
554 quint32 accepted_tof_index_range_begin,
555 quint32 accepted_tof_index_range_end)
const
560 std::vector<TimsFrame::TofIndexIntensityPair> trace_sptr;
571 qDebug() <<
" offset=" << offset <<
" size=" << size;
577 qint32 tof_index = 0;
581 for(std::size_t i = 0; i < size; i++)
583 value = (*(qint32 *)(
m_binaryData.constData() + offset + (i * 4)));
587 tof_index += -1 * value;
608 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()
TimsFrame(std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
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