Loading...
Searching...
No Matches
pappso::TimsFrame Class Reference

`#include <timsframe.h>`

Inheritance diagram for pappso::TimsFrame:

## 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
virtual Trace | cumulateScansToTrace (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
| cumulate scan list into a trace
virtual Trace | cumulateScansToTraceMzDownResolution (std::size_t mzindex_merge_window, std::size_t scanNumBegin, std::size_t scanNumEnd, quint32 &minimum_index, quint32 &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
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
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
virtual quint64 | cumulateSingleScanIntensities (std::size_t scanNum) const override
virtual quint64 | cumulateScansIntensities (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
| ...
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
virtual std::vector< quint32 > | getScanIntensities (std::size_t scanNum) const override
| get raw intensities without transformation from one scan it needs intensity normalization
virtual pappso::MassSpectrumCstSPtr | getMassSpectrumCstSPtr (std::size_t scanNum) const
| get the mass spectrum corresponding to a scan number
virtual pappso::MassSpectrumSPtr | getMassSpectrumSPtr (std::size_t scanNum) const override
| get Mass spectrum with peaks for this scan number need the binary file
Public Member Functions inherited from pappso::TimsFrameBase
| 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 | 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
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
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 MzCalibrationInterfaceSPtr & | getMzCalibrationInterfaceSPtr () const final
| get the MzCalibration model to compute mz and TOF for this frame
void | setMzCalibrationInterfaceSPtr (MzCalibrationInterfaceSPtr mzCalibration)
virtual Trace | getIonMobilityTraceByMzIndexRange (std::size_t mz_index_lower_bound, std::size_t mz_index_upper_bound, XicExtractMethod method) const
| get a mobility trace cumulating intensities inside the given mass index range

## 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, XicExtractMethod method) const
virtual void | cumulateScan (std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const
| cumulate a scan into a map
virtual void | cumulateScan2 (std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into, double mz_range_begin, double mz_range_end, 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 Attributes

QByteArray | m_timsDataFrame
Protected Attributes inherited from pappso::TimsFrameBase
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

## 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 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

  timsId | tims frame id
  scanNum | total number of scans in this frame
  p_bytes | pointer on the decompressed binary buffer
  len | size of the decompressed binary buffer

Definition at line 61 of file timsframe.cpp.

: TimsFrameBase(timsId, scanNum)
{
// langella@themis:~/developpement/git/bruker/cbuild$
// ./src/sample/timsdataSamplePappso
// /gorgone/pappso/fichiers_fabricants/Bruker/Demo_TimsTOF_juin2019/Samples/1922001/1922001-1_S-415_Pep_Pur-1ul_Slot1-10_1_2088.d/
qDebug() << timsId;
m_timsDataFrame.resize(len);
if(p_bytes != nullptr)
{
unshufflePacket(p_bytes);
}
else
{
if(m_scanNumber == 0)
{
throw pappso::PappsoException(
QObject::tr("TimsFrame::TimsFrame(%1,%2,nullptr,%3) FAILED")
.arg(m_timsId)
.arg(m_scanNumber)
.arg(len));
}
}
}
pappso::PappsoException
Definition pappsoexception.h:42
pappso::TimsFrameBase::TimsFrameBase
TimsFrameBase(std::size_t timsId, quint32 scanNum)
constructor for binary independant tims frame
Definition timsframebase.cpp:39
pappso::TimsFrameBase::m_scanNumber
quint32 m_scanNumber
total number of scans contained in this frame
Definition timsframebase.h:273
pappso::TimsFrameBase::m_timsId
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
Definition timsframebase.h:279
pappso::TimsFrame::m_timsDataFrame
QByteArray m_timsDataFrame
Definition timsframe.h:225
pappso::TimsFrame::unshufflePacket
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

  other | TODO

Definition at line 92 of file timsframe.cpp.

: TimsFrameBase(other)
{
}

## ~TimsFrame()

pappso::TimsFrame::~TimsFrame | ( |  | ) |

virtual

Destructor

Definition at line 96 of file timsframe.cpp.

{
}

## TimsFrame() [3/3]

pappso::TimsFrame::TimsFrame | ( | std::size_t | timsId,
|  | quint32 | scanNum
| ) |  |

protected

constructor for binary independant tims frame

Parameters

  timsId | tims frame identifier in the database
  scanNum | the total number of scans contained in this frame

Definition at line 55 of file timsframe.cpp.

: TimsFrameBase(timsId, scanNum)
{
// m_timsDataFrame.resize(10);
}

## Member Function Documentation

## cumulateScan()

void pappso::TimsFrame::cumulateScan | ( | std::size_t | scanNum,
|  | std::map< quint32, quint32 > & | accumulate_into
| ) |  | const

protected virtual

cumulate a scan into a map

Parameters

  scanNum | scan number 0 to (m_scanNumber-1)

Reimplemented in pappso::TimsFrameType1.

Definition at line 305 of file timsframe.cpp.

{
// qDebug();
if(m_timsDataFrame.size() == 0)
return;
// checkScanNum(scanNum);
std::size_t scan_size = getNbrPeaks(scanNum);
std::size_t scan_offset = getScanOffset(scanNum);
qint32 previous = -1;
for(std::size_t i = 0; i < scan_size; i++)
{
quint32 x = (*(quint32 *)((m_timsDataFrame.constData() +
(scan_offset * 4) + (i * 8))) +
previous);
quint32 y = (*(quint32 *)(m_timsDataFrame.constData() +
(scan_offset * 4) + (i * 8) + 4));
previous = x;
auto ret = accumulate_into.insert(std::pair<quint32, quint32>(x, y));
if(ret.second == false)
{
// already existed : cumulate
ret.first->second += y;
}
}
// qDebug();
}
pappso::TimsFrame::getNbrPeaks
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
pappso::TimsFrame::getScanOffset
std::size_t getScanOffset(std::size_t scanNum) const
get offset for this spectrum in the binary file
Definition timsframe.cpp:159
pappso::PeptideIonCter::y
@ y
pappso::PeptideIonCter::x
@ x

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

Referenced by cumulateScansInRawMap(), cumulateScansToTrace(), and cumulateScansToTraceMzDownResolution().

## cumulateScan2()

void pappso::TimsFrame::cumulateScan2 | ( | std::size_t | scanNum,
|  | std::map< quint32, quint32 > & | accumulate_into,
|  | double | mz_range_begin,
|  | double | mz_range_end,
|  | quint32 | accepted_tof_index_range_begin,
|  | quint32 | accepted_tof_index_range_end
| ) |  | const

protected virtual

Definition at line 344 of file timsframe.cpp.

{
// qDebug();
if(m_timsDataFrame.size() == 0)
return;
// checkScanNum(scanNum);
std::size_t scan_size = getNbrPeaks(scanNum);
std::size_t scan_offset = getScanOffset(scanNum);
qint32 previous = -1;
for(std::size_t i = 0; i < scan_size; i++)
{
quint32 x = (*(quint32 *)((m_timsDataFrame.constData() +
(scan_offset * 4) + (i * 8))) +
previous);
if(x < accepted_tof_index_range_begin)
{
// qDebug() << "TOF index still not in range, x:" << x;
continue;
}
if(x > accepted_tof_index_range_end)
{
// qDebug() << "TOF index already out of range, x:" << x;
break;
}
// qDebug() << "TOF index in range, x:" << x;
quint32 y = (*(quint32 *)(m_timsDataFrame.constData() +
(scan_offset * 4) + (i * 8) + 4));
previous = x;
auto ret = accumulate_into.insert(std::pair<quint32, quint32>(x, y));
if(ret.second == false)
{
// already existed : cumulate
ret.first->second += y;
}
}
// qDebug();
}

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

Referenced by cumulateScansToTraceMzDownResolution2().

## cumulateScansInRawMap()

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

override virtual

cumulate scan list into a trace into a raw spectrum map

Parameters

  rawSpectrum | simple map of integers to cumulate raw counts
  scanNumBegin | first scan to cumulate
  scanNumEnd | last scan to cumulate

Reimplemented from pappso::TimsFrameBase.

Definition at line 675 of file timsframe.cpp.

{
// qDebug() << "begin mobility_scan_begin=" << mobility_scan_begin
//<< " mobility_scan_end=" << mobility_scan_end;
if(m_timsDataFrame.size() == 0)
return;
try
{
std::size_t mobility_scan_max = mobility_scan_end + 1;
qDebug();
for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
{
qDebug() << i;
cumulateScan(i, rawSpectrum);
qDebug() << i;
// local_accumulationTime += m_accumulationTime;
}
}
catch(std::exception &error)
{
qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
.arg(__FUNCTION__)
.arg(mobility_scan_begin)
.arg(mobility_scan_end)
.arg(error.what());
}
// qDebug() << "end";
}
pappso::TimsFrame::cumulateScan
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 | mobility_scan_begin,
|  | std::size_t | mobility_scan_end
| ) |  | const

override virtual

...

Parameters

  mobility_scan_begin | p_mobility_scan_begin:...
  mobility_scan_end | p_mobility_scan_end:...

Returns
  quint64

Reimplemented from pappso::TimsFrameBase.

Definition at line 267 of file timsframe.cpp.

{
quint64 summed_intensities = 0;
// qDebug() << "begin mobility_scan_begin =" << mobility_scan_begin
//<< "mobility_scan_end =" << mobility_scan_end;
if(m_timsDataFrame.size() == 0)
return summed_intensities;
try
{
std::size_t mobility_scan_max = mobility_scan_end + 1;
for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
{
qDebug() << i;
summed_intensities += cumulateSingleScanIntensities(i);
qDebug() << i;
}
}
catch(std::exception &error)
{
qDebug() << QString("Failure in %1 %2 to %3 :\n %4")
.arg(__FUNCTION__)
.arg(mobility_scan_begin)
.arg(mobility_scan_end)
.arg(error.what());
}
// qDebug() << "end";
return summed_intensities;
}
pappso::TimsFrame::cumulateSingleScanIntensities
virtual quint64 cumulateSingleScanIntensities(std::size_t scanNum) const override
Definition timsframe.cpp:220

References cumulateSingleScanIntensities(), and m_timsDataFrame.

## cumulateScansToTrace()

Trace pappso::TimsFrame::cumulateScansToTrace | ( | std::size_t | scanNumBegin,
|  | std::size_t | scanNumEnd
| ) |  | const

override virtual

cumulate scan list into a trace

Parameters

  scanNumBegin | first scan to cumulate
  scanNumEnd | last scan to cumulate

Returns
  Trace mz and intensity values

Reimplemented from pappso::TimsFrameBase.

Definition at line 400 of file timsframe.cpp.

{
// qDebug();
Trace new_trace;
try
{
if(m_timsDataFrame.size() == 0)
return new_trace;
std::map<quint32, quint32> raw_spectrum;
// double local_accumulationTime = 0;
std::size_t mobility_scan_max = mobility_scan_end + 1;
qDebug();
for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
{
// qDebug() << i;
cumulateScan(i, raw_spectrum);
// qDebug() << i;
// local_accumulationTime += m_accumulationTime;
}
// qDebug();
pappso::DataPoint data_point_cumul;
MzCalibrationInterface *mz_calibration_p =
getMzCalibrationInterfaceSPtr().get();
for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
{
data_point_cumul.x =
mz_calibration_p->getMzFromTofIndex(pair_tof_intensity.first);
// normalization
data_point_cumul.y =
pair_tof_intensity.second * ((double)100.0 / m_accumulationTime);
new_trace.push_back(data_point_cumul);
}
new_trace.sortX();
// qDebug();
}
catch(std::exception &error)
{
qDebug() << QString(
"Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
.arg(mobility_scan_begin, mobility_scan_end)
.arg(error.what());
}
return new_trace;
}
pappso::TimsFrameBase::m_accumulationTime
double m_accumulationTime
accumulation time in milliseconds
Definition timsframebase.h:283
pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
Definition timsframebase.cpp:473
pappso::DataPoint
Definition datapoint.h:22
pappso::DataPoint::x
pappso_double x
Definition datapoint.h:23
pappso::DataPoint::y
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.

## cumulateScansToTraceMzDownResolution()

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

override 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_window | width of the mzindex window used to merge all intensities into a single point. This results in faster computing.
  scanNumBegin | scan number in the frame in the order it lies in binary file, from 0 to N-1
  scanNumEnd | scan number in the frame in the order it lies in binary file, from 0 to N-1

Reimplemented from pappso::TimsFrameBase.

Definition at line 459 of file timsframe.cpp.

{
// qDebug();
Trace new_trace;
try
{
if(m_timsDataFrame.size() == 0)
{
qDebug() << "The frame is empty, returning empty trace.";
return new_trace;
}
// Allocate a map for (TOF,intensity) pairs to
// accumulate ion mobility scans.
std::map<quint32, quint32> raw_spectrum;
// double local_accumulationTime = 0;
std::size_t mobility_scan_max = mobility_scan_end + 1;
for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
{
// qDebug() << "Going to cumulate currently iterated mobility scan:"
// << i;
cumulateScan(i, raw_spectrum);
// qDebug() << "Done cumulating currently iterated mobility scan:" <<
// i;
// local_accumulationTime += m_accumulationTime;
}
// qDebug();
pappso::DataPoint data_point_cumul;
MzCalibrationInterface *mz_calibration_p =
getMzCalibrationInterfaceSPtr().get();
// If the caller asks that m/z values be binned larger than they are,
// ask that the m/z raw map be reduced in resolution.
if(mz_index_merge_window > 0)
raw_spectrum = downsizeMzRawMap(mz_index_merge_window, raw_spectrum);
// Store the first mz index and the last mz index of the current spectrum.
// The values are set to the out parameters.
mz_minimum_index_out = std::numeric_limits<quint32>::max();
mz_maximum_index_out = 0;
for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
{
if(pair_tof_intensity.first > mz_maximum_index_out)
mz_maximum_index_out = pair_tof_intensity.first;
if(pair_tof_intensity.first < mz_minimum_index_out)
mz_minimum_index_out = pair_tof_intensity.first;
// Convert the TOF index to m/z
data_point_cumul.x =
mz_calibration_p->getMzFromTofIndex(pair_tof_intensity.first);
// Normalization
data_point_cumul.y =
pair_tof_intensity.second * ((double)100.0 / m_accumulationTime);
// Finally make the data point a new Trace point.
new_trace.push_back(data_point_cumul);
}
// qDebug() << "At this point we have mz_minimum_index_out:"
// << mz_minimum_index_out
// << "and mz_maximum_index_out:" << mz_maximum_index_out;
// FIXME: this does not seem to be necessary since raw_spectrum is a map
// with auto-sorting on the keys which are quint32.
// new_trace.sortX();
// qDebug();
}
catch(std::exception &error)
{
qDebug() << QString(
"Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
.arg(mobility_scan_begin, mobility_scan_end)
.arg(error.what());
}
// qDebug() << "Returning new trace of size:" << new_trace.size();
return new_trace;
}
pappso::TimsFrameBase::downsizeMzRawMap
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
Definition timsframebase.cpp:606

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

## cumulateScansToTraceMzDownResolution2()

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

Definition at line 558 of file timsframe.cpp.

{
// qDebug();
Trace new_trace;
try
{
if(m_timsDataFrame.size() == 0)
{
qDebug() << "The frame is empty, returning empty trace.";
return new_trace;
}
// Allocate a map for (TOF index,intensity) pairs to
// accumulate ion mobility scans.
std::map<quint32, quint32> raw_spectrum;
// double local_accumulationTime = 0;
std::size_t mobility_scan_max = mobility_scan_end + 1;
quint32 only_in_mz_begin_tof_index_range =
getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(
mz_range_begin);
quint32 only_in_mz_end_tof_index_range =
getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(mz_range_end);
// qDebug() << "20231129 TOF index range begin:"
// << only_in_mz_begin_tof_index_range;
// qDebug() << "20231129 TOF index range end:"
// << only_in_mz_end_tof_index_range;
for(std::size_t i = mobility_scan_begin; i < mobility_scan_max; i++)
{
// qDebug() << "Going to cumulate currently iterated mobility scan:"
// << i;
cumulateScan2(i,
raw_spectrum,
mz_range_begin,
mz_range_end,
only_in_mz_begin_tof_index_range,
only_in_mz_end_tof_index_range);
// qDebug() << "Done cumulating currently iterated mobility scan:" <<
// i;
// local_accumulationTime += m_accumulationTime;
}
// qDebug();
pappso::DataPoint data_point_cumul;
MzCalibrationInterface *mz_calibration_p =
getMzCalibrationInterfaceSPtr().get();
// If the caller asks that m/z values be binned larger than they are,
// ask that the m/z raw map be reduced in resolution.
if(mz_index_merge_window > 0)
raw_spectrum = downsizeMzRawMap(mz_index_merge_window, raw_spectrum);
// Store the first mz index and the last mz index of the current spectrum.
// The values are set to the out parameters.
mz_minimum_index_out = std::numeric_limits<quint32>::max();
mz_maximum_index_out = 0;
for(std::pair<quint32, quint32> pair_tof_intensity : raw_spectrum)
{
if(pair_tof_intensity.first > mz_maximum_index_out)
mz_maximum_index_out = pair_tof_intensity.first;
if(pair_tof_intensity.first < mz_minimum_index_out)
mz_minimum_index_out = pair_tof_intensity.first;
// Convert the TOF index to m/z
data_point_cumul.x =
mz_calibration_p->getMzFromTofIndex(pair_tof_intensity.first);
// Normalization
data_point_cumul.y =
pair_tof_intensity.second * ((double)100.0 / m_accumulationTime);
// Finally make the data point a new Trace point.
new_trace.push_back(data_point_cumul);
}
// qDebug() << "At this point we have mz_minimum_index_out:"
// << mz_minimum_index_out
// << "and mz_maximum_index_out:" << mz_maximum_index_out;
// FIXME: this does not seem to be necessary since raw_spectrum is a map
// with auto-sorting on the keys which are quint32.
// new_trace.sortX();
// qDebug();
}
catch(std::exception &error)
{
qDebug() << QString(
"Failure in TimsFrame::cumulateScanToTrace %1 to %2 :\n %3")
.arg(mobility_scan_begin, mobility_scan_end)
.arg(error.what());
}
// qDebug() << "Returning new trace of size:" << new_trace.size();
return new_trace;
}
pappso::TimsFrame::cumulateScan2
virtual void cumulateScan2(std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into, double mz_range_begin, double mz_range_end, quint32 accepted_tof_index_range_begin, quint32 accepted_tof_index_range_end) const
Definition timsframe.cpp:344

References cumulateScan2(), pappso::TimsFrameBase::downsizeMzRawMap(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsFrameBase::m_accumulationTime, m_timsDataFrame, pappso::DataPoint::x, and pappso::DataPoint::y.

## cumulateSingleScanIntensities()

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

override virtual

Reimplemented from pappso::TimsFrameBase.

Definition at line 220 of file timsframe.cpp.

{
qDebug();
quint64 summed_intensities = 0;
if(m_timsDataFrame.size() == 0)
return summed_intensities;
// checkScanNum(scanNum);
std::size_t size = getNbrPeaks(scanNum);
std::size_t offset = getScanOffset(scanNum);
qint32 previous = -1;
for(std::size_t i = 0; i < size; i++)
{
quint32 x =
(*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
previous);
quint32 y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
(i * 8) + 4));
previous = x;
summed_intensities += y;
}
// Normalization over the accumulation time for this frame.
summed_intensities *= ((double)100.0 / m_accumulationTime);
qDebug();
return summed_intensities;
}

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

{
qDebug() << std::distance(itXicListbegin, itXicListend);
std::vector<TimsFrame::XicComputeStructure> tmp_xic_list;
for(auto it = itXicListbegin; it != itXicListend; it++)
{
tmp_xic_list.push_back(TimsFrame::XicComputeStructure(this, **it));
qDebug() << " tmp_xic_struct.mobilityIndexBegin="
<< tmp_xic_list.back().mobilityIndexBegin
<< " tmp_xic_struct.mobilityIndexEnd="
<< tmp_xic_list.back().mobilityIndexEnd;
qDebug() << " tmp_xic_struct.mzIndexLowerBound="
<< tmp_xic_list.back().mzIndexLowerBound
<< " tmp_xic_struct.mzIndexUpperBound="
<< tmp_xic_list.back().mzIndexUpperBound;
}
if(tmp_xic_list.size() == 0)
return;
/*
std::sort(tmp_xic_list.begin(), tmp_xic_list.end(), [](const
TimsXicStructure &a, const TimsXicStructure &b) { return
a.mobilityIndexBegin < b.mobilityIndexBegin;
});
*/
std::vector<std::size_t> unique_scan_num_list;
for(auto &&struct_xic : tmp_xic_list)
{
for(std::size_t scan = struct_xic.mobilityIndexBegin;
(scan <= struct_xic.mobilityIndexEnd) && (scan < m_scanNumber);
scan++)
{
unique_scan_num_list.push_back(scan);
}
}
std::sort(unique_scan_num_list.begin(), unique_scan_num_list.end());
auto it_scan_num_end =
std::unique(unique_scan_num_list.begin(), unique_scan_num_list.end());
auto it_scan_num = unique_scan_num_list.begin();
while(it_scan_num != it_scan_num_end)
{
TraceSPtr ms_spectrum = getRawTraceSPtr(*it_scan_num);
// qDebug() << ms_spectrum.get()->toString();
for(auto &&tmp_xic_struct : tmp_xic_list)
{
if(((*it_scan_num) >= tmp_xic_struct.mobilityIndexBegin) &&
((*it_scan_num) <= tmp_xic_struct.mobilityIndexEnd))
{
if(method == XicExtractMethod::max)
{
tmp_xic_struct.tmpIntensity +=
ms_spectrum.get()->maxY(tmp_xic_struct.mzIndexLowerBound,
tmp_xic_struct.mzIndexUpperBound);
qDebug() << "tmp_xic_struct.tmpIntensity="
<< tmp_xic_struct.tmpIntensity;
}
else
{
// sum
tmp_xic_struct.tmpIntensity +=
ms_spectrum.get()->sumY(tmp_xic_struct.mzIndexLowerBound,
tmp_xic_struct.mzIndexUpperBound);
qDebug() << "tmp_xic_struct.tmpIntensity="
<< tmp_xic_struct.tmpIntensity;
}
}
}
it_scan_num++;
}
for(auto &&tmp_xic_struct : tmp_xic_list)
{
if(tmp_xic_struct.tmpIntensity != 0)
{
qDebug() << tmp_xic_struct.xic_ptr;
tmp_xic_struct.xic_ptr->push_back(
{m_time, tmp_xic_struct.tmpIntensity});
}
}
qDebug();
}
pappso::TimsFrameBase::m_time
double m_time
retention time
Definition timsframebase.h:289
pappso::TimsFrame::getRawTraceSPtr
virtual pappso::TraceSPtr getRawTraceSPtr(std::size_t scanNum) const
get the raw index tof_index and intensities (normalized)
Definition timsframe.cpp:869
pappso::TraceSPtr
std::shared_ptr< Trace > TraceSPtr
Definition trace.h:135
pappso::XicExtractMethod::max
@ 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

  scanNum | the scan number to retrieve

Definition at line 712 of file timsframe.cpp.

{
// qDebug();
return getMassSpectrumSPtr(scanNum);
}
pappso::TimsFrame::getMassSpectrumSPtr
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:720

References getMassSpectrumSPtr().

## getMassSpectrumSPtr()

pappso::MassSpectrumSPtr pappso::TimsFrame::getMassSpectrumSPtr | ( | std::size_t | scanNum | ) | const

override virtual

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

Parameters

  scanNum | scan 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 720 of file timsframe.cpp.

{
// qDebug() << " scanNum=" << scanNum;
checkScanNum(scanNum);
// qDebug();
pappso::MassSpectrumSPtr mass_spectrum_sptr =
std::make_shared<pappso::MassSpectrum>();
// std::vector<DataPoint>
if(m_timsDataFrame.size() == 0)
return mass_spectrum_sptr;
// qDebug();
std::size_t size = getNbrPeaks(scanNum);
std::size_t offset = getScanOffset(scanNum);
MzCalibrationInterface *mz_calibration_p =
getMzCalibrationInterfaceSPtr().get();
qint32 previous = -1;
qint32 tof_index;
// std::vector<quint32> index_list;
DataPoint data_point;
for(std::size_t i = 0; i < size; i++)
{
tof_index =
(*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
previous);
data_point.y = (*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) +
(i * 8) + 4));
// intensity normalization
data_point.y *= 100.0 / m_accumulationTime;
previous = tof_index;
// mz calibration
data_point.x = mz_calibration_p->getMzFromTofIndex(tof_index);
mass_spectrum_sptr.get()->push_back(data_point);
}
// qDebug();
return mass_spectrum_sptr;
}
pappso::TimsFrameBase::checkScanNum
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
Definition timsframebase.cpp:103
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition massspectrum.h:56

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

override virtual

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

Parameters

  scanNum | scan 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.

{
if(m_timsDataFrame.size() == 0)
return 0;
/*
if(scanNum == 0)
{
quint32 res = (*(quint32 *)(m_timsDataFrame.constData() + 4)) -
(*(quint32 *)(m_timsDataFrame.constData()-4));
return res / 2;
}*/
if(scanNum == (m_scanNumber - 1))
{
auto nb_uint4 = m_timsDataFrame.size() / 4;
std::size_t cumul = 0;
for(quint32 i = 0; i < m_scanNumber; i++)
{
cumul += (*(quint32 *)(m_timsDataFrame.constData() + (i * 4)));
}
return (nb_uint4 - cumul) / 2;
}
checkScanNum(scanNum);
// quint32 *res = (quint32 *)(m_timsDataFrame.constData() + (scanNum * 4));
// qDebug() << " res=" << *res;
return (*(quint32 *)(m_timsDataFrame.constData() + ((scanNum + 1) * 4))) / 2;
}

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

Referenced by cumulateScan(), cumulateScan2(), cumulateSingleScanIntensities(), getMassSpectrumSPtr(), getRawTraceSPtr(), getScanIndexList(), and getScanIntensities().

## getRawTraceSPtr()

pappso::TraceSPtr pappso::TimsFrame::getRawTraceSPtr | ( | std::size_t | scanNum | ) | const

protected virtual

get the raw index tof_index and intensities (normalized)

Parameters

  scanNum | the scan number to extract

Returns
  trace vector

Reimplemented in pappso::TimsFrameType1.

Definition at line 869 of file timsframe.cpp.

{
// qDebug();
pappso::TraceSPtr trace_sptr = std::make_shared<pappso::Trace>();
// std::vector<DataPoint>
if(m_timsDataFrame.size() == 0)
return trace_sptr;
// qDebug();
std::size_t size = getNbrPeaks(scanNum);
std::size_t offset = getScanOffset(scanNum);
qint32 previous = -1;
std::vector<quint32> index_list;
for(std::size_t i = 0; i < size; i++)
{
DataPoint data_point(
(*(quint32 *)((m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
previous),
(*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8) +
4)));
// intensity normalization
data_point.y *= 100.0 / m_accumulationTime;
previous = data_point.x;
trace_sptr.get()->push_back(data_point);
}
// qDebug();
return trace_sptr;
}

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

override virtual

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.

{
qDebug();
checkScanNum(scanNum);
std::vector<quint32> scan_tof;
if(m_timsDataFrame.size() == 0)
return scan_tof;
scan_tof.resize(getNbrPeaks(scanNum));
std::size_t offset = getScanOffset(scanNum);
qint32 previous = -1;
for(std::size_t i = 0; i < scan_tof.size(); i++)
{
scan_tof[i] =
(*(quint32 *)(m_timsDataFrame.constData() + (offset * 4) + (i * 8))) +
previous;
previous = scan_tof[i];
}
qDebug();
return scan_tof;
}

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

override virtual

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.

{
qDebug();
checkScanNum(scanNum);
std::vector<quint32> scan_intensities;
if(m_timsDataFrame.size() == 0)
return scan_intensities;
scan_intensities.resize(getNbrPeaks(scanNum));
std::size_t offset = getScanOffset(scanNum);
for(std::size_t i = 0; i < scan_intensities.size(); i++)
{
scan_intensities[i] = (*(quint32 *)(m_timsDataFrame.constData() +
(offset * 4) + (i * 8) + 4));
}
qDebug();
return scan_intensities;
}

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

  scanNum | scan 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.

{
std::size_t offset = 0;
for(std::size_t i = 0; i < (scanNum + 1); i++)
{
offset += (*(quint32 *)(m_timsDataFrame.constData() + (i * 4)));
}
return offset;
}

References m_timsDataFrame.

Referenced by cumulateScan(), cumulateScan2(), cumulateSingleScanIntensities(), getMassSpectrumSPtr(), getRawTraceSPtr(), getScanIndexList(), and getScanIntensities().

## unshufflePacket()

void pappso::TimsFrame::unshufflePacket | ( | const char * | src | ) |

private

unshuffle data packet of tims compression type 2

Parameters

  src | is a zstd decompressed buffer pointer

Definition at line 102 of file timsframe.cpp.

{
qDebug();
quint64 len = m_timsDataFrame.size();
if(len % 4 != 0)
{
throw pappso::PappsoException(
QObject::tr("TimsFrame::unshufflePacket error: len % 4 != 0"));
}
quint64 nb_uint4 = len / 4;
char *dest = m_timsDataFrame.data();
quint64 src_offset = 0;
for(quint64 j = 0; j < 4; j++)
{
for(quint64 i = 0; i < nb_uint4; i++)
{
dest[(i * 4) + j] = src[src_offset];
src_offset++;
}
}
qDebug();
}

References m_timsDataFrame.

Referenced by TimsFrame().

## Member Data Documentation

## m_timsDataFrame

QByteArray pappso::TimsFrame::m_timsDataFrame

protected

Definition at line 225 of file timsframe.h.

Referenced by TimsFrame(), pappso::TimsFrameType1::TimsFrameType1(), pappso::TimsFrameType1::copyAndLzfDecompress(), cumulateScan(), pappso::TimsFrameType1::cumulateScan(), cumulateScan2(), cumulateScansInRawMap(), cumulateScansIntensities(), cumulateScansToTrace(), cumulateScansToTraceMzDownResolution(), cumulateScansToTraceMzDownResolution2(), cumulateSingleScanIntensities(), getMassSpectrumSPtr(), pappso::TimsFrameType1::getMassSpectrumSPtr(), getNbrPeaks(), getRawTraceSPtr(), pappso::TimsFrameType1::getRawTraceSPtr(), getScanIndexList(), pappso::TimsFrameType1::getScanIndexList(), getScanIntensities(), pappso::TimsFrameType1::getScanIntensities(), getScanOffset(), pappso::TimsFrameType1::lzfDecompressScan(), and unshufflePacket().

## 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:

- pappsomspp/vendors/tims/timsframe.h
- pappsomspp/vendors/tims/timsframe.cpp