libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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 getScanPeakCount (std::size_t scanIndex) const override
 get the number of peaks in this spectrum need the binary file
 
virtual Trace cumulateScansToTrace (std::size_t scanIndexBegin, std::size_t scanIndexEnd) const override
 cumulate scan list into a trace
 
virtual Trace combineScansToTraceWithDowngradedMzResolution (std::size_t mzindex_merge_window, std::size_t scanNumBegin, std::size_t scanNumEnd, quint32 &mz_minimum_index, quint32 &mz_maximum_index) const override
 cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time to leverage computing performance, this function decreases the mz resolution
 
virtual Trace combineScansToTraceWithDowngradedMzResolution2 (std::size_t mz_index_merge_window, double mz_range_begin, double mz_range_end, std::size_t mobility_scan_begin, std::size_t mobility_scan_end, quint32 &mz_minimum_index_out, quint32 &mz_maximum_index_out) const override
 cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time to leverage computing performance, this function decreases the mz resolution
 
void combineScansInTofIndexIntensityMap (TimsDataFastMap &rawSpectrum, std::size_t scan_index_begin, std::size_t scan_index_end) const override
 cumulate scan list into a trace into a raw spectrum map
 
virtual void combineScansInTofIndexIntensityMap (TimsDataFastMap &tof_index_intensity_map, std::size_t scan_index_begin, std::size_t scan_index_end, quint32 tof_index_begin, quint32 tof_index_end) const override
 cumulate scan list into a trace into a raw spectrum map The intensities are NOT normalized with respect to the frame accumulation time
 
virtual Trace getMobilityScan (std::size_t scanNum, std::size_t mz_index_merge_window, double mz_range_begin, double mz_range_end, quint32 &mz_minimum_index_out, quint32 &mz_maximum_index_out) const override
 get a single mobility scan m/z + intensities
 
virtual quint64 cumulateScanIntensities (std::size_t scanNum) const override
 
virtual quint64 cumulateScanRangeIntensities (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
 ...
 
virtual std::vector< quint32 > getScanTofIndexList (std::size_t scanNum) const override
 get raw index list for one given scan index are not TOF nor m/z, just index on digitizer
 
virtual std::vector< quint32 > getScanIntensityList (std::size_t scanNum) const override
 get raw intensities without transformation from one scan it needs intensity normalization
 
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr (std::size_t scanNum) const override
 get Mass spectrum with peaks for this scan index need the binary file
 
virtual std::vector< TofIndexIntensityPairgetRawValuePairList (std::size_t scanNum, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const
 get the raw index tof_index and intensities (normalized)
 
- Public Member Functions inherited from pappso::TimsFrameBase
 TimsFrameBase (std::size_t frameId, quint32 scanCount)
 constructor for binary independant tims frame
 
 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
 
virtual std::size_t getTotalNumberOfScans () const
 get the number of scans contained in this frame each scan represents an ion mobility slice
 
virtual quint32 getMaximumRawMassIndex () const
 get the maximum raw mass index contained in this frame
 
virtual pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr (std::size_t scan_index) const final
 get the mass spectrum corresponding to a scan index
 
bool checkScanNum (std::size_t scanNum) const
 check that this scan number exists
 
void setAcqDurationInMilliseconds (double acquisition_duration_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 setRtInSeconds (double time)
 
void setMsMsType (quint8 type)
 
unsigned int getMsLevel () const
 
double getRtInSeconds () const
 
std::size_t getId () const
 
double getDriftTimeInMilliseconds (std::size_t scan_index) const
 get drift time of a scan number in milliseconds
 
double getOneOverK0Transformation (std::size_t scan_index) const
 get 1/K0 value of a given scan (mobility value)
 
std::size_t getScanIndexFromOneOverK0 (double one_over_k0) const
 get the scan number from a given 1/Ko mobility value
 
double getVoltageTransformation (std::size_t scanNum) const
 get voltage for a given scan number
 
pappso::Trace getTraceFromTofIndexIntensityMap (TimsDataFastMap &accumulated_scans) const
 transform accumulation of raw scans into a real mass spectrum
 
virtual const MzCalibrationInterfaceSPtrgetMzCalibrationInterfaceSPtr () const final
 get the MzCalibration model to compute mz and TOF for this frame
 
void setMzCalibrationInterfaceSPtr (MzCalibrationInterfaceSPtr mzCalibration)
 
virtual Trace getIonMobilityTraceByTofIndexRange (std::size_t tof_index_begin, std::size_t tof_index_end, Enums::XicExtractMethod method, std::size_t scan_index_begin, std::size_t scan_index_end) const
 get a mobility trace cumulating intensities inside the given mass index range
 

Protected Member Functions

 TimsFrame (std::size_t timsId, quint32 scanNum)
 constructor for binary independant tims frame
 
void extractTimsXicListInRtRange (std::vector< XicCoordTims * >::iterator &itXicListbegin, std::vector< XicCoordTims * >::iterator &itXicListend, Enums::XicExtractMethod method) const
 
virtual void cumulateScan (std::size_t scanNum, TimsDataFastMap &accumulate_into) const
 cumulate a scan into a map
 
virtual void cumulateScan2 (std::size_t scanNum, TimsDataFastMap &accumulate_into, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const
 
virtual pappso::TraceSPtr getRawTraceSPtr (std::size_t scanNum) const
 get the raw index tof_index and intensities (normalized)
 
- Protected Member Functions inherited from pappso::TimsFrameBase
virtual std::vector< TofIndexIntensityPair > & downgradeResolutionOfTofIndexIntensityPairList (std::size_t tof_index_merge_window, std::vector< TofIndexIntensityPair > &spectrum) const
 Downgrade the TOF index resolution to lower the number of real m/z computations.
 

Protected Attributes

QByteArray m_binaryData
 
- Protected Attributes inherited from pappso::TimsFrameBase
quint32 m_scanCount
 total number of scans contained in this frame
 
std::size_t m_frameId
 Tims frame database id (the SQL identifier of this frame)
 
double m_acqDurationInMilliseconds = 0
 acquisition duration in milliseconds
 
quint8 m_msMsType = 0
 
double m_rtInSeconds = 0
 retention time
 
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
 
std::size_t getScanOffset (std::size_t scanNum) const
 get offset for this spectrum in the binary file
 

Private Attributes

friend TimsDirectXicExtractor
 

Detailed Description

Todo
write docs

Definition at line 53 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 60 of file timsframe.cpp.

64 : TimsFrameBase(timsId, scanNum)
65{
66 // langella@themis:~/developpement/git/bruker/cbuild$
67 // ./src/sample/timsdataSamplePappso
68 // /gorgone/pappso/fichiers_fabricants/Bruker/Demo_TimsTOF_juin2019/Samples/1922001/1922001-1_S-415_Pep_Pur-1ul_Slot1-10_1_2088.d/
69 // qDebug() << timsId;
70
71 m_binaryData.resize(len);
72
73 if(p_bytes != nullptr)
74 {
75 unshufflePacket(p_bytes);
76 }
77 else
78 {
79 if(m_scanCount == 0)
80 {
81
82 throw pappso::PappsoException(
83 QObject::tr("TimsFrame::TimsFrame(%1,%2,nullptr,%3) FAILED")
84 .arg(m_frameId)
85 .arg(m_scanCount)
86 .arg(len));
87 }
88 }
89}
TimsFrameBase(std::size_t frameId, quint32 scanCount)
constructor for binary independant tims frame
quint32 m_scanCount
total number of scans contained in this frame
std::size_t m_frameId
Tims frame database id (the SQL identifier of this frame)
QByteArray m_binaryData
Definition timsframe.h:288
void unshufflePacket(const char *src)
unshuffle data packet of tims compression type 2

References pappso::TimsFrameBase::TimsFrameBase(), m_binaryData, pappso::TimsFrameBase::m_frameId, pappso::TimsFrameBase::m_scanCount, and unshufflePacket().

Referenced by TimsFrame(), pappso::TimsFrameType1::TimsFrameType1(), pappso::TimsFrameType1::TimsFrameType1(), and pappso::TimsFrame::XicComputeStructure::XicComputeStructure().

◆ TimsFrame() [2/3]

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

Copy constructor

Parameters
otherTODO

Definition at line 91 of file timsframe.cpp.

91 : TimsFrameBase(other)
92{
93}

References TimsFrame(), and pappso::TimsFrameBase::TimsFrameBase().

◆ ~TimsFrame()

pappso::TimsFrame::~TimsFrame ( )
virtual

Destructor

Definition at line 95 of file timsframe.cpp.

96{
97}

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

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

References pappso::TimsFrameBase::TimsFrameBase().

Member Function Documentation

◆ combineScansInTofIndexIntensityMap() [1/2]

void pappso::TimsFrame::combineScansInTofIndexIntensityMap ( TimsDataFastMap & rawSpectrum,
std::size_t scan_index_begin,
std::size_t scan_index_end ) 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 673 of file timsframe.cpp.

676{
677 // qDebug() << "begin mobility_scan_begin=" << mobility_scan_begin
678 //<< " mobility_scan_end=" << mobility_scan_end;
679
680 if(m_binaryData.size() == 0)
681 return;
682 try
683 {
684
685 std::size_t mobility_scan_max = scan_index_end + 1;
686 // if (mobility_scan_max > m_scanCount) mobility_scan_max = m_scanCount;
687 // qDebug();
688 for(std::size_t i = scan_index_begin; i < mobility_scan_max; i++)
689 {
690 // qDebug() << i;
691 cumulateScan(i, rawSpectrum);
692 // qDebug() << i;
693
694 // local_accumulationTime += m_accumulationTime;
695 }
696 }
697
698 catch(std::exception &error)
699 {
700 qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
701 .arg(__FUNCTION__)
702 .arg(scan_index_begin)
703 .arg(scan_index_end)
704 .arg(error.what());
705 }
706
707 // qDebug() << "end";
708}
virtual void cumulateScan(std::size_t scanNum, TimsDataFastMap &accumulate_into) const
cumulate a scan into a map

References cumulateScan(), and m_binaryData.

◆ combineScansInTofIndexIntensityMap() [2/2]

void pappso::TimsFrame::combineScansInTofIndexIntensityMap ( TimsDataFastMap & tof_index_intensity_map,
std::size_t scan_index_begin,
std::size_t scan_index_end,
quint32 tof_index_begin,
quint32 tof_index_end ) const
overridevirtual

cumulate scan list into a trace into a raw spectrum map The intensities are NOT normalized with respect to the frame accumulation time

Parameters
tof_index_intensity_mapsimple map of integers to cumulate raw counts
scan_index_beginscan index in the frame in the order it lies in binary file, from 0 to N-1
scan_index_endscan index in the frame in the order it lies in binary file, from 0 to N-1
tof_index_begin
tof_index_end

Reimplemented from pappso::TimsFrameBase.

Definition at line 712 of file timsframe.cpp.

717{
718 // qDebug() << "tof_index_begin=" << tof_index_begin
719 // << " tof_index_end=" << tof_index_end;
720
721 //<< " mobility_scan_end=" << mobility_scan_end;
722
723 if(m_binaryData.size() == 0)
724 return;
725 try
726 {
727
728 std::size_t mobility_scan_max = scan_index_end + 1;
729 // if (mobility_scan_max > m_scanCount) mobility_scan_max = m_scanCount;
730 // qDebug();
731 for(std::size_t i = scan_index_begin; i < mobility_scan_max; i++)
732 {
733 // qDebug() << i;
734 cumulateScan2(i, rawSpectrum, tof_index_begin, tof_index_end);
735 // qDebug() << i << rawSpectrum.getTofIndexList().size();
736 // local_accumulationTime += m_accumulationTime;
737 }
738 }
739
740 catch(std::exception &error)
741 {
742 qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
743 .arg(__FUNCTION__)
744 .arg(scan_index_begin)
745 .arg(scan_index_end)
746 .arg(error.what());
747 }
748
749 // qDebug() << "end";
750}
virtual void cumulateScan2(std::size_t scanNum, TimsDataFastMap &accumulate_into, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const

References cumulateScan2(), and m_binaryData.

◆ combineScansToTraceWithDowngradedMzResolution()

Trace pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution ( std::size_t mzindex_merge_window,
std::size_t scanNumBegin,
std::size_t scanNumEnd,
quint32 & mz_minimum_index,
quint32 & mz_maximum_index ) const
overridevirtual

cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time to leverage computing performance, this function decreases the mz resolution

Parameters
mzindex_merge_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.
scanNumBeginscan number in the frame in the order it lies in binary file, from 0 to N-1
scanNumEndscan number in the frame in the order it lies in binary file, from 0 to N-1
mz_minimum_indexreport the minimum mz index contained in the resulting trace
mz_maximum_indexreport the maximum mz index contained in the resulting trace

Reimplemented from pappso::TimsFrameBase.

Definition at line 447 of file timsframe.cpp.

453{
454 // qDebug();
455
456 Trace new_trace;
457
458 try
459 {
460 if(m_binaryData.size() == 0)
461 {
462 qDebug() << "The frame is empty, returning empty trace.";
463 return new_trace;
464 }
465
466 // Allocate a map for (TOF,intensity) pairs to
467 // accumulate ion mobility scans.
468
469 TimsDataFastMap &raw_spectrum =
471 raw_spectrum.clear();
472 // double local_accumulationTime = 0;
473
474 std::size_t mobility_scan_max = mobility_scan_end + 1;
475
476 for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
477 {
478 // qDebug() << "Going to cumulate currently iterated mobility scan:"
479 // << i;
480 cumulateScan(i, raw_spectrum);
481 // qDebug() << "Done cumulating currently iterated mobility scan:" <<
482 // i;
483
484 // local_accumulationTime += m_accumulationTime;
485 }
486
487 // qDebug();
488
489 pappso::DataPoint data_point_cumul;
490
491 MzCalibrationInterface *mz_calibration_p =
493
494 // If the caller asks that m/z values be binned larger than they are,
495 // ask that the m/z raw map be reduced in resolution.
496 if(mz_index_merge_window > 0)
497 {
498 raw_spectrum.downsizeMzRawMap(mz_index_merge_window);
499 }
500
501 // Store the first mz index and the last mz index of the current spectrum.
502 // The values are set to the out parameters.
503 mz_minimum_index_out = std::numeric_limits<quint32>::max();
504 mz_maximum_index_out = 0;
505
506 // FIXME: donc je comprends que les index sont contigus
507 // puisqu'on utilise at(key) ?
508 for(quint32 tof_index : raw_spectrum.getTofIndexList())
509 {
510 if(tof_index > mz_maximum_index_out)
511 mz_maximum_index_out = tof_index;
512 if(tof_index < mz_minimum_index_out)
513 mz_minimum_index_out = tof_index;
514
515 // Convert the TOF index to m/z
516 data_point_cumul.x = mz_calibration_p->getMzFromTofIndex(tof_index);
517
518 // Normalization
519 data_point_cumul.y = raw_spectrum.readIntensity(tof_index) *
520 ((double)100.0 / m_acqDurationInMilliseconds);
521
522 // Finally make the data point a new Trace point.
523 new_trace.push_back(data_point_cumul);
524 }
525
526 // qDebug() << "At this point we have mz_minimum_index_out:"
527 // << mz_minimum_index_out
528 // << "and mz_maximum_index_out:" << mz_maximum_index_out;
529
530 // FIXME: this does not seem to be necessary since raw_spectrum is a map
531 // with auto-sorting on the keys which are quint32.
532 // new_trace.sortX();
533
534 // qDebug();
535 }
536 catch(std::exception &error)
537 {
538 qDebug() << QString(
539 "Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
540 .arg(mobility_scan_begin, mobility_scan_end)
541 .arg(error.what());
542 }
543
544 // qDebug() << "Returning new trace of size:" << new_trace.size();
545
546 return new_trace;
547}
static TimsDataFastMap & getTimsDataFastMapInstance()
double m_acqDurationInMilliseconds
acquisition duration in milliseconds
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
pappso_double x
Definition datapoint.h:24
pappso_double y
Definition datapoint.h:25

References pappso::TimsDataFastMap::clear(), cumulateScan(), pappso::TimsDataFastMap::downsizeMzRawMap(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsDataFastMap::getTimsDataFastMapInstance(), pappso::TimsDataFastMap::getTofIndexList(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::TimsDataFastMap::readIntensity(), pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by pappso::TimsFramesMsRunReader::readSpectrumCollection2().

◆ combineScansToTraceWithDowngradedMzResolution2()

Trace pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2 ( std::size_t mz_index_merge_window,
double mz_range_begin,
double mz_range_end,
std::size_t mobility_scan_begin,
std::size_t mobility_scan_end,
quint32 & mz_minimum_index_out,
quint32 & mz_maximum_index_out ) const
overridevirtual

cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time to leverage computing performance, this function decreases the mz resolution

Parameters
mzindex_merge_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.
mz_range_begin
mz_range_end
scanNumBeginscan number in the frame in the order it lies in binary file, from 0 to N-1
scanNumEndscan number in the frame in the order it lies in binary file, from 0 to N-1
mz_minimum_indexreport the minimum mz index contained in the resulting trace (constrained by the mz_range_begin)
mz_maximum_indexreport the maximum mz index contained in the resulting trace (constrained by the mz_range_end)

Reimplemented from pappso::TimsFrameBase.

Definition at line 551 of file timsframe.cpp.

559{
560 // qDebug() << "Calling cumulateScansToTraceMzDownResolution2 for both mz and "
561 // "im ranges accounting.";
562
563 Trace new_trace;
564
565 try
566 {
567 if(m_binaryData.size() == 0)
568 {
569 qDebug() << "The frame is empty, returning empty trace.";
570 return new_trace;
571 }
572
573 // Allocate a map for (TOF index,intensity) pairs to
574 // accumulate ion mobility scans.
575
576 TimsDataFastMap &raw_spectrum =
578 raw_spectrum.clear();
579 // double local_accumulationTime = 0;
580
581 std::size_t mobility_scan_max = mobility_scan_end + 1;
582
583 quint32 tof_index_for_mz_range_begin =
584 getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(
585 mz_range_begin);
586 quint32 tof_index_for_mz_range_end =
587 getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(mz_range_end);
588
589 // qDebug() << "TOF index for mz range begin:"
590 // << tof_index_for_mz_range_begin;
591 // qDebug() << "TOF index for mz range end:"
592 // << tof_index_for_mz_range_end;
593
594 for(std::size_t iter = mobility_scan_begin; iter < mobility_scan_max;
595 iter++)
596 {
597 // qDebug() << "Going to cumulate currently iterated mobility scan:"
598 // << iter;
599 cumulateScan2(iter,
600 raw_spectrum,
601 tof_index_for_mz_range_begin,
602 tof_index_for_mz_range_end);
603 // qDebug() << "Done cumulating currently iterated mobility scan:" <<
604 // i;
605
606 // local_accumulationTime += m_accumulationTime;
607 }
608
609 // qDebug();
610
611 pappso::DataPoint data_point_cumul;
612
613 MzCalibrationInterface *mz_calibration_p =
615
616 // If the caller asks that m/z values be binned larger than they are,
617 // ask that the m/z raw map be reduced in resolution.
618 if(mz_index_merge_window > 0)
619 {
620 raw_spectrum.downsizeMzRawMap(mz_index_merge_window);
621 }
622
623 // Store the first mz index and the last mz index of the current spectrum.
624 // The values are set to the out parameters.
625 mz_minimum_index_out = std::numeric_limits<quint32>::max();
626 mz_maximum_index_out = 0;
627
628 // for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
629 for(quint32 tof_index : raw_spectrum.getTofIndexList())
630 {
631 std::size_t intensity = raw_spectrum.readIntensity(tof_index);
632 if(tof_index > mz_maximum_index_out)
633 mz_maximum_index_out = tof_index;
634 if(tof_index < mz_minimum_index_out)
635 mz_minimum_index_out = tof_index;
636
637 // Convert the TOF index to m/z
638 data_point_cumul.x = mz_calibration_p->getMzFromTofIndex(tof_index);
639
640 // Normalization
641 data_point_cumul.y =
642 intensity * ((double)100.0 / m_acqDurationInMilliseconds);
643
644 // Finally make the data point a new Trace point.
645 new_trace.push_back(data_point_cumul);
646 }
647
648 // qDebug() << "At this point we have mz_minimum_index_out:"
649 // << mz_minimum_index_out
650 // << "and mz_maximum_index_out:" << mz_maximum_index_out;
651
652 // FIXME: this does not seem to be necessary since raw_spectrum is a map
653 // with auto-sorting on the keys which are quint32.
654 // new_trace.sortX();
655
656 // qDebug();
657 }
658 catch(std::exception &error)
659 {
660 qDebug() << QString(
661 "Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
662 .arg(mobility_scan_begin, mobility_scan_end)
663 .arg(error.what());
664 }
665
666 // qDebug() << "Returning new trace of size:" << new_trace.size();
667
668 return new_trace;
669}

References pappso::TimsDataFastMap::clear(), cumulateScan2(), pappso::TimsDataFastMap::downsizeMzRawMap(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsDataFastMap::getTimsDataFastMapInstance(), pappso::TimsDataFastMap::getTofIndexList(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::TimsDataFastMap::readIntensity(), pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by pappso::TimsFramesMsRunReader::readSpectrumCollection2().

◆ cumulateScan()

void pappso::TimsFrame::cumulateScan ( std::size_t scanNum,
TimsDataFastMap & 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 304 of file timsframe.cpp.

306{
307 // qDebug();
308
309 if(m_binaryData.size() == 0)
310 return;
311 // qDebug();
312
313 // checkScanNum(scanNum);
314
315 std::size_t scan_size = getScanPeakCount(scanNum);
316
317 std::size_t scan_offset = getScanOffset(scanNum);
318
319 qint32 previous = -1;
320 for(std::size_t i = 0; i < scan_size; i++)
321 {
322 quint32 x = (*(quint32 *)((m_binaryData.constData() + (scan_offset * 4) +
323 (i * 8))) +
324 previous);
325 quint32 y = (*(quint32 *)(m_binaryData.constData() + (scan_offset * 4) +
326 (i * 8) + 4));
327
328 previous = x;
329 // qDebug() << "x=" << x << " y=" << y;
330 accumulate_into.accumulateIntensity(x, y);
331 }
332
333 qDebug();
334}
virtual std::size_t getScanPeakCount(std::size_t scanIndex) const override
get the number of peaks in this spectrum need the binary file
std::size_t getScanOffset(std::size_t scanNum) const
get offset for this spectrum in the binary file

References pappso::TimsDataFastMap::accumulateIntensity(), getScanOffset(), getScanPeakCount(), m_binaryData, pappso::x, and pappso::y.

Referenced by combineScansInTofIndexIntensityMap(), combineScansToTraceWithDowngradedMzResolution(), and cumulateScansToTrace().

◆ cumulateScan2()

void pappso::TimsFrame::cumulateScan2 ( std::size_t scanNum,
TimsDataFastMap & accumulate_into,
quint32 accepted_tof_index_range_begin,
quint32 accepted_tof_index_range_end ) const
protectedvirtual

Reimplemented in pappso::TimsFrameType1.

Definition at line 338 of file timsframe.cpp.

342{
343 // qDebug();
344
345 if(m_binaryData.size() == 0)
346 return;
347
348 // checkScanNum(scanNum);
349
350 std::size_t scan_size = getScanPeakCount(scanNum);
351 std::size_t scan_offset = getScanOffset(scanNum);
352 qint32 previous = -1;
353
354 for(std::size_t i = 0; i < scan_size; i++)
355 {
356 quint32 x = (*(quint32 *)((m_binaryData.constData() + (scan_offset * 4) +
357 (i * 8))) +
358 previous);
359
360 previous = x;
361
362 if(x < accepted_tof_index_range_begin)
363 {
364
365 // qDebug() << "TOF index still not in range, x:" << x;
366 continue;
367 }
368 if(x > accepted_tof_index_range_end)
369 {
370 // qDebug() << "TOF index already out of range, x:" << x;
371 break;
372 }
373
374 // qDebug() << "TOF index in range, x:" << x;
375
376 quint32 y = (*(quint32 *)(m_binaryData.constData() + (scan_offset * 4) +
377 (i * 8) + 4));
378
379 accumulate_into.accumulateIntensity(x, y);
380 }
381
382 // qDebug();
383}

References pappso::TimsDataFastMap::accumulateIntensity(), getScanOffset(), getScanPeakCount(), m_binaryData, pappso::x, and pappso::y.

Referenced by combineScansInTofIndexIntensityMap(), and combineScansToTraceWithDowngradedMzResolution2().

◆ cumulateScanIntensities()

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

Reimplemented from pappso::TimsFrameBase.

Definition at line 219 of file timsframe.cpp.

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

References getScanOffset(), getScanPeakCount(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::x, and pappso::y.

Referenced by cumulateScanRangeIntensities().

◆ cumulateScanRangeIntensities()

quint64 pappso::TimsFrame::cumulateScanRangeIntensities ( std::size_t mobility_scan_begin,
std::size_t mobility_scan_end ) const
overridevirtual

...

Parameters
mobility_scan_beginp_mobility_scan_begin:...
mobility_scan_endp_mobility_scan_end:...
Returns
quint64

Reimplemented from pappso::TimsFrameBase.

Definition at line 266 of file timsframe.cpp.

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

References cumulateScanIntensities(), and m_binaryData.

Referenced by pappso::TimsFramesMsRunReader::computeTicChromatogram().

◆ cumulateScansToTrace()

Trace pappso::TimsFrame::cumulateScansToTrace ( std::size_t scanIndexBegin,
std::size_t scanIndexEnd ) 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 387 of file timsframe.cpp.

389{
390 // qDebug();
391
392 Trace new_trace;
393
394 try
395 {
396 if(m_binaryData.size() == 0)
397 return new_trace;
398 TimsDataFastMap &raw_spectrum =
400 raw_spectrum.clear();
401 // double local_accumulationTime = 0;
402
403 std::size_t mobility_scan_max = mobility_scan_end + 1;
404 qDebug();
405 for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
406 {
407 // qDebug() << i;
408 cumulateScan(i, raw_spectrum);
409 // qDebug() << i;
410
411 // local_accumulationTime += m_accumulationTime;
412 }
413
414 // qDebug();
415
416 pappso::DataPoint data_point_cumul;
417
418
419 MzCalibrationInterface *mz_calibration_p =
421
422
423 for(quint32 tof_index : raw_spectrum.getTofIndexList())
424 {
425 data_point_cumul.x = mz_calibration_p->getMzFromTofIndex(tof_index);
426 // normalization
427 data_point_cumul.y = raw_spectrum.readIntensity(tof_index) *
428 ((double)100.0 / m_acqDurationInMilliseconds);
429 new_trace.push_back(data_point_cumul);
430 }
431 new_trace.sortX();
432
433 // qDebug();
434 }
435
436 catch(std::exception &error)
437 {
438 qDebug() << QString(
439 "Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
440 .arg(mobility_scan_begin, mobility_scan_end)
441 .arg(error.what());
442 }
443 return new_trace;
444}

References pappso::TimsDataFastMap::clear(), cumulateScan(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsDataFastMap::getTimsDataFastMapInstance(), pappso::TimsDataFastMap::getTofIndexList(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::TimsDataFastMap::readIntensity(), 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,
Enums::XicExtractMethod method ) const
protected

Definition at line 870 of file timsframe.cpp.

874{
875 // qDebug() << std::distance(itXicListbegin, itXicListend);
876
877 std::vector<TimsFrame::XicComputeStructure> tmp_xic_list;
878
879 for(auto it = itXicListbegin; it != itXicListend; it++)
880 {
881 tmp_xic_list.push_back(TimsFrame::XicComputeStructure(this, **it));
882
883 // qDebug() << " tmp_xic_struct.mobilityIndexBegin="
884 // << tmp_xic_list.back().mobilityIndexBegin
885 // << " tmp_xic_struct.mobilityIndexEnd="
886 // << tmp_xic_list.back().mobilityIndexEnd;
887
888 // qDebug() << " tmp_xic_struct.mzIndexLowerBound="
889 // << tmp_xic_list.back().mzIndexLowerBound
890 // << " tmp_xic_struct.mzIndexUpperBound="
891 // << tmp_xic_list.back().mzIndexUpperBound;
892 }
893 if(tmp_xic_list.size() == 0)
894 return;
895 /*
896 std::sort(tmp_xic_list.begin(), tmp_xic_list.end(), [](const
897 TimsXicStructure &a, const TimsXicStructure &b) { return
898 a.mobilityIndexBegin < b.mobilityIndexBegin;
899 });
900 */
901 std::vector<std::size_t> unique_scan_num_list;
902 for(auto &&struct_xic : tmp_xic_list)
903 {
904 for(std::size_t scan = struct_xic.mobilityIndexBegin;
905 (scan <= struct_xic.mobilityIndexEnd) && (scan < m_scanCount);
906 scan++)
907 {
908 unique_scan_num_list.push_back(scan);
909 }
910 }
911 std::sort(unique_scan_num_list.begin(), unique_scan_num_list.end());
912 auto it_scan_num_end =
913 std::unique(unique_scan_num_list.begin(), unique_scan_num_list.end());
914 auto it_scan_num = unique_scan_num_list.begin();
915
916 while(it_scan_num != it_scan_num_end)
917 {
918 TraceSPtr ms_spectrum = getRawTraceSPtr(*it_scan_num);
919 // qDebug() << ms_spectrum.get()->toString();
920 for(auto &&tmp_xic_struct : tmp_xic_list)
921 {
922 if(((*it_scan_num) >= tmp_xic_struct.mobilityIndexBegin) &&
923 ((*it_scan_num) <= tmp_xic_struct.mobilityIndexEnd))
924 {
925 if(method == Enums::XicExtractMethod::max)
926 {
927 tmp_xic_struct.tmpIntensity +=
928 ms_spectrum.get()->maxY(tmp_xic_struct.mzIndexLowerBound,
929 tmp_xic_struct.mzIndexUpperBound);
930
931 // qDebug() << "tmp_xic_struct.tmpIntensity="
932 // << tmp_xic_struct.tmpIntensity;
933 }
934 else
935 {
936 // sum
937 tmp_xic_struct.tmpIntensity +=
938 ms_spectrum.get()->sumY(tmp_xic_struct.mzIndexLowerBound,
939 tmp_xic_struct.mzIndexUpperBound);
940
941 // qDebug() << "tmp_xic_struct.tmpIntensity="
942 // << tmp_xic_struct.tmpIntensity;
943 }
944 }
945 }
946 it_scan_num++;
947 }
948
949 for(auto &&tmp_xic_struct : tmp_xic_list)
950 {
951 if(tmp_xic_struct.tmpIntensity != 0)
952 {
953 // qDebug() << tmp_xic_struct.xic_ptr;
954
955 tmp_xic_struct.xic_ptr->push_back(
956 {m_rtInSeconds, tmp_xic_struct.tmpIntensity});
957 }
958 }
959
960 // qDebug();
961}
double m_rtInSeconds
retention time
virtual pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const
get the raw index tof_index and intensities (normalized)
@ max
maximum of intensities
Definition types.h:280
std::shared_ptr< Trace > TraceSPtr
Definition trace.h:135

References getRawTraceSPtr(), pappso::TimsFrameBase::m_rtInSeconds, pappso::TimsFrameBase::m_scanCount, and pappso::Enums::max.

Referenced by pappso::TimsDirectXicExtractor::protectedExtractXicCoordSPtrList().

◆ getMassSpectrumSPtr()

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

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

Parameters
scan_indexscan index in the frame in the order it lies in binary file, from 0 to N-1 (this is the mobility index)

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 753 of file timsframe.cpp.

754{
755
756 // qDebug() << " scanNum=" << scanNum;
757
758 checkScanNum(scanNum);
759
760 // qDebug();
761
762 pappso::MassSpectrumSPtr mass_spectrum_sptr =
763 std::make_shared<pappso::MassSpectrum>();
764 // std::vector<DataPoint>
765
766 if(m_binaryData.size() == 0)
767 return mass_spectrum_sptr;
768
769 // qDebug();
770
771 std::size_t size = getScanPeakCount(scanNum);
772
773 std::size_t offset = getScanOffset(scanNum);
774
775 MzCalibrationInterface *mz_calibration_p =
777
778
779 qint32 previous = -1;
780 qint32 tof_index;
781 // std::vector<quint32> index_list;
782 DataPoint data_point;
783 for(std::size_t i = 0; i < size; i++)
784 {
785 tof_index =
786 (*(quint32 *)((m_binaryData.constData() + (offset * 4) + (i * 8))) +
787 previous);
788 data_point.y =
789 (*(quint32 *)(m_binaryData.constData() + (offset * 4) + (i * 8) + 4));
790
791 // intensity normalization
792 data_point.y *= 100.0 / m_acqDurationInMilliseconds;
793
794 previous = tof_index;
795
796
797 // mz calibration
798 data_point.x = mz_calibration_p->getMzFromTofIndex(tof_index);
799 mass_spectrum_sptr.get()->push_back(data_point);
800 }
801
802 // qDebug();
803
804 return mass_spectrum_sptr;
805}
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
std::shared_ptr< MassSpectrum > MassSpectrumSPtr

References pappso::TimsFrameBase::checkScanNum(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), getScanOffset(), getScanPeakCount(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::DataPoint::x, and pappso::DataPoint::y.

◆ getMobilityScan()

Trace pappso::TimsFrame::getMobilityScan ( std::size_t scanNum,
std::size_t mz_index_merge_window,
double mz_range_begin,
double mz_range_end,
quint32 & mz_minimum_index_out,
quint32 & mz_maximum_index_out ) const
overridevirtual

get a single mobility scan m/z + intensities

Parameters
scanNumscan number in the frame in the order it lies in binary file, from 0 to N-1
mzindex_merge_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.
mz_range_begin
mz_range_end
mz_minimum_indexreport the minimum mz index contained in the resulting trace (constrained by the mz_range_begin)
mz_maximum_indexreport the maximum mz index contained in the resulting trace (constrained by the mz_range_end)

Reimplemented from pappso::TimsFrameBase.

Definition at line 809 of file timsframe.cpp.

815{
816 // qDebug() << "mz_range_begin:" << mz_range_begin
817 // << "mz_range_end:" << mz_range_end
818 // << "mz_index_merge_window:" << mz_index_merge_window;
819
820 Trace spectrum;
821
822 quint32 mz_index_begin = 0;
823 quint32 mz_index_end = std::numeric_limits<quint32>::max();
824
825 if(mz_range_end > 0)
826 {
827 // qDebug() << "m/z range is requested.";
828
829 mz_index_begin =
830 msp_mzCalibration.get()->getTofIndexFromMz(mz_range_begin);
831 mz_index_end = msp_mzCalibration.get()->getTofIndexFromMz(mz_range_end);
832 }
833
834 // qDebug() << "After conversion of mz indices, mz_index_begin:"
835 // << mz_index_begin << "mz_index_end;" << mz_index_end;
836
837 auto raw_spectrum =
838 getRawValuePairList(scanNum, mz_index_begin, mz_index_end);
839
840 // qDebug() << " raw_spectrum.size();" << raw_spectrum.size();
841
842 if(mz_index_merge_window > 0)
843 {
844 // qDebug() << "mz_index_merge_window;=" << mz_index_merge_window
845 // << " raw_spectrum.size()=" << raw_spectrum.size();
847 mz_index_merge_window, raw_spectrum);
848 }
849
850 if(raw_spectrum.size() > 0)
851 {
852 mz_minimum_index_out = raw_spectrum.front().tof_index;
853 mz_maximum_index_out = raw_spectrum.back().tof_index;
854
855 for(auto &&element : raw_spectrum)
856 {
857 spectrum.push_back(DataPoint(
858 msp_mzCalibration.get()->getMzFromTofIndex(element.tof_index),
859 static_cast<double>(element.intensity_index)));
860
861 // intensity normalization
862 spectrum.back().y *= 100.0 / m_acqDurationInMilliseconds;
863 }
864 }
865
866 return spectrum;
867}
MzCalibrationInterfaceSPtr msp_mzCalibration
virtual std::vector< TofIndexIntensityPair > & downgradeResolutionOfTofIndexIntensityPairList(std::size_t tof_index_merge_window, std::vector< TofIndexIntensityPair > &spectrum) const
Downgrade the TOF index resolution to lower the number of real m/z computations.
virtual std::vector< TofIndexIntensityPair > getRawValuePairList(std::size_t scanNum, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const
get the raw index tof_index and intensities (normalized)

References pappso::TimsFrameBase::downgradeResolutionOfTofIndexIntensityPairList(), getRawValuePairList(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, and pappso::TimsFrameBase::msp_mzCalibration.

Referenced by pappso::TimsMsRunReader::readSpectrumCollection2().

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

966{
967
968 // qDebug();
969
970 pappso::TraceSPtr trace_sptr = std::make_shared<pappso::Trace>();
971 // std::vector<DataPoint>
972
973 if(m_binaryData.size() == 0)
974 return trace_sptr;
975 // qDebug();
976
977 std::size_t size = getScanPeakCount(scanNum);
978
979 std::size_t offset = getScanOffset(scanNum);
980
981 qint32 previous = -1;
982 std::vector<quint32> index_list;
983 for(std::size_t i = 0; i < size; i++)
984 {
985 DataPoint data_point(
986 (*(quint32 *)((m_binaryData.constData() + (offset * 4) + (i * 8))) +
987 previous),
988 (*(quint32 *)(m_binaryData.constData() + (offset * 4) + (i * 8) + 4)));
989
990 // intensity normalization
991 data_point.y *= 100.0 / m_acqDurationInMilliseconds;
992
993 previous = data_point.x;
994 trace_sptr.get()->push_back(data_point);
995 }
996 // qDebug();
997 return trace_sptr;
998}

References getScanOffset(), getScanPeakCount(), pappso::TimsFrameBase::m_acqDurationInMilliseconds, m_binaryData, pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by extractTimsXicListInRtRange().

◆ getRawValuePairList()

std::vector< TimsFrame::TofIndexIntensityPair > pappso::TimsFrame::getRawValuePairList ( std::size_t scanNum,
quint32 accepted_tof_index_range_begin,
quint32 accepted_tof_index_range_end ) const
virtual

get the raw index tof_index and intensities (normalized)

Parameters
scanNumthe scan number to extract
accepted_tof_index_range_beginmz index begin
accepted_tof_index_range_endmz index end
Returns
vector of RawValuePair

Reimplemented in pappso::TimsFrameType1.

Definition at line 1002 of file timsframe.cpp.

1005{
1006 // qDebug() << accepted_tof_index_range_begin;
1007
1008 std::vector<TimsFrame::TofIndexIntensityPair> raw_value_pairs;
1009 // std::vector<DataPoint>
1010
1011 if(m_binaryData.size() == 0)
1012 return raw_value_pairs;
1013 // qDebug();
1014
1015 std::size_t size = getScanPeakCount(scanNum);
1016
1017 std::size_t offset = getScanOffset(scanNum);
1018
1019 // qDebug() << size;
1020 qint32 previous = -1;
1021 std::vector<quint32> index_list;
1022 for(std::size_t i = 0; i < size; i++)
1023 {
1024
1025 // qDebug() << i;
1026 TimsFrame::TofIndexIntensityPair raw_value_pair(
1027 {(*(quint32 *)((m_binaryData.constData() + (offset * 4) + (i * 8))) +
1028 previous),
1029 (*(quint32 *)(m_binaryData.constData() + (offset * 4) + (i * 8) +
1030 4))});
1031
1032 previous = raw_value_pair.tof_index;
1033 if(raw_value_pair.tof_index < accepted_tof_index_range_begin)
1034 {
1035 // qDebug() << "TOF index still not in range, x:" << x;
1036 continue;
1037 }
1038 if(raw_value_pair.tof_index > accepted_tof_index_range_end)
1039 {
1040 // qDebug() << "TOF index already out of range, x:" << x;
1041 break;
1042 }
1043
1044 raw_value_pairs.push_back(raw_value_pair);
1045 }
1046 // qDebug() << raw_value_pairs.size();
1047 return raw_value_pairs;
1048}

References getScanOffset(), getScanPeakCount(), m_binaryData, and pappso::TimsFrameBase::TofIndexIntensityPair::tof_index.

Referenced by getMobilityScan().

◆ getScanIntensityList()

std::vector< quint32 > pappso::TimsFrame::getScanIntensityList ( 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 195 of file timsframe.cpp.

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

References pappso::TimsFrameBase::checkScanNum(), getScanOffset(), getScanPeakCount(), and m_binaryData.

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

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

References m_binaryData.

Referenced by cumulateScan(), cumulateScan2(), cumulateScanIntensities(), getMassSpectrumSPtr(), getRawTraceSPtr(), getRawValuePairList(), getScanIntensityList(), and getScanTofIndexList().

◆ getScanPeakCount()

std::size_t pappso::TimsFrame::getScanPeakCount ( std::size_t scanIndex) const
overridevirtual

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

Parameters
scanIndexscan index in the frame in the order it lies in frame's binary data, from 0 to N-1

Reimplemented from pappso::TimsFrameBase.

Reimplemented in pappso::TimsFrameType1.

Definition at line 128 of file timsframe.cpp.

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

References pappso::TimsFrameBase::checkScanNum(), m_binaryData, and pappso::TimsFrameBase::m_scanCount.

Referenced by cumulateScan(), cumulateScan2(), cumulateScanIntensities(), getMassSpectrumSPtr(), getRawTraceSPtr(), getRawValuePairList(), getScanIntensityList(), and getScanTofIndexList().

◆ getScanTofIndexList()

std::vector< quint32 > pappso::TimsFrame::getScanTofIndexList ( 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 170 of file timsframe.cpp.

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

References pappso::TimsFrameBase::checkScanNum(), getScanOffset(), getScanPeakCount(), and m_binaryData.

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

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

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

References m_binaryData.

Referenced by TimsFrame().

Member Data Documentation

◆ m_binaryData

◆ TimsDirectXicExtractor

friend pappso::TimsFrame::TimsDirectXicExtractor
private

Definition at line 55 of file timsframe.h.


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