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)
 
virtual ~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 quint64 cumulateSingleScanIntensities (std::size_t scanNum) const override
 
virtual quint64 cumulateScansIntensities (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
 ... More...
 
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 More...
 
virtual std::vector< quint32 > getScanIntensities (std::size_t scanNum) const override
 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)
 
virtual ~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...
 
virtual std::size_t getTotalNumberOfScans () const
 get the number of scans contained in this frame each scan represents an ion mobility slice More...
 
virtual quint32 getMaximumRawMassIndex () const
 get the maximum raw mass index contained in this frame 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)
 
virtual Trace getIonMobilityTraceByMzIndexRange (std::size_t mz_index_lower_bound, std::size_t mz_index_upper_bound, XicExtractMethod method) const
 get a mobility trace cumulating intensities inside the given mass index range More...
 

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 51 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 62 of file timsframe.cpp.

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

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 93 of file timsframe.cpp.

93  : TimsFrameBase(other)
94 {
95 }

◆ ~TimsFrame()

pappso::TimsFrame::~TimsFrame ( )
virtual

Destructor

Definition at line 97 of file timsframe.cpp.

98 {
99 }

◆ 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 56 of file timsframe.cpp.

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

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 306 of file timsframe.cpp.

308 {
309  //qDebug();
310 
311  if(m_timsDataFrame.size() == 0)
312  return;
313  // checkScanNum(scanNum);
314 
315  std::size_t size = getNbrPeaks(scanNum);
316 
317  std::size_t offset = getScanOffset(scanNum);
318 
319  qint32 previous = -1;
320  for(std::size_t i = 0; i < size; i++)
321  {
322  quint32 x =
323  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
324  previous);
325  quint32 y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
326  (i * 8) + 4));
327 
328  previous = x;
329 
330  auto ret = accumulate_into.insert(std::pair<quint32, quint32>(x, y));
331 
332  if(ret.second == false)
333  {
334  // already existed : cumulate
335  ret.first->second += y;
336  }
337  }
338 
339  // qDebug();
340 }
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:130
std::size_t getScanOffset(std::size_t scanNum) const
get offset for this spectrum in the binary file
Definition: timsframe.cpp:160

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 404 of file timsframe.cpp.

407 {
408  // qDebug() << "begin scanNumBegin=" << scanNumBegin
409  //<< " scanNumEnd=" << scanNumEnd;
410 
411  if(m_timsDataFrame.size() == 0)
412  return;
413  try
414  {
415 
416  std::size_t imax = scanNumEnd + 1;
417  qDebug();
418  for(std::size_t i = scanNumBegin; i < imax; i++)
419  {
420  qDebug() << i;
421  cumulateScan(i, rawSpectrum);
422  qDebug() << i;
423  // local_accumulationTime += m_accumulationTime;
424  }
425  }
426 
427  catch(std::exception &error)
428  {
429  qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
430  .arg(__FUNCTION__)
431  .arg(scanNumBegin)
432  .arg(scanNumEnd)
433  .arg(error.what());
434  }
435 
436  // qDebug() << "end";
437 }
virtual void cumulateScan(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
cumulate a scan into a map
Definition: timsframe.cpp:306

References cumulateScan(), and m_timsDataFrame.

◆ cumulateScansIntensities()

quint64 pappso::TimsFrame::cumulateScansIntensities ( std::size_t  scanNumBegin,
std::size_t  scanNumEnd 
) const
overridevirtual

...

Parameters
scanNumBeginp_scanNumBegin:...
scanNumEndp_scanNumEnd:...
Returns
quint64

Reimplemented from pappso::TimsFrameBase.

Definition at line 268 of file timsframe.cpp.

270 {
271  quint64 summed_intensities = 0;
272 
273  //qDebug() << "begin scanNumBegin =" << scanNumBegin
274  //<< "scanNumEnd =" << scanNumEnd;
275 
276  if(m_timsDataFrame.size() == 0)
277  return summed_intensities;
278 
279  try
280  {
281  std::size_t imax = scanNumEnd + 1;
282 
283  for(std::size_t i = scanNumBegin; i < imax; i++)
284  {
285  qDebug() << i;
286  summed_intensities += cumulateSingleScanIntensities(i);
287  qDebug() << i;
288  }
289  }
290  catch(std::exception &error)
291  {
292  qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
293  .arg(__FUNCTION__)
294  .arg(scanNumBegin)
295  .arg(scanNumEnd)
296  .arg(error.what());
297  }
298 
299  //qDebug() << "end";
300 
301  return summed_intensities;
302 }
virtual quint64 cumulateSingleScanIntensities(std::size_t scanNum) const override
Definition: timsframe.cpp:221

References cumulateSingleScanIntensities(), 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 344 of file timsframe.cpp.

346 {
347  // qDebug();
348 
349  Trace new_trace;
350 
351  try
352  {
353  if(m_timsDataFrame.size() == 0)
354  return new_trace;
355  std::map<quint32, quint32> raw_spectrum;
356  // double local_accumulationTime = 0;
357 
358  std::size_t imax = scanNumEnd + 1;
359  qDebug();
360  for(std::size_t i = scanNumBegin; i < imax; i++)
361  {
362  // qDebug() << i;
363  cumulateScan(i, raw_spectrum);
364  // qDebug() << i;
365 
366  // local_accumulationTime += m_accumulationTime;
367  }
368 
369  // qDebug();
370 
371  pappso::DataPoint data_point_cumul;
372 
373 
374  MzCalibrationInterface *mz_calibration_p =
376 
377 
378  for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
379  {
380  data_point_cumul.x =
381  mz_calibration_p->getMzFromTofIndex(pair_tof_intensity.first);
382  // normalization
383  data_point_cumul.y =
384  pair_tof_intensity.second * ((double)100.0 / m_accumulationTime);
385  new_trace.push_back(data_point_cumul);
386  }
387  new_trace.sortX();
388 
389  // qDebug();
390  }
391 
392  catch(std::exception &error)
393  {
394  qDebug() << QString(
395  "Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
396  .arg(scanNumBegin, scanNumEnd)
397  .arg(error.what());
398  }
399  return new_trace;
400 }
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:23
pappso_double y
Definition: datapoint.h:24

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

◆ cumulateSingleScanIntensities()

quint64 pappso::TimsFrame::cumulateSingleScanIntensities ( std::size_t  scanNum) const
overridevirtual

Reimplemented from pappso::TimsFrameBase.

Definition at line 221 of file timsframe.cpp.

222 {
223  qDebug();
224 
225  quint64 summed_intensities = 0;
226 
227  if(m_timsDataFrame.size() == 0)
228  return summed_intensities;
229  // checkScanNum(scanNum);
230 
231  std::size_t size = getNbrPeaks(scanNum);
232 
233  std::size_t offset = getScanOffset(scanNum);
234 
235  qint32 previous = -1;
236 
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 
243  quint32 y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
244  (i * 8) + 4));
245 
246  previous = x;
247 
248  summed_intensities += y;
249  }
250 
251  // Normalization over the accumulation time for this frame.
252  summed_intensities *= ((double)100.0 / m_accumulationTime);
253 
254  qDebug();
255 
256  return summed_intensities;
257 }

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

Referenced by cumulateScansIntensities().

◆ extractTimsXicListInRtRange()

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

Definition at line 505 of file timsframe.cpp.

509 {
510  qDebug() << std::distance(itXicListbegin, itXicListend);
511 
512  std::vector<TimsFrame::XicComputeStructure> tmp_xic_list;
513 
514  for(auto it = itXicListbegin; it != itXicListend; it++)
515  {
516  tmp_xic_list.push_back(TimsFrame::XicComputeStructure(this, **it));
517 
518  qDebug() << " tmp_xic_struct.mobilityIndexBegin="
519  << tmp_xic_list.back().mobilityIndexBegin
520  << " tmp_xic_struct.mobilityIndexEnd="
521  << tmp_xic_list.back().mobilityIndexEnd;
522 
523  qDebug() << " tmp_xic_struct.mzIndexLowerBound="
524  << tmp_xic_list.back().mzIndexLowerBound
525  << " tmp_xic_struct.mzIndexUpperBound="
526  << tmp_xic_list.back().mzIndexUpperBound;
527  }
528  if(tmp_xic_list.size() == 0)
529  return;
530  /*
531  std::sort(tmp_xic_list.begin(), tmp_xic_list.end(), [](const
532  TimsXicStructure &a, const TimsXicStructure &b) { return
533  a.mobilityIndexBegin < b.mobilityIndexBegin;
534  });
535  */
536  std::vector<std::size_t> unique_scan_num_list;
537  for(auto &&struct_xic : tmp_xic_list)
538  {
539  for(std::size_t scan = struct_xic.mobilityIndexBegin;
540  (scan <= struct_xic.mobilityIndexEnd) && (scan < m_scanNumber);
541  scan++)
542  {
543  unique_scan_num_list.push_back(scan);
544  }
545  }
546  std::sort(unique_scan_num_list.begin(), unique_scan_num_list.end());
547  auto it_scan_num_end =
548  std::unique(unique_scan_num_list.begin(), unique_scan_num_list.end());
549  auto it_scan_num = unique_scan_num_list.begin();
550 
551  while(it_scan_num != it_scan_num_end)
552  {
553  TraceSPtr ms_spectrum = getRawTraceSPtr(*it_scan_num);
554  // qDebug() << ms_spectrum.get()->toString();
555  for(auto &&tmp_xic_struct : tmp_xic_list)
556  {
557  if(((*it_scan_num) >= tmp_xic_struct.mobilityIndexBegin) &&
558  ((*it_scan_num) <= tmp_xic_struct.mobilityIndexEnd))
559  {
560  if(method == XicExtractMethod::max)
561  {
562  tmp_xic_struct.tmpIntensity +=
563  ms_spectrum.get()->maxY(tmp_xic_struct.mzIndexLowerBound,
564  tmp_xic_struct.mzIndexUpperBound);
565 
566  qDebug() << "tmp_xic_struct.tmpIntensity="
567  << tmp_xic_struct.tmpIntensity;
568  }
569  else
570  {
571  // sum
572  tmp_xic_struct.tmpIntensity +=
573  ms_spectrum.get()->sumY(tmp_xic_struct.mzIndexLowerBound,
574  tmp_xic_struct.mzIndexUpperBound);
575  qDebug() << "tmp_xic_struct.tmpIntensity="
576  << tmp_xic_struct.tmpIntensity;
577  }
578  }
579  }
580  it_scan_num++;
581  }
582 
583  for(auto &&tmp_xic_struct : tmp_xic_list)
584  {
585  if(tmp_xic_struct.tmpIntensity != 0)
586  {
587  qDebug() << tmp_xic_struct.xic_ptr;
588  tmp_xic_struct.xic_ptr->push_back(
589  {m_time, tmp_xic_struct.tmpIntensity});
590  }
591  }
592 
593  qDebug();
594 }
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:598
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:135
@ 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 441 of file timsframe.cpp.

442 {
443  // qDebug();
444 
445  return getMassSpectrumSPtr(scanNum);
446 }
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:449

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 449 of file timsframe.cpp.

450 {
451 
452  // qDebug() << " scanNum=" << scanNum;
453 
454  checkScanNum(scanNum);
455 
456  // qDebug();
457 
458  pappso::MassSpectrumSPtr mass_spectrum_sptr =
459  std::make_shared<pappso::MassSpectrum>();
460  // std::vector<DataPoint>
461 
462  if(m_timsDataFrame.size() == 0)
463  return mass_spectrum_sptr;
464 
465  // qDebug();
466 
467  std::size_t size = getNbrPeaks(scanNum);
468 
469  std::size_t offset = getScanOffset(scanNum);
470 
471  MzCalibrationInterface *mz_calibration_p =
473 
474 
475  qint32 previous = -1;
476  qint32 tof_index;
477  // std::vector<quint32> index_list;
478  DataPoint data_point;
479  for(std::size_t i = 0; i < size; i++)
480  {
481  tof_index =
482  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
483  previous);
484  data_point.y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
485  (i * 8) + 4));
486 
487  // intensity normalization
488  data_point.y *= 100.0 / m_accumulationTime;
489 
490  previous = tof_index;
491 
492 
493  // mz calibration
494  data_point.x = mz_calibration_p->getMzFromTofIndex(tof_index);
495  mass_spectrum_sptr.get()->push_back(data_point);
496  }
497 
498  // qDebug();
499 
500  return mass_spectrum_sptr;
501 }
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 130 of file timsframe.cpp.

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

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

Referenced by cumulateScan(), cumulateSingleScanIntensities(), 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 598 of file timsframe.cpp.

599 {
600 
601  // qDebug();
602 
603  pappso::TraceSPtr trace_sptr = std::make_shared<pappso::Trace>();
604  // std::vector<DataPoint>
605 
606  if(m_timsDataFrame.size() == 0)
607  return trace_sptr;
608  // qDebug();
609 
610  std::size_t size = getNbrPeaks(scanNum);
611 
612  std::size_t offset = getScanOffset(scanNum);
613 
614  qint32 previous = -1;
615  std::vector<quint32> index_list;
616  for(std::size_t i = 0; i < size; i++)
617  {
618  DataPoint data_point(
619  (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
620  previous),
621  (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8) +
622  4)));
623 
624  // intensity normalization
625  data_point.y *= 100.0 / m_accumulationTime;
626 
627  previous = data_point.x;
628  trace_sptr.get()->push_back(data_point);
629  }
630  // qDebug();
631  return trace_sptr;
632 }

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
overridevirtual

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

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 172 of file timsframe.cpp.

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

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

Referenced by pappso::BaseColorMapPlotWidget::addColorMap().

◆ getScanIntensities()

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

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

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 197 of file timsframe.cpp.

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

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

Referenced by pappso::BaseColorMapPlotWidget::addColorMap().

◆ 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 160 of file timsframe.cpp.

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

References m_timsDataFrame.

Referenced by cumulateScan(), cumulateSingleScanIntensities(), 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 103 of file timsframe.cpp.

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

References m_timsDataFrame.

Referenced by TimsFrame().

Member Data Documentation

◆ m_timsDataFrame

◆ TimsDirectXicExtractor

friend pappso::TimsFrame::TimsDirectXicExtractor
private

Definition at line 53 of file timsframe.h.


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