libpappsomspp
Library for mass spectrometry
pappso::TimsFrame Class Reference

#include <timsframe.h>

Inheritance diagram for pappso::TimsFrame:
pappso::TimsFrameBase pappso::TimsFrameType1

Classes

struct  XicComputeStructure
 

Public Member Functions

 TimsFrame (std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
 
 TimsFrame (const TimsFrame &other)
 
 ~TimsFrame ()
 
virtual std::size_t getNbrPeaks (std::size_t scanNum) const override
 get the number of peaks in this spectrum need the binary file More...
 
virtual Trace cumulateScanToTrace (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
 cumulate scan list into a trace More...
 
virtual void cumulateScansInRawMap (std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const override
 cumulate scan list into a trace into a raw spectrum map More...
 
virtual 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 More...
 
virtual std::vector< quint32 > getScanIntensities (std::size_t scanNum) const
 get raw intensities without transformation from one scan it needs intensity normalization More...
 
virtual pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr (std::size_t scanNum) const
 get the mass spectrum corresponding to a scan number More...
 
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr (std::size_t scanNum) const override
 get Mass spectrum with peaks for this scan number need the binary file More...
 
- Public Member Functions inherited from pappso::TimsFrameBase
 TimsFrameBase (std::size_t timsId, quint32 scanNum)
 constructor for binary independant tims frame More...
 
 TimsFrameBase (const TimsFrameBase &other)
 
 ~TimsFrameBase ()
 
virtual bool hasSameCalibrationData (const TimsFrameBase &other) const
 tells if 2 tims frame has the same calibration data Usefull to know if raw data can be handled between frames More...
 
bool checkScanNum (std::size_t scanNum) const
 check that this scan number exists More...
 
void setAccumulationTime (double accumulation_time_ms)
 
void setMzCalibration (double T1_frame, double T2_frame, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3, double C4, double T1_ref, double T2_ref, double dC1, double dC2)
 
void setTimsCalibration (int tims_model_type, double C0, double C1, double C2, double C3, double C4, double C5, double C6, double C7, double C8, double C9)
 
void setTime (double time)
 
void setMsMsType (quint8 type)
 
unsigned int getMsLevel () const
 
double getTime () const
 
std::size_t getId () const
 
double getDriftTime (std::size_t scanNum) const
 get drift time of a scan number in milliseconds More...
 
double getOneOverK0Transformation (std::size_t scanNum) const
 get 1/K0 value of a given scan (mobility value) More...
 
std::size_t getScanNumFromOneOverK0 (double one_over_k0) const
 get the scan number from a given 1/Ko mobility value More...
 
double getVoltageTransformation (std::size_t scanNum) const
 get voltage for a given scan number More...
 
pappso::Trace getTraceFromCumulatedScans (std::map< quint32, quint32 > &accumulated_scans) const
 transform accumulation of raw scans into a real mass spectrum More...
 
pappso::Trace getTraceFromCumulatedScansBuiltinCentroid (std::map< quint32, quint32 > &accumulated_scans) const
 transform accumulation of raw scans into a real mass spectrum with a simple centroid on raw integers More...
 
virtual const MzCalibrationInterfaceSPtrgetMzCalibrationInterfaceSPtr () const final
 get the MzCalibration model to compute mz and TOF for this frame More...
 
void setMzCalibrationInterfaceSPtr (MzCalibrationInterfaceSPtr mzCalibration)
 

Protected Member Functions

 TimsFrame (std::size_t timsId, quint32 scanNum)
 constructor for binary independant tims frame More...
 
void extractTimsXicListInRtRange (std::vector< XicCoordTims * >::iterator &itXicListbegin, std::vector< XicCoordTims * >::iterator &itXicListend, XicExtractMethod method) const
 
virtual void cumulateScan (std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
 cumulate a scan into a map More...
 
virtual pappso::TraceSPtr getRawTraceSPtr (std::size_t scanNum) const
 get the raw index tof_index and intensities (normalized) More...
 

Protected Attributes

QByteArray m_timsDataFrame
 
- Protected Attributes inherited from pappso::TimsFrameBase
quint32 m_scanNumber
 total number of scans contained in this frame More...
 
std::size_t m_timsId
 Tims frame database id (the SQL identifier of this frame) More...
 
double m_accumulationTime = 0
 accumulation time in milliseconds More...
 
quint8 m_msMsType = 0
 
double m_time = 0
 retention time More...
 
double m_timsDvStart = 0
 
double m_timsSlope
 
double m_timsTtrans = 0
 
double m_timsNdelay = 0
 
double m_timsVmin = 0
 
double m_timsVmax = 0
 
double m_timsC6 = 0
 
double m_timsC7 = 0
 
MzCalibrationInterfaceSPtr msp_mzCalibration = nullptr
 

Private Member Functions

void unshufflePacket (const char *src)
 unshuffle data packet of tims compression type 2 More...
 
std::size_t getScanOffset (std::size_t scanNum) const
 get offset for this spectrum in the binary file More...
 

Private Attributes

friend TimsDirectXicExtractor
 

Detailed Description

Todo:
write docs

Definition at line 52 of file timsframe.h.

Constructor & Destructor Documentation

◆ TimsFrame() [1/3]

pappso::TimsFrame::TimsFrame ( std::size_t  timsId,
quint32  scanNum,
char *  p_bytes,
std::size_t  len 
)
Parameters
timsIdtims frame id
scanNumtotal number of scans in this frame
p_bytespointer on the decompressed binary buffer
lensize of the decompressed binary buffer

Definition at line 63 of file timsframe.cpp.

67  : TimsFrameBase(timsId, scanNum)
68 {
69  // langella@themis:~/developpement/git/bruker/cbuild$
70  // ./src/sample/timsdataSamplePappso
71  // /gorgone/pappso/fichiers_fabricants/Bruker/Demo_TimsTOF_juin2019/Samples/1922001/1922001-1_S-415_Pep_Pur-1ul_Slot1-10_1_2088.d/
72  qDebug() << timsId;
73 
74  m_timsDataFrame.resize(len);
75 
76  if(p_bytes != nullptr)
77  {
78  unshufflePacket(p_bytes);
79  }
80  else
81  {
82  if(m_scanNumber == 0)
83  {
84 
86  QObject::tr("TimsFrame::TimsFrame(%1,%2,nullptr,%3) FAILED")
87  .arg(m_timsId)
88  .arg(m_scanNumber)
89  .arg(len));
90  }
91  }
92 }
TimsFrameBase(std::size_t timsId, quint32 scanNum)
constructor for binary independant tims frame
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)
QByteArray m_timsDataFrame
Definition: timsframe.h:181
void unshufflePacket(const char *src)
unshuffle data packet of tims compression type 2
Definition: timsframe.cpp:104

References pappso::TimsFrameBase::m_scanNumber, m_timsDataFrame, pappso::TimsFrameBase::m_timsId, and unshufflePacket().

◆ TimsFrame() [2/3]

pappso::TimsFrame::TimsFrame ( const TimsFrame other)

Copy constructor

Parameters
otherTODO

Definition at line 94 of file timsframe.cpp.

94  : TimsFrameBase(other)
95 {
96 }

◆ ~TimsFrame()

pappso::TimsFrame::~TimsFrame ( )

Destructor

Definition at line 98 of file timsframe.cpp.

99 {
100 }

◆ TimsFrame() [3/3]

pappso::TimsFrame::TimsFrame ( std::size_t  timsId,
quint32  scanNum 
)
protected

constructor for binary independant tims frame

Parameters
timsIdtims frame identifier in the database
scanNumthe total number of scans contained in this frame

Definition at line 57 of file timsframe.cpp.

58  : TimsFrameBase(timsId, scanNum)
59 {
60  // m_timsDataFrame.resize(10);
61 }

Member Function Documentation

◆ cumulateScan()

void pappso::TimsFrame::cumulateScan ( std::size_t  scanNum,
std::map< quint32, quint32 > &  accumulate_into 
) const
protectedvirtual

cumulate a scan into a map

Parameters
scanNumscan number 0 to (m_scanNumber-1)

Reimplemented in pappso::TimsFrameType1.

Definition at line 222 of file timsframe.cpp.

224 {
225  qDebug();
226 
227  if(m_timsDataFrame.size() == 0)
228  return;
229  // checkScanNum(scanNum);
230 
231 
232  std::size_t size = getNbrPeaks(scanNum);
233 
234  std::size_t offset = getScanOffset(scanNum);
235 
236  qint32 previous = -1;
237  for(std::size_t i = 0; i < size; i++)
238  {
239  quint32 x =
240  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
241  previous);
242  quint32 y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
243  (i * 8) + 4));
244 
245  previous = x;
246 
247  auto ret = accumulate_into.insert(std::pair<quint32, quint32>(x, y));
248 
249  if(ret.second == false)
250  {
251  // already existed : cumulate
252  ret.first->second += y;
253  }
254  }
255  qDebug();
256 }
virtual std::size_t getNbrPeaks(std::size_t scanNum) const override
get the number of peaks in this spectrum need the binary file
Definition: timsframe.cpp:131
std::size_t getScanOffset(std::size_t scanNum) const
get offset for this spectrum in the binary file
Definition: timsframe.cpp:161

References getNbrPeaks(), getScanOffset(), m_timsDataFrame, pappso::x, and pappso::y.

Referenced by cumulateScansInRawMap(), and cumulateScanToTrace().

◆ cumulateScansInRawMap()

void pappso::TimsFrame::cumulateScansInRawMap ( std::map< quint32, quint32 > &  rawSpectrum,
std::size_t  scanNumBegin,
std::size_t  scanNumEnd 
) const
overridevirtual

cumulate scan list into a trace into a raw spectrum map

Parameters
rawSpectrumsimple map of integers to cumulate raw counts
scanNumBeginfirst scan to cumulate
scanNumEndlast scan to cumulate

Reimplemented from pappso::TimsFrameBase.

Definition at line 316 of file timsframe.cpp.

319 {
320  qDebug() << "begin scanNumBegin=" << scanNumBegin
321  << " scanNumEnd=" << scanNumEnd;
322 
323  if(m_timsDataFrame.size() == 0)
324  return;
325  try
326  {
327 
328  std::size_t imax = scanNumEnd + 1;
329  qDebug();
330  for(std::size_t i = scanNumBegin; i < imax; i++)
331  {
332  qDebug() << i;
333  cumulateScan(i, rawSpectrum);
334  qDebug() << i;
335  // local_accumulationTime += m_accumulationTime;
336  }
337  }
338 
339  catch(std::exception &error)
340  {
341  qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
342  .arg(__FUNCTION__)
343  .arg(scanNumBegin)
344  .arg(scanNumEnd)
345  .arg(error.what());
346  }
347  qDebug() << "end";
348 }
virtual void cumulateScan(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
cumulate a scan into a map
Definition: timsframe.cpp:222

References cumulateScan(), and m_timsDataFrame.

◆ cumulateScanToTrace()

Trace pappso::TimsFrame::cumulateScanToTrace ( std::size_t  scanNumBegin,
std::size_t  scanNumEnd 
) const
overridevirtual

cumulate scan list into a trace

Parameters
scanNumBeginfirst scan to cumulate
scanNumEndlast scan to cumulate
Returns
Trace mz and intensity values

Reimplemented from pappso::TimsFrameBase.

Definition at line 260 of file timsframe.cpp.

262 {
263  qDebug();
264 
265  Trace new_trace;
266 
267  try
268  {
269  if(m_timsDataFrame.size() == 0)
270  return new_trace;
271  std::map<quint32, quint32> raw_spectrum;
272  // double local_accumulationTime = 0;
273 
274  std::size_t imax = scanNumEnd + 1;
275  qDebug();
276  for(std::size_t i = scanNumBegin; i < imax; i++)
277  {
278  qDebug() << i;
279  cumulateScan(i, raw_spectrum);
280  qDebug() << i;
281  // local_accumulationTime += m_accumulationTime;
282  }
283  qDebug();
284  pappso::DataPoint data_point_cumul;
285 
286 
287  MzCalibrationInterface *mz_calibration_p =
289 
290 
291  for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
292  {
293  data_point_cumul.x =
294  mz_calibration_p->getMzFromTofIndex(pair_tof_intensity.first);
295  // normalization
296  data_point_cumul.y =
297  pair_tof_intensity.second * ((double)100.0 / m_accumulationTime);
298  new_trace.push_back(data_point_cumul);
299  }
300  new_trace.sortX();
301  qDebug();
302  }
303 
304  catch(std::exception &error)
305  {
306  qDebug() << QString(
307  "Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
308  .arg(scanNumBegin, scanNumEnd)
309  .arg(error.what());
310  }
311  return new_trace;
312 }
double m_accumulationTime
accumulation time in milliseconds
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
pappso_double x
Definition: datapoint.h:22
pappso_double y
Definition: datapoint.h:23

References cumulateScan(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsFrameBase::m_accumulationTime, m_timsDataFrame, pappso::Trace::sortX(), pappso::DataPoint::x, and pappso::DataPoint::y.

◆ extractTimsXicListInRtRange()

void pappso::TimsFrame::extractTimsXicListInRtRange ( std::vector< XicCoordTims * >::iterator &  itXicListbegin,
std::vector< XicCoordTims * >::iterator &  itXicListend,
XicExtractMethod  method 
) const
protected

Definition at line 412 of file timsframe.cpp.

416 {
417  qDebug() << std::distance(itXicListbegin, itXicListend);
418  std::vector<TimsFrame::XicComputeStructure> tmp_xic_list;
419 
420  for(auto it = itXicListbegin; it != itXicListend; it++)
421  {
422  tmp_xic_list.push_back(TimsFrame::XicComputeStructure(this, **it));
423 
424  qDebug() << " tmp_xic_struct.mobilityIndexBegin="
425  << tmp_xic_list.back().mobilityIndexBegin
426  << " tmp_xic_struct.mobilityIndexEnd="
427  << tmp_xic_list.back().mobilityIndexEnd;
428 
429  qDebug() << " tmp_xic_struct.mzIndexLowerBound="
430  << tmp_xic_list.back().mzIndexLowerBound
431  << " tmp_xic_struct.mzIndexUpperBound="
432  << tmp_xic_list.back().mzIndexUpperBound;
433  }
434  if(tmp_xic_list.size() == 0)
435  return;
436  /*
437  std::sort(tmp_xic_list.begin(), tmp_xic_list.end(), [](const TimsXicStructure
438  &a, const TimsXicStructure &b) { return a.mobilityIndexBegin <
439  b.mobilityIndexBegin;
440  });
441  */
442  std::vector<std::size_t> unique_scan_num_list;
443  for(auto &&struct_xic : tmp_xic_list)
444  {
445  for(std::size_t scan = struct_xic.mobilityIndexBegin;
446  (scan <= struct_xic.mobilityIndexEnd) && (scan < m_scanNumber);
447  scan++)
448  {
449  unique_scan_num_list.push_back(scan);
450  }
451  }
452  std::sort(unique_scan_num_list.begin(), unique_scan_num_list.end());
453  auto it_scan_num_end =
454  std::unique(unique_scan_num_list.begin(), unique_scan_num_list.end());
455  auto it_scan_num = unique_scan_num_list.begin();
456 
457  while(it_scan_num != it_scan_num_end)
458  {
459  TraceSPtr ms_spectrum = getRawTraceSPtr(*it_scan_num);
460  // qDebug() << ms_spectrum.get()->toString();
461  for(auto &&tmp_xic_struct : tmp_xic_list)
462  {
463  if(((*it_scan_num) >= tmp_xic_struct.mobilityIndexBegin) &&
464  ((*it_scan_num) <= tmp_xic_struct.mobilityIndexEnd))
465  {
466  if(method == XicExtractMethod::max)
467  {
468  tmp_xic_struct.tmpIntensity +=
469  ms_spectrum.get()->maxY(tmp_xic_struct.mzIndexLowerBound,
470  tmp_xic_struct.mzIndexUpperBound);
471 
472  qDebug() << "tmp_xic_struct.tmpIntensity="
473  << tmp_xic_struct.tmpIntensity;
474  }
475  else
476  {
477  // sum
478  tmp_xic_struct.tmpIntensity +=
479  ms_spectrum.get()->sumY(tmp_xic_struct.mzIndexLowerBound,
480  tmp_xic_struct.mzIndexUpperBound);
481  qDebug() << "tmp_xic_struct.tmpIntensity="
482  << tmp_xic_struct.tmpIntensity;
483  }
484  }
485  }
486  it_scan_num++;
487  }
488 
489  for(auto &&tmp_xic_struct : tmp_xic_list)
490  {
491  if(tmp_xic_struct.tmpIntensity != 0)
492  {
493  qDebug() << tmp_xic_struct.xic_ptr;
494  tmp_xic_struct.xic_ptr->push_back(
495  {m_time, tmp_xic_struct.tmpIntensity});
496  }
497  }
498 
499  qDebug();
500 }
double m_time
retention time
virtual pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const
get the raw index tof_index and intensities (normalized)
Definition: timsframe.cpp:504
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:119
@ max
maximum of intensities

References getRawTraceSPtr(), pappso::TimsFrameBase::m_scanNumber, pappso::TimsFrameBase::m_time, and pappso::max.

◆ getMassSpectrumCstSPtr()

pappso::MassSpectrumCstSPtr pappso::TimsFrame::getMassSpectrumCstSPtr ( std::size_t  scanNum) const
virtual

get the mass spectrum corresponding to a scan number

Parameters
scanNumthe scan number to retrieve

Definition at line 352 of file timsframe.cpp.

353 {
354  qDebug();
355  return getMassSpectrumSPtr(scanNum);
356 }
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
get Mass spectrum with peaks for this scan number need the binary file
Definition: timsframe.cpp:359

References getMassSpectrumSPtr().

◆ getMassSpectrumSPtr()

pappso::MassSpectrumSPtr pappso::TimsFrame::getMassSpectrumSPtr ( std::size_t  scanNum) const
overridevirtual

get Mass spectrum with peaks for this scan number need the binary file

Parameters
scanNumscan number in the frame in the order it lies in binary file, from 0 to N-1

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 359 of file timsframe.cpp.

360 {
361 
362  qDebug() << " scanNum=" << scanNum;
363 
364  checkScanNum(scanNum);
365 
366  qDebug();
367 
368  pappso::MassSpectrumSPtr mass_spectrum_sptr =
369  std::make_shared<pappso::MassSpectrum>();
370  // std::vector<DataPoint>
371 
372  if(m_timsDataFrame.size() == 0)
373  return mass_spectrum_sptr;
374  qDebug();
375 
376  std::size_t size = getNbrPeaks(scanNum);
377 
378  std::size_t offset = getScanOffset(scanNum);
379 
380  MzCalibrationInterface *mz_calibration_p =
382 
383 
384  qint32 previous = -1;
385  qint32 tof_index;
386  // std::vector<quint32> index_list;
387  DataPoint data_point;
388  for(std::size_t i = 0; i < size; i++)
389  {
390  tof_index =
391  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
392  previous);
393  data_point.y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
394  (i * 8) + 4));
395 
396  // intensity normalization
397  data_point.y *= 100.0 / m_accumulationTime;
398 
399  previous = tof_index;
400 
401 
402  // mz calibration
403  data_point.x = mz_calibration_p->getMzFromTofIndex(tof_index);
404  mass_spectrum_sptr.get()->push_back(data_point);
405  }
406  qDebug();
407  return mass_spectrum_sptr;
408 }
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54

References pappso::TimsFrameBase::checkScanNum(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), getNbrPeaks(), getScanOffset(), pappso::TimsFrameBase::m_accumulationTime, m_timsDataFrame, pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by getMassSpectrumCstSPtr().

◆ getNbrPeaks()

std::size_t pappso::TimsFrame::getNbrPeaks ( std::size_t  scanNum) const
overridevirtual

get the number of peaks in this spectrum need the binary file

Parameters
scanNumscan number in the frame in the order it lies in binary file, from 0 to N-1

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 131 of file timsframe.cpp.

132 {
133  if(m_timsDataFrame.size() == 0)
134  return 0;
135  /*
136  if(scanNum == 0)
137  {
138  quint32 res = (*(quint32 *)(m_timsDataFrame.constData() + 4)) -
139  (*(quint32 *)(m_timsDataFrame.constData()-4));
140  return res / 2;
141  }*/
142  if(scanNum == (m_scanNumber - 1))
143  {
144  auto nb_uint4 = m_timsDataFrame.size() / 4;
145 
146  std::size_t cumul = 0;
147  for(quint32 i = 0; i < m_scanNumber; i++)
148  {
149  cumul += (*(quint32 *)(m_timsDataFrame.constData() + (i * 4)));
150  }
151  return (nb_uint4 - cumul) / 2;
152  }
153  checkScanNum(scanNum);
154 
155  // quint32 *res = (quint32 *)(m_timsDataFrame.constData() + (scanNum * 4));
156  // qDebug() << " res=" << *res;
157  return (*(quint32 *)(m_timsDataFrame.constData() + ((scanNum + 1) * 4))) / 2;
158 }

References pappso::TimsFrameBase::checkScanNum(), pappso::TimsFrameBase::m_scanNumber, and m_timsDataFrame.

Referenced by cumulateScan(), getMassSpectrumSPtr(), getRawTraceSPtr(), getScanIndexList(), and getScanIntensities().

◆ getRawTraceSPtr()

pappso::TraceSPtr pappso::TimsFrame::getRawTraceSPtr ( std::size_t  scanNum) const
protectedvirtual

get the raw index tof_index and intensities (normalized)

Parameters
scanNumthe scan number to extract
Returns
trace vector

Reimplemented in pappso::TimsFrameType1.

Definition at line 504 of file timsframe.cpp.

505 {
506 
507  // qDebug();
508 
509  pappso::TraceSPtr trace_sptr = std::make_shared<pappso::Trace>();
510  // std::vector<DataPoint>
511 
512  if(m_timsDataFrame.size() == 0)
513  return trace_sptr;
514  // qDebug();
515 
516  std::size_t size = getNbrPeaks(scanNum);
517 
518  std::size_t offset = getScanOffset(scanNum);
519 
520  qint32 previous = -1;
521  std::vector<quint32> index_list;
522  for(std::size_t i = 0; i < size; i++)
523  {
524  DataPoint data_point(
525  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
526  previous),
527  (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8) +
528  4)));
529 
530  // intensity normalization
531  data_point.y *= 100.0 / m_accumulationTime;
532 
533  previous = data_point.x;
534  trace_sptr.get()->push_back(data_point);
535  }
536  // qDebug();
537  return trace_sptr;
538 }

References getNbrPeaks(), getScanOffset(), pappso::TimsFrameBase::m_accumulationTime, m_timsDataFrame, pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by extractTimsXicListInRtRange().

◆ getScanIndexList()

std::vector< quint32 > pappso::TimsFrame::getScanIndexList ( std::size_t  scanNum) const
virtual

get raw index list for one given scan index are not TOF nor m/z, just index on digitizer

Reimplemented in pappso::TimsFrameType1.

Definition at line 173 of file timsframe.cpp.

174 {
175  qDebug();
176  checkScanNum(scanNum);
177  std::vector<quint32> scan_tof;
178 
179  if(m_timsDataFrame.size() == 0)
180  return scan_tof;
181  scan_tof.resize(getNbrPeaks(scanNum));
182 
183  std::size_t offset = getScanOffset(scanNum);
184 
185  qint32 previous = -1;
186  for(std::size_t i = 0; i < scan_tof.size(); i++)
187  {
188  scan_tof[i] =
189  (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
190  previous;
191  previous = scan_tof[i];
192  }
193  qDebug();
194  return scan_tof;
195 }

References pappso::TimsFrameBase::checkScanNum(), getNbrPeaks(), getScanOffset(), and m_timsDataFrame.

◆ getScanIntensities()

std::vector< quint32 > pappso::TimsFrame::getScanIntensities ( std::size_t  scanNum) const
virtual

get raw intensities without transformation from one scan it needs intensity normalization

Reimplemented in pappso::TimsFrameType1.

Definition at line 198 of file timsframe.cpp.

199 {
200  qDebug();
201  checkScanNum(scanNum);
202  std::vector<quint32> scan_intensities;
203 
204  if(m_timsDataFrame.size() == 0)
205  return scan_intensities;
206 
207  scan_intensities.resize(getNbrPeaks(scanNum));
208 
209  std::size_t offset = getScanOffset(scanNum);
210 
211  for(std::size_t i = 0; i < scan_intensities.size(); i++)
212  {
213  scan_intensities[i] = (*(quint32 *)(m_timsDataFrame.constData() +
214  (offset * 4) + (i * 8) + 4));
215  }
216  qDebug();
217  return scan_intensities;
218 }

References pappso::TimsFrameBase::checkScanNum(), getNbrPeaks(), getScanOffset(), and m_timsDataFrame.

◆ getScanOffset()

std::size_t pappso::TimsFrame::getScanOffset ( std::size_t  scanNum) const
private

get offset for this spectrum in the binary file

Parameters
scanNumscan number in the frame in the order it lies in binary file, from 0 to N-1

Definition at line 161 of file timsframe.cpp.

162 {
163  std::size_t offset = 0;
164  for(std::size_t i = 0; i < (scanNum + 1); i++)
165  {
166  offset += (*(quint32 *)(m_timsDataFrame.constData() + (i * 4)));
167  }
168  return offset;
169 }

References m_timsDataFrame.

Referenced by cumulateScan(), getMassSpectrumSPtr(), getRawTraceSPtr(), getScanIndexList(), and getScanIntensities().

◆ unshufflePacket()

void pappso::TimsFrame::unshufflePacket ( const char *  src)
private

unshuffle data packet of tims compression type 2

Parameters
srcis a zstd decompressed buffer pointer

Definition at line 104 of file timsframe.cpp.

105 {
106  qDebug();
107  quint64 len = m_timsDataFrame.size();
108  if(len % 4 != 0)
109  {
111  QObject::tr("TimsFrame::unshufflePacket error: len%4 != 0"));
112  }
113 
114  quint64 nb_uint4 = len / 4;
115 
116  char *dest = m_timsDataFrame.data();
117  quint64 src_offset = 0;
118 
119  for(quint64 j = 0; j < 4; j++)
120  {
121  for(quint64 i = 0; i < nb_uint4; i++)
122  {
123  dest[(i * 4) + j] = src[src_offset];
124  src_offset++;
125  }
126  }
127  qDebug();
128 }

References m_timsDataFrame.

Referenced by TimsFrame().

Member Data Documentation

◆ m_timsDataFrame

◆ TimsDirectXicExtractor

friend pappso::TimsFrame::TimsDirectXicExtractor
private

Definition at line 54 of file timsframe.h.


The documentation for this class was generated from the following files: