pappso::TimsFrameType1 Class Reference

`#include <timsframetype1.h>`

Inheritance diagram for pappso::TimsFrameType1:

## Public Member Functions

| TimsFrameType1 (std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
| TimsFrameType1 (const TimsFrameType1 &other)
| ~TimsFrameType1 ()
virtual std::size_t | getNbrPeaks (std::size_t scanNum) const override
| get the number of peaks in this spectrum need the binary file More...
virtual std::vector< quint32 > | getScanIndexList (std::size_t scanNum) const override
| get raw index list for one given scan index are not TOF nor m/z, just index on digitizer More...
virtual std::vector< quint32 > | getScanIntensities (std::size_t scanNum) const override
| get raw intensities without transformation from one scan it needs intensity normalization More...
virtual pappso::MassSpectrumSPtr | getMassSpectrumSPtr (std::size_t scanNum) const override
| get the mass spectrum corresponding to a scan number More...
Public Member Functions inherited from pappso::TimsFrame
| TimsFrame (std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
| TimsFrame (const TimsFrame &other)
| ~TimsFrame ()
virtual Trace | cumulateScanToTrace (std::size_t scanNumBegin, std::size_t scanNumEnd) const override
| cumulate scan list into a trace More...
virtual void | cumulateScansInRawMap (std::map< quint32, quint32 > &rawSpectrum, std::size_t scanNumBegin, std::size_t scanNumEnd) const override
| cumulate scan list into a trace into a raw spectrum map More...
virtual pappso::MassSpectrumCstSPtr | getMassSpectrumCstSPtr (std::size_t scanNum) const
| get the mass spectrum corresponding to a scan number More...
Public Member Functions inherited from pappso::TimsFrameBase
| TimsFrameBase (std::size_t timsId, quint32 scanNum)
| constructor for binary independant tims frame More...
| TimsFrameBase (const TimsFrameBase &other)
| ~TimsFrameBase ()
virtual bool | hasSameCalibrationData (const TimsFrameBase &other) const
| tells if 2 tims frame has the same calibration data Usefull to know if raw data can be handled between frames More...
bool | checkScanNum (std::size_t scanNum) const
| check that this scan number exists More...
void | setAccumulationTime (double accumulation_time_ms)
void | setMzCalibration (double T1_frame, double T2_frame, double digitizerTimebase, double digitizerDelay, double C0, double C1, double C2, double C3, double C4, double T1_ref, double T2_ref, double dC1, double dC2)
void | setTimsCalibration (int tims_model_type, double C0, double C1, double C2, double C3, double C4, double C5, double C6, double C7, double C8, double C9)
void | setTime (double time)
void | setMsMsType (quint8 type)
unsigned int | getMsLevel () const
double | getTime () const
std::size_t | getId () const
double | getDriftTime (std::size_t scanNum) const
| get drift time of a scan number in milliseconds More...
double | getOneOverK0Transformation (std::size_t scanNum) const
| get 1/K0 value of a given scan (mobility value) More...
std::size_t | getScanNumFromOneOverK0 (double one_over_k0) const
| get the scan number from a given 1/Ko mobility value More...
double | getVoltageTransformation (std::size_t scanNum) const
| get voltage for a given scan number More...
pappso::Trace | getTraceFromCumulatedScans (std::map< quint32, quint32 > &accumulated_scans) const
| transform accumulation of raw scans into a real mass spectrum More...
pappso::Trace | getTraceFromCumulatedScansBuiltinCentroid (std::map< quint32, quint32 > &accumulated_scans) const
| transform accumulation of raw scans into a real mass spectrum with a simple centroid on raw integers More...
virtual const MzCalibrationInterfaceSPtr & | getMzCalibrationInterfaceSPtr () const final
| get the MzCalibration model to compute mz and TOF for this frame More...
void | setMzCalibrationInterfaceSPtr (MzCalibrationInterfaceSPtr mzCalibration)

## Protected Member Functions

virtual void | cumulateScan (std::size_t scanNum, std::map< quint32, quint32 > &accumulate_into) const override
| cumulate a scan into a map More...
virtual pappso::TraceSPtr | getRawTraceSPtr (std::size_t scanNum) const override
| get the raw index tof_index and intensities (normalized) More...
Protected Member Functions inherited from pappso::TimsFrame
| TimsFrame (std::size_t timsId, quint32 scanNum)
| constructor for binary independant tims frame More...
void | extractTimsXicListInRtRange (std::vector< XicCoordTims * >::iterator &itXicListbegin, std::vector< XicCoordTims * >::iterator &itXicListend, XicExtractMethod method) const

## Private Member Functions

void | copyAndLzfDecompress (const char *src, std::size_t len)
| copy buffer header and lzf decompress each scan for tims compression type 1 More...
unsigned int | lzfDecompressScan (const char *src, unsigned int src_len, char *dest, unsigned int dest_len)
| decompress a single LZF compressed scan buffer More...

## Private Attributes

std::vector< std::size_t > | m_scanOffsetList
std::vector< std::size_t > | m_scanSizeList

## Additional Inherited Members

Protected Attributes inherited from pappso::TimsFrame
QByteArray | m_timsDataFrame
Protected Attributes inherited from pappso::TimsFrameBase
quint32 | m_scanNumber
| total number of scans contained in this frame More...
std::size_t | m_timsId
| Tims frame database id (the SQL identifier of this frame) More...
double | m_accumulationTime = 0
| accumulation time in milliseconds More...
quint8 | m_msMsType = 0
double | m_time = 0
| retention time More...
double | m_timsDvStart = 0
double | m_timsSlope
double | m_timsTtrans = 0
double | m_timsNdelay = 0
double | m_timsVmin = 0
double | m_timsVmax = 0
double | m_timsC6 = 0
double | m_timsC7 = 0
MzCalibrationInterfaceSPtr | msp_mzCalibration = nullptr

## Detailed Description

Todo:
  write docs

Definition at line 37 of file timsframetype1.h.

## Constructor & Destructor Documentation

## TimsFrameType1() [1/2]

pappso::TimsFrameType1::TimsFrameType1 | ( | 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 40 of file timsframetype1.cpp.

: TimsFrame(timsId, scanNum)
{
qDebug() << timsId;
m_timsDataFrame.resize(len * 2);
if(p_bytes != nullptr)
{
qDebug() << timsId;
copyAndLzfDecompress(p_bytes, len);
qDebug() << timsId;
}
else
{
if(m_scanNumber == 0)
{
throw pappso::PappsoException(
QObject::tr(
"TimsFrameType1::TimsFrameType1(%1,%2,nullptr,%3) FAILED")
.arg(m_timsId)
.arg(m_scanNumber)
.arg(len));
}
}
}
pappso::PappsoException
Definition: pappsoexception.h:42
pappso::TimsFrameBase::m_scanNumber
quint32 m_scanNumber
total number of scans contained in this frame
Definition: timsframebase.h:197
pappso::TimsFrameBase::m_timsId
std::size_t m_timsId
Tims frame database id (the SQL identifier of this frame)
Definition: timsframebase.h:203
pappso::TimsFrameType1::copyAndLzfDecompress
void copyAndLzfDecompress(const char *src, std::size_t len)
copy buffer header and lzf decompress each scan for tims compression type 1
Definition: timsframetype1.cpp:80
pappso::TimsFrame::m_timsDataFrame
QByteArray m_timsDataFrame
Definition: timsframe.h:181
pappso::TimsFrame::TimsFrame
TimsFrame(std::size_t timsId, quint32 scanNum, char *p_bytes, std::size_t len)
Definition: timsframe.cpp:63

References copyAndLzfDecompress(), pappso::TimsFrameBase::m_scanNumber, pappso::TimsFrame::m_timsDataFrame, and pappso::TimsFrameBase::m_timsId.

## TimsFrameType1() [2/2]

pappso::TimsFrameType1::TimsFrameType1 | ( | const TimsFrameType1 & | other | ) |

Copy constructor

Parameters

  other | TODO

Definition at line 70 of file timsframetype1.cpp.

: TimsFrame(other)
{
}

## ~TimsFrameType1()

pappso::TimsFrameType1::~TimsFrameType1 | ( |  | ) |

Destructor

Definition at line 74 of file timsframetype1.cpp.

{
}

## Member Function Documentation

## copyAndLzfDecompress()

void pappso::TimsFrameType1::copyAndLzfDecompress | ( | const char * | src,
|  | std::size_t | len
| ) |  |

private

copy buffer header and lzf decompress each scan for tims compression type 1

Parameters

  src | raw data buffer containing scan offsets and LZF compressed scans
  len | length of the data buffer

Definition at line 80 of file timsframetype1.cpp.

{
qDebug() << " m_scanNumber=" << m_scanNumber << " len=" << len;
// the start position offset for each scan and the length of the last scan
// copy first m_scanNumber*4 bytes in qbyte array
std::size_t count = (m_scanNumber + 2) * 4;
qDebug() << " count=" << count;
if(m_timsDataFrame.size() < (long)(count + count))
{
qDebug() << " m_timsDataFrame.size()=" << m_timsDataFrame.size();
m_timsDataFrame.resize(count + count);
}
/*
std::size_t decompressed_size =
lzfDecompressScan(src + 3687 - 8,
9,
m_timsDataFrame.data() + 3660,
m_timsDataFrame.size() - 3660);
qDebug() << "decompressed_size=" << decompressed_size;
*/
// memcpy(m_timsDataFrame.data(), src, count);
qDebug() << "offset begin at last :" << count + 4;
// std::vector<std::size_t> compressed_len_list;
std::size_t offset;
std::size_t previous_offset = (*(quint32 *)(src));
qDebug() << "first offset= " << previous_offset;
std::size_t cumul_decompressed_size = 0;
for(quint32 i = 1; i <= m_scanNumber; i++)
{
offset = (*(quint32 *)(src + (i * 4)));
std::size_t compressed_size = offset - previous_offset;
qDebug() << "scan i=" << i << " previous_offset=" << previous_offset
<< " offset=" << offset << " length=" << compressed_size;
// compressed_len_list.push_back(offset - previous_offset);
std::size_t remaining_size = m_timsDataFrame.size();
if(cumul_decompressed_size < remaining_size)
{
remaining_size = remaining_size - cumul_decompressed_size;
}
else
{
remaining_size = 0;
}
qDebug() << " remaining_size=" << remaining_size;
std::size_t decompressed_size =
lzfDecompressScan(src + previous_offset - 8,
compressed_size,
m_timsDataFrame.data() + cumul_decompressed_size,
remaining_size);
m_scanOffsetList.push_back(cumul_decompressed_size);
m_scanSizeList.push_back(decompressed_size / 4);
cumul_decompressed_size += decompressed_size;
qDebug() << " decompressed_size=" << decompressed_size;
previous_offset = offset;
}
/*
std::size_t last_offset = (*(quint32 *)(src + (m_scanNumber * 4)));
qDebug() << "last scan length :" << last_offset;
qDebug() << "last scan length bonus:"
<< (*(quint32 *)(src + (m_scanNumber + 1 * 4)));
qDebug() << " m_scanOffsetList.size()=" << m_scanOffsetList.size()
<< " m_scanNumber=" << m_scanNumber;
*/
/*
throw PappsoException(
QObject::tr("ERROR reading TimsFrameType1 ").arg(m_timsId));
*/
}
pappso::TimsFrameType1::m_scanSizeList
std::vector< std::size_t > m_scanSizeList
Definition: timsframetype1.h:128
pappso::TimsFrameType1::lzfDecompressScan
unsigned int lzfDecompressScan(const char *src, unsigned int src_len, char *dest, unsigned int dest_len)
decompress a single LZF compressed scan buffer
Definition: timsframetype1.cpp:168
pappso::TimsFrameType1::m_scanOffsetList
std::vector< std::size_t > m_scanOffsetList
Definition: timsframetype1.h:127

References lzfDecompressScan(), pappso::TimsFrameBase::m_scanNumber, m_scanOffsetList, m_scanSizeList, and pappso::TimsFrame::m_timsDataFrame.

Referenced by TimsFrameType1().

## cumulateScan()

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

override protected virtual

cumulate a scan into a map

Parameters

  scanNum | scan number 0 to (m_scanNumber-1)

Reimplemented from pappso::TimsFrame.

Definition at line 218 of file timsframetype1.cpp.

{
if(m_timsDataFrame.size() == 0)
return;
// checkScanNum(scanNum);
std::size_t size = m_scanSizeList[scanNum];
std::size_t offset = m_scanOffsetList[scanNum];
// qDebug() << "begin offset=" << offset << " size=" << size;
qint32 value = 0;
qint32 tof_index = 0;
for(std::size_t i = 0; i < size; i++)
{
value = (*(qint32 *)(m_timsDataFrame.constData() + offset + (i * 4)));
// qDebug() << " i=" << i << " value=" << value;
if(value < 0)
{
tof_index += -1 * value;
}
else
{
quint32 x = tof_index;
quint32 y = value;
auto ret = accumulate_into.insert(std::pair<quint32, quint32>(x, y));
if(ret.second == false)
{
// already existed : cumulate
ret.first->second += y;
}
tof_index++;
}
}
qDebug() << "end";
}
pappso::PeptideIonCter::y
@ y
pappso::PeptideIonCter::x
@ x

References m_scanOffsetList, m_scanSizeList, pappso::TimsFrame::m_timsDataFrame, pappso::x, and pappso::y.

## getMassSpectrumSPtr()

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

override virtual

get the mass spectrum corresponding to a scan number

Parameters

  scanNum | the scan number to retrieve

Reimplemented from pappso::TimsFrame.

Definition at line 280 of file timsframetype1.cpp.

{
qDebug() << " scanNum=" << scanNum;
checkScanNum(scanNum);
try
{
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 = m_scanSizeList[scanNum];
std::size_t offset = m_scanOffsetList[scanNum];
qDebug() << " offset=" << offset << " size=" << size;
if(size == 0)
return mass_spectrum_sptr;
MzCalibrationInterface *mz_calibration_p =
getMzCalibrationInterfaceSPtr().get();
qint32 value = 0;
qint32 tof_index = 0;
// std::vector<quint32> index_list;
DataPoint data_point;
for(std::size_t i = 0; i < size; i++)
{
value = (*(qint32 *)(m_timsDataFrame.constData() + offset + (i * 4)));
if(value < 0)
{
tof_index += -1 * value;
}
else
{
data_point.y = value;
// intensity normalization
data_point.y *= 100.0 / m_accumulationTime;
// mz calibration
data_point.x = mz_calibration_p->getMzFromTofIndex(tof_index);
mass_spectrum_sptr.get()->push_back(data_point);
tof_index++;
}
}
qDebug() << mass_spectrum_sptr.get()->toString();
return mass_spectrum_sptr;
}
catch(PappsoException &error)
{
throw pappso::PappsoException(
QObject::tr("Error TimsFrameType1::getMassSpectrumSPtr frameId=%1 "
"scanNum=%2 :\n%3")
.arg(getId())
.arg(scanNum)
.arg(error.qwhat()));
}
}
pappso::TimsFrameBase::m_accumulationTime
double m_accumulationTime
accumulation time in milliseconds
Definition: timsframebase.h:207
pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr
virtual const MzCalibrationInterfaceSPtr & getMzCalibrationInterfaceSPtr() const final
get the MzCalibration model to compute mz and TOF for this frame
Definition: timsframebase.cpp:421
pappso::TimsFrameBase::checkScanNum
bool checkScanNum(std::size_t scanNum) const
check that this scan number exists
Definition: timsframebase.cpp:101
pappso::TimsFrameBase::getId
std::size_t getId() const
Definition: timsframebase.cpp:183
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54

References pappso::TimsFrameBase::checkScanNum(), pappso::TimsFrameBase::getId(), pappso::TimsFrameBase::getMzCalibrationInterfaceSPtr(), pappso::MzCalibrationInterface::getMzFromTofIndex(), pappso::TimsFrameBase::m_accumulationTime, m_scanOffsetList, m_scanSizeList, pappso::TimsFrame::m_timsDataFrame, pappso::PappsoException::qwhat(), pappso::DataPoint::x, and pappso::DataPoint::y.

Referenced by getNbrPeaks().

## getNbrPeaks()

std::size_t pappso::TimsFrameType1::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::TimsFrame.

Definition at line 210 of file timsframetype1.cpp.

{
pappso::MassSpectrumSPtr mass_spectrum_sptr = getMassSpectrumSPtr(scanNum);
return mass_spectrum_sptr.get()->size();
}
pappso::TimsFrameType1::getMassSpectrumSPtr
virtual pappso::MassSpectrumSPtr getMassSpectrumSPtr(std::size_t scanNum) const override
get the mass spectrum corresponding to a scan number
Definition: timsframetype1.cpp:280

References getMassSpectrumSPtr().

## getRawTraceSPtr()

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

override protected virtual

get the raw index tof_index and intensities (normalized)

Parameters

  scanNum | the scan number to extract

Returns
  trace vector

Reimplemented from pappso::TimsFrame.

Definition at line 356 of file timsframetype1.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 = m_scanSizeList[scanNum];
std::size_t offset = m_scanOffsetList[scanNum];
qDebug() << " offset=" << offset << " size=" << size;
if(size == 0)
return trace_sptr;
// qDebug();
qint32 value = 0;
qint32 tof_index = 0;
// std::vector<quint32> index_list;
DataPoint data_point;
for(std::size_t i = 0; i < size; i++)
{
value = (*(qint32 *)(m_timsDataFrame.constData() + offset + (i * 4)));
if(value < 0)
{
tof_index += -1 * value;
}
else
{
data_point.y = value;
// intensity normalization
data_point.y *= 100.0 / m_accumulationTime;
// mz calibration
data_point.x = tof_index;
trace_sptr.get()->push_back(data_point);
tof_index++;
}
}
// qDebug();
return trace_sptr;
}
pappso::TraceSPtr
std::shared_ptr< Trace > TraceSPtr
Definition: trace.h:135

References pappso::TimsFrameBase::m_accumulationTime, m_scanOffsetList, m_scanSizeList, pappso::TimsFrame::m_timsDataFrame, pappso::DataPoint::x, and pappso::DataPoint::y.

## getScanIndexList()

std::vector< quint32 > pappso::TimsFrameType1::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::TimsFrame.

Definition at line 262 of file timsframetype1.cpp.

{
throw pappso::ExceptionNotImplemented(QObject::tr("%1 %2 %3 NOT IMPLEMENTED ")
.arg(__FILE__)
.arg(__FUNCTION__)
.arg(__LINE__));
}
pappso::ExceptionNotImplemented
Definition: exceptionnotimplemented.h:32

## getScanIntensities()

std::vector< quint32 > pappso::TimsFrameType1::getScanIntensities | ( | std::size_t | scanNum | ) | const

override virtual

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

Reimplemented from pappso::TimsFrame.

Definition at line 271 of file timsframetype1.cpp.

{
throw pappso::ExceptionNotImplemented(QObject::tr("%1 %2 %3 NOT IMPLEMENTED ")
.arg(__FILE__)
.arg(__FUNCTION__)
.arg(__LINE__));
}

## lzfDecompressScan()

unsigned int pappso::TimsFrameType1::lzfDecompressScan | ( | const char * | src,
|  | unsigned int | src_len,
|  | char * | dest,
|  | unsigned int | dest_len
| ) |  |

private

decompress a single LZF compressed scan buffer

Parameters

  src | pointer on the LZF compressed buffer
  src_len | length of the source buffer
  dest | pointer to the destination buffer (in the qbyte array)
  dest_len | length of the destination buffer (max possible in the qbytearray)

Returns
  scan decompressed size

Definition at line 168 of file timsframetype1.cpp.

{
qDebug() << "src=" << src << " src_len=" << src_len
<< " dest_len=" << dest_len;
if(src_len == 0)
return 0;
unsigned int decompressed_size;
unsigned int more_space = src_len * 2;
decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
while(decompressed_size == 0)
{
qDebug() << "dest_len=" << dest_len;
qDebug() << "decompressed_size=" << decompressed_size;
if(errno == EINVAL)
{
throw PappsoException(
QObject::tr("ERROR reading TimsFrameType1 %1 TIMS binary file %2: "
"LZF decompression error EINVAL")
.arg(m_timsId));
}
else if(errno == E2BIG)
{
qDebug() << " m_timsDataFrame.size()=" << m_timsDataFrame.size()
<< " more_space=" << more_space;
m_timsDataFrame.resize(m_timsDataFrame.size() + more_space);
dest_len += more_space;
qDebug();
decompressed_size = lzf_decompress(src, src_len, dest, dest_len);
}
else
{
break;
}
}
return decompressed_size;
}

References pappso::TimsFrame::m_timsDataFrame, and pappso::TimsFrameBase::m_timsId.

Referenced by copyAndLzfDecompress().

## Member Data Documentation

## m_scanOffsetList

std::vector<std::size_t> pappso::TimsFrameType1::m_scanOffsetList

private

Definition at line 127 of file timsframetype1.h.

Referenced by copyAndLzfDecompress(), cumulateScan(), getMassSpectrumSPtr(), and getRawTraceSPtr().

## m_scanSizeList

std::vector<std::size_t> pappso::TimsFrameType1::m_scanSizeList

private

Definition at line 128 of file timsframetype1.h.

Referenced by copyAndLzfDecompress(), cumulateScan(), getMassSpectrumSPtr(), and getRawTraceSPtr().

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

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