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 getNbrPeaks (std::size_t scanNum) const
 get the number of peaks in this spectrum need the binary file 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...
 
virtual MassSpectrumSPtr getMassSpectrumSPtr (std::size_t scanNum) const
 get Mass spectrum with peaks for this scan number need the binary file More...
 
virtual Trace cumulateScanToTrace (std::size_t scanNumBegin, std::size_t scanNumEnd) const
 cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time More...
 
virtual void cumulateScansInRawMap (std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const
 cumulate scan list into a trace into a raw spectrum map The intensities are NOT normalized with respect to the frame accumulation time More...
 
virtual quint64 cumulateSingleScanIntensities (std::size_t scanNum) const
 
virtual quint64 cumulateScansIntensities (std::size_t scanNumBegin, std::size_t scanNumEnd) const
 
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 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 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 qDebug();
338}
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 398 of file timsframe.cpp.

401{
402 qDebug() << "begin scanNumBegin=" << scanNumBegin
403 << " scanNumEnd=" << scanNumEnd;
404
405 if(m_timsDataFrame.size() == 0)
406 return;
407 try
408 {
409
410 std::size_t imax = scanNumEnd + 1;
411 qDebug();
412 for(std::size_t i = scanNumBegin; i < imax; i++)
413 {
414 qDebug() << i;
415 cumulateScan(i, rawSpectrum);
416 qDebug() << i;
417 // local_accumulationTime += m_accumulationTime;
418 }
419 }
420
421 catch(std::exception &error)
422 {
423 qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
424 .arg(__FUNCTION__)
425 .arg(scanNumBegin)
426 .arg(scanNumEnd)
427 .arg(error.what());
428 }
429 qDebug() << "end";
430}
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 342 of file timsframe.cpp.

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

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

435{
436 qDebug();
437 return getMassSpectrumSPtr(scanNum);
438}
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:441

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

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

587{
588
589 // qDebug();
590
591 pappso::TraceSPtr trace_sptr = std::make_shared<pappso::Trace>();
592 // std::vector<DataPoint>
593
594 if(m_timsDataFrame.size() == 0)
595 return trace_sptr;
596 // qDebug();
597
598 std::size_t size = getNbrPeaks(scanNum);
599
600 std::size_t offset = getScanOffset(scanNum);
601
602 qint32 previous = -1;
603 std::vector<quint32> index_list;
604 for(std::size_t i = 0; i < size; i++)
605 {
606 DataPoint data_point(
607 (*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
608 previous),
609 (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8) +
610 4)));
611
612 // intensity normalization
613 data_point.y *= 100.0 / m_accumulationTime;
614
615 previous = data_point.x;
616 trace_sptr.get()->push_back(data_point);
617 }
618 // qDebug();
619 return trace_sptr;
620}

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: