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

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

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

92  : TimsFrameBase(other)
93 {
94 }

◆ ~TimsFrame()

pappso::TimsFrame::~TimsFrame ( )
virtual

Destructor

Definition at line 96 of file timsframe.cpp.

97 {
98 }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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: