libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::TimsFrameBase Class Reference

#include <timsframebase.h>

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

Classes

struct  RawValuePair
 

Public Member Functions

 TimsFrameBase (std::size_t timsId, quint32 scanNum)
 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 getNbrPeaks (std::size_t scanNum) const
 get the number of peaks in this spectrum need the binary file
 
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 MassSpectrumSPtr getMassSpectrumSPtr (std::size_t scanNum) const
 get Mass spectrum with peaks for this scan number need the binary file
 
virtual pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr (std::size_t scanNum) const final
 get the mass spectrum corresponding to a scan number
 
virtual Trace cumulateScansToTrace (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
 
virtual Trace cumulateScansToTraceMzDownResolution (std::size_t mzindex_merge_window, std::size_t scanNumBegin, std::size_t scanNumEnd, quint32 &minimum_index, quint32 &maximum_index) const
 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 cumulateScansToTraceMzDownResolution2 (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
 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 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
 get a single mobility scan m/z + intensities
 
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
 
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
 
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
 
double getOneOverK0Transformation (std::size_t scanNum) const
 get 1/K0 value of a given scan (mobility value)
 
std::size_t getScanNumFromOneOverK0 (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 getTraceFromCumulatedScans (std::map< quint32, quint32 > &accumulated_scans) const
 transform accumulation of raw scans into a real mass spectrum
 
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
 
virtual const MzCalibrationInterfaceSPtrgetMzCalibrationInterfaceSPtr () const final
 get the MzCalibration model to compute mz and TOF for this frame
 
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
 
virtual std::vector< quint32 > getScanIntensities (std::size_t scanNum) const
 get raw intensities without transformation from one scan it needs intensity normalization
 
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
 

Protected Member Functions

virtual std::map< quint32, quint32 > & downsizeMzRawMap (std::size_t mzindex_merge_window, std::map< quint32, quint32 > &rawSpectrum) const
 downsize mz resolution to lower the number of real mz computations
 
virtual std::vector< RawValuePair > & downsizeMzRawValuePairList (std::size_t mzindex_merge_window, std::vector< RawValuePair > &spectrum) const
 downsize mz resolution to lower the number of real mz computations
 

Protected Attributes

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)
 
double m_accumulationTime = 0
 accumulation time in milliseconds
 
quint8 m_msMsType = 0
 
double m_time = 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
 

Detailed Description

Todo:
write docs

Definition at line 47 of file timsframebase.h.

Constructor & Destructor Documentation

◆ TimsFrameBase() [1/2]

pappso::TimsFrameBase::TimsFrameBase ( std::size_t  timsId,
quint32  scanNum 
)

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 39 of file timsframebase.cpp.

40{
41 qDebug() << timsId;
42 m_timsId = timsId;
43
44 m_scanNumber = scanNum;
45}
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)

References m_scanNumber, and m_timsId.

◆ TimsFrameBase() [2/2]

pappso::TimsFrameBase::TimsFrameBase ( const TimsFrameBase other)

Copy constructor

Parameters
otherTODO

Definition at line 47 of file timsframebase.cpp.

48{
49}

◆ ~TimsFrameBase()

pappso::TimsFrameBase::~TimsFrameBase ( )
virtual

Destructor

Definition at line 51 of file timsframebase.cpp.

52{
53}

Member Function Documentation

◆ checkScanNum()

bool pappso::TimsFrameBase::checkScanNum ( std::size_t  scanNum) const

check that this scan number exists

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

Definition at line 103 of file timsframebase.cpp.

104{
105 if(scanNum >= m_scanNumber)
106 {
108 QObject::tr("Invalid scan number : scanNum %1 > m_scanNumber %2")
109 .arg(scanNum)
110 .arg(m_scanNumber));
111 }
112
113 return true;
114}

References m_scanNumber.

Referenced by pappso::TimsFrame::getMassSpectrumSPtr(), pappso::TimsFrameType1::getMassSpectrumSPtr(), pappso::TimsFrame::getNbrPeaks(), pappso::TimsFrame::getScanIndexList(), pappso::TimsFrameType1::getScanIndexList(), pappso::TimsFrame::getScanIntensities(), and pappso::TimsFrameType1::getScanIntensities().

◆ cumulateScansInRawMap()

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

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

Parameters
rawSpectrumsimple map of integers to cumulate raw counts
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

Reimplemented in pappso::TimsFrame.

Definition at line 206 of file timsframebase.cpp.

210{
211 throw PappsoException(
212 QObject::tr(
213 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
214 "number begin %1 end %2")
215 .arg(scanNumBegin)
216 .arg(scanNumEnd));
217}

◆ cumulateScansIntensities()

quint64 pappso::TimsFrameBase::cumulateScansIntensities ( std::size_t  scanNumBegin,
std::size_t  scanNumEnd 
) const
virtual

Reimplemented in pappso::TimsFrame.

Definition at line 234 of file timsframebase.cpp.

236{
237 throw PappsoException(
238 QObject::tr(
239 "ERROR unable to cumulateScansInRawMap in TimsFrameBase for scan "
240 "number begin %1 end %2")
241 .arg(scanNumBegin)
242 .arg(scanNumEnd));
243
244 return 0;
245}

◆ cumulateScansToTrace()

Trace pappso::TimsFrameBase::cumulateScansToTrace ( std::size_t  scanNumBegin,
std::size_t  scanNumEnd 
) const
virtual

cumulate spectrum given a scan number range need the binary file The intensities are normalized with respect to the frame accumulation time

Parameters
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

Reimplemented in pappso::TimsFrame.

Definition at line 149 of file timsframebase.cpp.

151{
152 throw PappsoException(
153 QObject::tr("ERROR unable to cumulateScanToTrace in TimsFrameBase for scan "
154 "number begin %1 end %2")
155 .arg(scanNumBegin)
156 .arg(scanNumEnd));
157}

◆ cumulateScansToTraceMzDownResolution()

Trace pappso::TimsFrameBase::cumulateScansToTraceMzDownResolution ( std::size_t  mzindex_merge_window,
std::size_t  scanNumBegin,
std::size_t  scanNumEnd,
quint32 &  minimum_index,
quint32 &  maximum_index 
) const
virtual

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 in pappso::TimsFrame.

Definition at line 160 of file timsframebase.cpp.

166{
167 throw PappsoException(QObject::tr("Non implemented function %1 %2 %3")
168 .arg(__FILE__)
169 .arg(__FUNCTION__)
170 .arg(__LINE__));
171}

◆ cumulateScansToTraceMzDownResolution2()

Trace pappso::TimsFrameBase::cumulateScansToTraceMzDownResolution2 ( 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
virtual

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 in pappso::TimsFrame.

Definition at line 174 of file timsframebase.cpp.

182{
183 throw PappsoException(QObject::tr("Non implemented function %1 %2 %3")
184 .arg(__FILE__)
185 .arg(__FUNCTION__)
186 .arg(__LINE__));
187}

◆ cumulateSingleScanIntensities()

quint64 pappso::TimsFrameBase::cumulateSingleScanIntensities ( std::size_t  scanNum) const
virtual

Reimplemented in pappso::TimsFrame.

Definition at line 221 of file timsframebase.cpp.

222{
223 throw PappsoException(
224 QObject::tr(
225 "ERROR unable to cumulateSingleScanIntensities in TimsFrameBase for scan "
226 "number %1.")
227 .arg(scanNum));
228
229 return 0;
230}

◆ downsizeMzRawMap()

std::map< quint32, quint32 > & pappso::TimsFrameBase::downsizeMzRawMap ( std::size_t  mzindex_merge_window,
std::map< quint32, quint32 > &  rawSpectrum 
) const
protectedvirtual

downsize mz resolution to lower the number of real mz computations

Parameters
mzindex_merge_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.
rawSpectrumthe spectrum to shrink

Definition at line 647 of file timsframebase.cpp.

649{
650 std::map<quint32, quint32> new_spectrum;
651
652 for(auto &pair_mz_intensity : rawSpectrum)
653 {
654 quint32 mzkey = (pair_mz_intensity.first / mzindex_merge_window);
655 mzkey = (mzkey * mzindex_merge_window) + (mzindex_merge_window / 2);
656 auto it = new_spectrum.insert({mzkey, pair_mz_intensity.second});
657 if(it.second == false)
658 {
659 it.first->second += pair_mz_intensity.second;
660 }
661 }
662 rawSpectrum = new_spectrum;
663 return rawSpectrum;
664}

Referenced by pappso::TimsFrame::cumulateScansToTraceMzDownResolution(), and pappso::TimsFrame::cumulateScansToTraceMzDownResolution2().

◆ downsizeMzRawValuePairList()

std::vector< TimsFrameBase::RawValuePair > & pappso::TimsFrameBase::downsizeMzRawValuePairList ( std::size_t  mzindex_merge_window,
std::vector< RawValuePair > &  spectrum 
) const
protectedvirtual

downsize mz resolution to lower the number of real mz computations

Parameters
mzindex_merge_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.
rawSpectrumthe spectrum to shrink

Definition at line 667 of file timsframebase.cpp.

670{
671
672 qDebug() << rawSpectrum.size();
673 std::vector<TimsFrameBase::RawValuePair> new_spectrum;
674
675 TimsFrameBase::RawValuePair current_point;
676 current_point.intensity_index = 0;
677 current_point.mz_tof_index = 0;
678 for(auto &pair_mz_intensity : rawSpectrum)
679 {
680 quint32 mzkey = (pair_mz_intensity.mz_tof_index / mzindex_merge_window);
681 mzkey = (mzkey * mzindex_merge_window) + (mzindex_merge_window / 2);
682
683 if(current_point.mz_tof_index != mzkey)
684 {
685 if(current_point.mz_tof_index > 0)
686 {
687 new_spectrum.push_back(current_point);
688 }
689
690 current_point.intensity_index = pair_mz_intensity.intensity_index;
691 current_point.mz_tof_index = mzkey;
692 }
693 else
694 {
695 current_point.intensity_index += pair_mz_intensity.intensity_index;
696 }
697 }
698
699 if(current_point.mz_tof_index > 0)
700 {
701 new_spectrum.push_back(current_point);
702 }
703 rawSpectrum = new_spectrum;
704 qDebug() << rawSpectrum.size();
705 return rawSpectrum;
706}

References pappso::TimsFrameBase::RawValuePair::intensity_index, and pappso::TimsFrameBase::RawValuePair::mz_tof_index.

Referenced by pappso::TimsFrame::getMobilityScan().

◆ getDriftTime()

double pappso::TimsFrameBase::getDriftTime ( std::size_t  scanNum) const

get drift time of a scan number in milliseconds

Parameters
scanNumscan number in the frame in the order it lies in binary file, from 0 to N-1
Returns
time in milliseconds of mobility delay (drift time)

Definition at line 334 of file timsframebase.cpp.

335{
336 return (m_accumulationTime / (double)m_scanNumber) * ((double)scanNum);
337}
double m_accumulationTime
accumulation time in milliseconds

References m_accumulationTime, and m_scanNumber.

◆ getId()

std::size_t pappso::TimsFrameBase::getId ( ) const

◆ getIonMobilityTraceByMzIndexRange()

Trace pappso::TimsFrameBase::getIonMobilityTraceByMzIndexRange ( std::size_t  mz_index_lower_bound,
std::size_t  mz_index_upper_bound,
XicExtractMethod  method 
) const
virtual

get a mobility trace cumulating intensities inside the given mass index range

Parameters
mz_index_lower_boundraw mass index lower bound
mz_index_upper_boundraw mass index upper bound
methodmax or sum intensities

Definition at line 583 of file timsframebase.cpp.

587{
588 Trace im_trace;
589 DataPoint data_point;
590 for(quint32 i = 0; i < m_scanNumber; i++)
591 {
592 data_point.x = i;
593 data_point.y = 0;
594 qDebug() << "m_scanNumber=" << m_scanNumber << " i=" << i;
595 std::vector<quint32> index_list = getScanIndexList(i);
596 auto it_lower = std::find_if(index_list.begin(),
597 index_list.end(),
598 [mz_index_lower_bound](quint32 to_compare) {
599 if(to_compare < mz_index_lower_bound)
600 {
601 return false;
602 }
603 return true;
604 });
605
606
607 if(it_lower == index_list.end())
608 {
609 }
610 else
611 {
612
613
614 auto it_upper =
615 std::find_if(index_list.begin(),
616 index_list.end(),
617 [mz_index_upper_bound](quint32 to_compare) {
618 if(mz_index_upper_bound >= to_compare)
619 {
620 return false;
621 }
622 return true;
623 });
624 std::vector<quint32> intensity_list = getScanIntensities(i);
625 for(int j = std::distance(index_list.begin(), it_lower);
626 j < std::distance(index_list.begin(), it_upper);
627 j++)
628 {
629 if(method == XicExtractMethod::sum)
630 {
631 data_point.y += intensity_list[j];
632 }
633 else
634 {
635 data_point.y =
636 std::max((double)intensity_list[j], data_point.y);
637 }
638 }
639 }
640 im_trace.push_back(data_point);
641 }
642 qDebug();
643 return im_trace;
644}
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
virtual std::vector< quint32 > getScanIntensities(std::size_t scanNum) const
get raw intensities without transformation from one scan it needs intensity normalization
@ sum
sum of intensities

References getScanIndexList(), getScanIntensities(), m_scanNumber, pappso::sum, pappso::DataPoint::x, and pappso::DataPoint::y.

◆ getMassSpectrumCstSPtr()

pappso::MassSpectrumCstSPtr pappso::TimsFrameBase::getMassSpectrumCstSPtr ( std::size_t  scanNum) const
finalvirtual

get the mass spectrum corresponding to a scan number

Parameters
scanNumthe scan number to retrieve

Definition at line 142 of file timsframebase.cpp.

143{
144 // qDebug();
145
146 return getMassSpectrumSPtr(scanNum);
147}
virtual MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const
get Mass spectrum with peaks for this scan number need the binary file

References getMassSpectrumSPtr().

◆ getMassSpectrumSPtr()

MassSpectrumSPtr pappso::TimsFrameBase::getMassSpectrumSPtr ( std::size_t  scanNum) const
virtual

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 (this is the mobility index)

Reimplemented in pappso::TimsFrame, and pappso::TimsFrameType1.

Definition at line 132 of file timsframebase.cpp.

133{
134 throw PappsoException(
135 QObject::tr(
136 "ERROR unable to getMassSpectrumSPtr in TimsFrameBase for scan number %1")
137 .arg(scanNum));
138}

Referenced by getMassSpectrumCstSPtr().

◆ getMaximumRawMassIndex()

quint32 pappso::TimsFrameBase::getMaximumRawMassIndex ( ) const
virtual

get the maximum raw mass index contained in this frame

Definition at line 547 of file timsframebase.cpp.

548{
549 quint32 max_value = 0;
550 for(quint32 i = 0; i < m_scanNumber; i++)
551 {
552 qDebug() << "m_scanNumber=" << m_scanNumber << " i=" << i;
553 std::vector<quint32> index_list = getScanIndexList(i);
554 auto it = std::max_element(index_list.begin(), index_list.end());
555 if(it != index_list.end())
556 {
557 max_value = std::max(max_value, *it);
558 }
559 }
560 return max_value;
561}

References getScanIndexList(), and m_scanNumber.

◆ getMobilityScan()

Trace pappso::TimsFrameBase::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
virtual

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 in pappso::TimsFrame.

Definition at line 190 of file timsframebase.cpp.

198{
199 throw PappsoException(QObject::tr("Non implemented function %1 %2 %3")
200 .arg(__FILE__)
201 .arg(__FUNCTION__)
202 .arg(__LINE__));
203}

◆ getMsLevel()

unsigned int pappso::TimsFrameBase::getMsLevel ( ) const

Definition at line 262 of file timsframebase.cpp.

263{
264 if(m_msMsType == 0)
265 return 1;
266 return 2;
267}

References m_msMsType.

◆ getMzCalibrationInterfaceSPtr()

const MzCalibrationInterfaceSPtr & pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr ( ) const
finalvirtual

get the MzCalibration model to compute mz and TOF for this frame

Definition at line 514 of file timsframebase.cpp.

515{
516 if(msp_mzCalibration == nullptr)
517 {
518
520 QObject::tr("ERROR in %1, %2, %3 msp_mzCalibration is null")
521 .arg(__FILE__)
522 .arg(__FUNCTION__)
523 .arg(__LINE__));
524 }
525 return msp_mzCalibration;
526}
MzCalibrationInterfaceSPtr msp_mzCalibration

References msp_mzCalibration.

Referenced by pappso::TimsFrame::XicComputeStructure::XicComputeStructure(), pappso::TimsFrame::cumulateScansToTrace(), pappso::TimsFrame::cumulateScansToTraceMzDownResolution(), pappso::TimsFrame::cumulateScansToTraceMzDownResolution2(), pappso::TimsFrame::getMassSpectrumSPtr(), pappso::TimsFrameType1::getMassSpectrumSPtr(), getTraceFromCumulatedScans(), and getTraceFromCumulatedScansBuiltinCentroid().

◆ getNbrPeaks()

std::size_t pappso::TimsFrameBase::getNbrPeaks ( std::size_t  scanNum) const
virtual

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 in pappso::TimsFrame, and pappso::TimsFrameType1.

Definition at line 117 of file timsframebase.cpp.

118{
119 throw PappsoException(
120 QObject::tr(
121 "ERROR unable to get number of peaks in TimsFrameBase for scan number %1")
122 .arg(scanNum));
123}

◆ getOneOverK0Transformation()

double pappso::TimsFrameBase::getOneOverK0Transformation ( std::size_t  scanNum) const

get 1/K0 value of a given scan (mobility value)

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

Definition at line 340 of file timsframebase.cpp.

341{
342 return 1 / (m_timsC6 + (m_timsC7 / getVoltageTransformation(scanNum)));
343}
double getVoltageTransformation(std::size_t scanNum) const
get voltage for a given scan number

References getVoltageTransformation(), m_timsC6, and m_timsC7.

◆ getScanIndexList()

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

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

Reimplemented in pappso::TimsFrame, and pappso::TimsFrameType1.

Definition at line 564 of file timsframebase.cpp.

565{
566 throw PappsoException(
567 QObject::tr(
568 "ERROR unable to getScanIndexList in TimsFrameBase for scan number %1")
569 .arg(scanNum));
570}

Referenced by getIonMobilityTraceByMzIndexRange(), and getMaximumRawMassIndex().

◆ getScanIntensities()

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

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

Reimplemented in pappso::TimsFrame, and pappso::TimsFrameType1.

Definition at line 574 of file timsframebase.cpp.

575{
576 throw PappsoException(
577 QObject::tr(
578 "ERROR unable to getScanIntensities in TimsFrameBase for scan number %1")
579 .arg(scanNum));
580}

Referenced by getIonMobilityTraceByMzIndexRange().

◆ getScanNumFromOneOverK0()

std::size_t pappso::TimsFrameBase::getScanNumFromOneOverK0 ( double  one_over_k0) const

get the scan number from a given 1/Ko mobility value

Parameters
one_over_k0the mobility value to tranform
Returns
integer the scan number in the frame in the order it lies in binary file, from 0 to N-1

Definition at line 347 of file timsframebase.cpp.

348{
349 double temp = 1 / one_over_k0;
350 temp = temp - m_timsC6;
351 temp = temp / m_timsC7;
352 temp = 1 / temp;
353 temp = temp - m_timsDvStart;
354 temp = temp / m_timsSlope + m_timsTtrans + m_timsNdelay;
355 return (std::size_t)std::round(temp);
356}

References m_timsC6, m_timsC7, m_timsDvStart, m_timsNdelay, m_timsSlope, and m_timsTtrans.

◆ getTime()

double pappso::TimsFrameBase::getTime ( ) const

Definition at line 270 of file timsframebase.cpp.

271{
272 return m_time;
273}
double m_time
retention time

References m_time.

◆ getTotalNumberOfScans()

std::size_t pappso::TimsFrameBase::getTotalNumberOfScans ( ) const
virtual

get the number of scans contained in this frame each scan represents an ion mobility slice

Definition at line 126 of file timsframebase.cpp.

127{
128 return m_scanNumber;
129}

References m_scanNumber.

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

◆ getTraceFromCumulatedScans()

pappso::Trace pappso::TimsFrameBase::getTraceFromCumulatedScans ( std::map< quint32, quint32 > &  accumulated_scans) const

transform accumulation of raw scans into a real mass spectrum

Definition at line 374 of file timsframebase.cpp.

376{
377 qDebug();
378 // qDebug();
379 // add flanking peaks
380 pappso::Trace local_trace;
381
382 MzCalibrationInterface *mz_calibration_p =
384
385
386 DataPoint element;
387 for(auto &scan_element : accumulated_scans)
388 {
389 // intensity normalization
390 element.y = ((double)scan_element.second) * 100.0 / m_accumulationTime;
391
392 // mz calibration
393 element.x = mz_calibration_p->getMzFromTofIndex(scan_element.first);
394
395 local_trace.push_back(element);
396 }
397 local_trace.sortX();
398
399 qDebug();
400 // qDebug();
401 return local_trace;
402}
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
A simple container of DataPoint instances.
Definition trace.h:148
void sortX(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1086

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

◆ getTraceFromCumulatedScansBuiltinCentroid()

pappso::Trace pappso::TimsFrameBase::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

Definition at line 405 of file timsframebase.cpp.

407{
408 qDebug();
409 // qDebug();
410 // add flanking peaks
411 std::vector<quint32> keys;
412 transform(begin(accumulated_scans),
413 end(accumulated_scans),
414 back_inserter(keys),
415 [](std::map<quint32, quint32>::value_type const &pair) {
416 return pair.first;
417 });
418 std::sort(keys.begin(), keys.end());
419 pappso::DataPoint data_point_cumul;
420 data_point_cumul.x = 0;
421 data_point_cumul.y = 0;
422
423 pappso::Trace local_trace;
424
425 MzCalibrationInterface *mz_calibration_p =
427
428
429 quint32 last_key = 0;
430
431 for(quint32 key : keys)
432 {
433 if(key == last_key + 1)
434 {
435 // cumulate
436 if(accumulated_scans[key] > accumulated_scans[last_key])
437 {
438 if(data_point_cumul.x == last_key)
439 {
440 // growing peak
441 data_point_cumul.x = key;
442 data_point_cumul.y += accumulated_scans[key];
443 }
444 else
445 {
446 // new peak
447 // flush
448 if(data_point_cumul.y > 0)
449 {
450 // intensity normalization
451 data_point_cumul.y *= 100.0 / m_accumulationTime;
452
453
454 // mz calibration
455 data_point_cumul.x =
456 mz_calibration_p->getMzFromTofIndex(data_point_cumul.x);
457 local_trace.push_back(data_point_cumul);
458 }
459
460 // new point
461 data_point_cumul.x = key;
462 data_point_cumul.y = accumulated_scans[key];
463 }
464 }
465 else
466 {
467 data_point_cumul.y += accumulated_scans[key];
468 }
469 }
470 else
471 {
472 // flush
473 if(data_point_cumul.y > 0)
474 {
475 // intensity normalization
476 data_point_cumul.y *= 100.0 / m_accumulationTime;
477
478
479 // qDebug() << "raw data x=" << data_point_cumul.x;
480 // mz calibration
481 data_point_cumul.x =
482 mz_calibration_p->getMzFromTofIndex(data_point_cumul.x);
483 // qDebug() << "mz=" << data_point_cumul.x;
484 local_trace.push_back(data_point_cumul);
485 }
486
487 // new point
488 data_point_cumul.x = key;
489 data_point_cumul.y = accumulated_scans[key];
490 }
491
492 last_key = key;
493 }
494 // flush
495 if(data_point_cumul.y > 0)
496 {
497 // intensity normalization
498 data_point_cumul.y *= 100.0 / m_accumulationTime;
499
500
501 // mz calibration
502 data_point_cumul.x =
503 mz_calibration_p->getMzFromTofIndex(data_point_cumul.x);
504 local_trace.push_back(data_point_cumul);
505 }
506
507 local_trace.sortX();
508 qDebug();
509 // qDebug();
510 return local_trace;
511}
pappso_double x
Definition datapoint.h:23
pappso_double y
Definition datapoint.h:24

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

◆ getVoltageTransformation()

double pappso::TimsFrameBase::getVoltageTransformation ( std::size_t  scanNum) const

get voltage for a given scan number

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

Definition at line 312 of file timsframebase.cpp.

313{
314 double v = m_timsDvStart +
315 m_timsSlope * ((double)scanNum - m_timsTtrans - m_timsNdelay);
316
317 if(v < m_timsVmin)
318 {
320 QObject::tr("ERROR in TimsFrame::getVoltageTransformation invalid tims "
321 "calibration, v < m_timsVmin"));
322 }
323
324
325 if(v > m_timsVmax)
326 {
328 QObject::tr("ERROR in TimsFrame::getVoltageTransformation invalid tims "
329 "calibration, v > m_timsVmax"));
330 }
331 return v;
332}

References m_timsDvStart, m_timsNdelay, m_timsSlope, m_timsTtrans, m_timsVmax, and m_timsVmin.

Referenced by getOneOverK0Transformation().

◆ hasSameCalibrationData()

bool pappso::TimsFrameBase::hasSameCalibrationData ( const TimsFrameBase other) const
virtual

tells if 2 tims frame has the same calibration data Usefull to know if raw data can be handled between frames

Definition at line 359 of file timsframebase.cpp.

360{
361 if((m_timsDvStart == other.m_timsDvStart) &&
362 (m_timsTtrans == other.m_timsTtrans) &&
363 (m_timsNdelay == other.m_timsNdelay) && (m_timsVmin == other.m_timsVmin) &&
364 (m_timsVmax == other.m_timsVmax) && (m_timsC6 == other.m_timsC6) &&
365 (m_timsC7 == other.m_timsC7) && (m_timsSlope == other.m_timsSlope))
366 {
367 return true;
368 }
369 return false;
370}

References m_timsC6, m_timsC7, m_timsDvStart, m_timsNdelay, m_timsSlope, m_timsTtrans, m_timsVmax, and m_timsVmin.

◆ setAccumulationTime()

void pappso::TimsFrameBase::setAccumulationTime ( double  accumulation_time_ms)

Definition at line 56 of file timsframebase.cpp.

57{
58 m_accumulationTime = accumulation_time_ms;
59}

References m_accumulationTime.

◆ setMsMsType()

void pappso::TimsFrameBase::setMsMsType ( quint8  type)

Definition at line 254 of file timsframebase.cpp.

255{
256
257 qDebug() << " m_msMsType=" << type;
258 m_msMsType = type;
259}

References m_msMsType.

◆ setMzCalibration()

void pappso::TimsFrameBase::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 
)

Definition at line 63 of file timsframebase.cpp.

76{
77
78 /* MzCalibrationModel1 mzCalibration(temperature_correction,
79 digitizerTimebase,
80 digitizerDelay,
81 C0,
82 C1,
83 C2,
84 C3,
85 C4);
86 */
87 msp_mzCalibration = std::make_shared<MzCalibrationModel1>(T1_frame,
88 T2_frame,
89 digitizerTimebase,
90 digitizerDelay,
91 C0,
92 C1,
93 C2,
94 C3,
95 C4,
96 T1_ref,
97 T2_ref,
98 dC1,
99 dC2);
100}

References msp_mzCalibration.

◆ setMzCalibrationInterfaceSPtr()

void pappso::TimsFrameBase::setMzCalibrationInterfaceSPtr ( MzCalibrationInterfaceSPtr  mzCalibration)

Definition at line 529 of file timsframebase.cpp.

531{
532
533 if(mzCalibration == nullptr)
534 {
535
537 QObject::tr("ERROR in %1, %2, %3 msp_mzCalibration is null")
538 .arg(__FILE__)
539 .arg(__FUNCTION__)
540 .arg(__LINE__));
541 }
542 msp_mzCalibration = mzCalibration;
543}

References msp_mzCalibration.

◆ setTime()

void pappso::TimsFrameBase::setTime ( double  time)

Definition at line 248 of file timsframebase.cpp.

249{
250 m_time = time;
251}

References m_time.

◆ setTimsCalibration()

void pappso::TimsFrameBase::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 
)

Definition at line 281 of file timsframebase.cpp.

292{
293 if(tims_model_type != 2)
294 {
295 throw pappso::PappsoException(QObject::tr(
296 "ERROR in TimsFrame::setTimsCalibration tims_model_type != 2"));
297 }
298 m_timsDvStart = C2; // C2 from TimsCalibration
299 m_timsTtrans = C4; // C4 from TimsCalibration
300 m_timsNdelay = C0; // C0 from TimsCalibration
301 m_timsVmin = C8; // C8 from TimsCalibration
302 m_timsVmax = C9; // C9 from TimsCalibration
303 m_timsC6 = C6;
304 m_timsC7 = C7;
305
306
308 (C3 - m_timsDvStart) / C1; // //C3 from TimsCalibration // C2 from
309 // TimsCalibration // C1 from TimsCalibration
310}

References m_timsC6, m_timsC7, m_timsDvStart, m_timsNdelay, m_timsSlope, m_timsTtrans, m_timsVmax, and m_timsVmin.

Member Data Documentation

◆ m_accumulationTime

◆ m_msMsType

quint8 pappso::TimsFrameBase::m_msMsType = 0
protected

Definition at line 364 of file timsframebase.h.

Referenced by getMsLevel(), and setMsMsType().

◆ m_scanNumber

◆ m_time

double pappso::TimsFrameBase::m_time = 0
protected

retention time

Definition at line 368 of file timsframebase.h.

Referenced by pappso::TimsFrame::extractTimsXicListInRtRange(), getTime(), and setTime().

◆ m_timsC6

double pappso::TimsFrameBase::m_timsC6 = 0
protected

◆ m_timsC7

double pappso::TimsFrameBase::m_timsC7 = 0
protected

◆ m_timsDvStart

double pappso::TimsFrameBase::m_timsDvStart = 0
protected

◆ m_timsId

std::size_t pappso::TimsFrameBase::m_timsId
protected

Tims frame database id (the SQL identifier of this frame)

Warning
in sqlite, there is another field called TimsId : this is not that, because it is in fact an offset in bytes in the binary file.

Definition at line 358 of file timsframebase.h.

Referenced by pappso::TimsFrame::TimsFrame(), TimsFrameBase(), pappso::TimsFrameType1::TimsFrameType1(), getId(), and pappso::TimsFrameType1::lzfDecompressScan().

◆ m_timsNdelay

double pappso::TimsFrameBase::m_timsNdelay = 0
protected

◆ m_timsSlope

double pappso::TimsFrameBase::m_timsSlope
protected

◆ m_timsTtrans

double pappso::TimsFrameBase::m_timsTtrans = 0
protected

◆ m_timsVmax

double pappso::TimsFrameBase::m_timsVmax = 0
protected

◆ m_timsVmin

double pappso::TimsFrameBase::m_timsVmin = 0
protected

◆ msp_mzCalibration

MzCalibrationInterfaceSPtr pappso::TimsFrameBase::msp_mzCalibration = nullptr
protected

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