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

`#include <timsbindec.h>`

## Public Member Functions

| TimsBinDec (const QFileInfo &timsBinFile, int timsCompressionType)
| TimsBinDec (const TimsBinDec &other)
virtual | ~TimsBinDec ()
TimsFrameSPtr | getTimsFrameSPtrByOffset (std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
void | closeLinearRead ()
| close file access and flush cache

## Private Member Functions

QFile * | getQfileLinear (std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
| open one QFile handler for linear read
QFile * | getQfileRandom ()
| open one QFile handler for random read
void | startLinearRead (std::size_t start_frame_id, std::size_t chunk_deque_size, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
| populate a fifo buffer with TimsFrameRawDataChunck accelerates inputs from file
TimsFrameSPtr | getTimsFrameFromRawDataChunck (const TimsFrameRawDataChunck &raw_data_chunck)
void | moveLinearReadForward (const std::vector< pappso::TimsFrameRecord > &frame_record_list)

## Private Attributes

int | m_timsCompressionType
QString | m_timsBinFile
QFile * | mp_fileLinear = nullptr
QFile * | mp_fileRandom = nullptr
char * | mpa_decompressMemoryBuffer = nullptr
std::size_t | m_decompressMemoryBufferSize = 0
TimsFrameRawDataChunck | m_randemAccessFrameRawDataChunck
std::vector< TimsFrameRawDataChunck > | m_linearAccessRawDataChunckList
std::size_t | m_firstFrameId = 0
std::size_t | m_lastFrameId = 0
std::size_t | m_linearAccessRawDataChunckDequeSize = 100
std::size_t | m_linearForwardThreshold = 30

## Detailed Description

Todo:
  write docs

Definition at line 44 of file timsbindec.h.

## Constructor & Destructor Documentation

## TimsBinDec() [1/2]

TimsBinDec::TimsBinDec | ( | const QFileInfo & | timsBinFile,
|  | int | timsCompressionType
| ) |  |

Default constructor

Definition at line 40 of file timsbindec.cpp.

: m_timsBinFile(timsBinFile.absoluteFilePath())
{
m_timsCompressionType = timsCompressionType;
if((timsCompressionType != 1) && (timsCompressionType != 2))
{
throw pappso::ExceptionNotImplemented(
QObject::tr("compression type %1 not handled by this library")
.arg(timsCompressionType));
}
if(m_timsBinFile.isEmpty())
{
throw pappso::PappsoException(
QObject::tr("No TIMS binary file name specified"));
}
QFile file(m_timsBinFile);
if(!file.open(QIODevice::ReadOnly))
{
throw PappsoException(
QObject::tr("ERROR opening TIMS binary file %1 for read")
.arg(timsBinFile.absoluteFilePath()));
}
}
pappso::ExceptionNotImplemented
Definition exceptionnotimplemented.h:32
pappso::PappsoException
Definition pappsoexception.h:42
pappso::TimsBinDec::m_timsCompressionType
int m_timsCompressionType
Definition timsbindec.h:100
pappso::TimsBinDec::m_timsBinFile
QString m_timsBinFile
Definition timsbindec.h:101

References m_timsBinFile, and m_timsCompressionType.

## TimsBinDec() [2/2]

TimsBinDec::TimsBinDec | ( | const TimsBinDec & | other | ) |

Copy constructor

Parameters

  other | TODO

Definition at line 65 of file timsbindec.cpp.

: m_timsBinFile(other.m_timsBinFile)
{
}

## ~TimsBinDec()

TimsBinDec::~TimsBinDec | ( |  | ) |

virtual

Destructor

Definition at line 70 of file timsbindec.cpp.

{
if(mpa_decompressMemoryBuffer != nullptr)
{
delete[] mpa_decompressMemoryBuffer;
}
if(mp_fileLinear != nullptr)
{
mp_fileLinear->close();
delete mp_fileLinear;
}
if(mp_fileRandom != nullptr)
{
mp_fileRandom->close();
delete mp_fileRandom;
}
}
pappso::TimsBinDec::mp_fileRandom
QFile * mp_fileRandom
Definition timsbindec.h:103
pappso::TimsBinDec::mp_fileLinear
QFile * mp_fileLinear
Definition timsbindec.h:102
pappso::TimsBinDec::mpa_decompressMemoryBuffer
char * mpa_decompressMemoryBuffer
Definition timsbindec.h:106

References mp_fileLinear, mp_fileRandom, and mpa_decompressMemoryBuffer.

## Member Function Documentation

## closeLinearRead()

void pappso::TimsBinDec::closeLinearRead | ( |  | ) |

close file access and flush cache

Definition at line 92 of file timsbindec.cpp.

{
// qDebug();
if(mp_fileLinear != nullptr)
{
mp_fileLinear->close();
delete mp_fileLinear;
}
mp_fileLinear = nullptr;
m_firstFrameId = 0;
m_lastFrameId = 0;
m_linearAccessRawDataChunckList.resize(0);
// qDebug();
}
pappso::TimsBinDec::m_firstFrameId
std::size_t m_firstFrameId
Definition timsbindec.h:113
pappso::TimsBinDec::m_lastFrameId
std::size_t m_lastFrameId
Definition timsbindec.h:114
pappso::TimsBinDec::m_linearAccessRawDataChunckList
std::vector< TimsFrameRawDataChunck > m_linearAccessRawDataChunckList
Definition timsbindec.h:112

Referenced by pappso::TimsData::ms2ReaderSpectrumCollectionByMsLevel().

## getQfileLinear()

QFile * TimsBinDec::getQfileLinear | ( | std::size_t | frameId,
|  | const std::vector< pappso::TimsFrameRecord > & | frame_record_list
| ) |  |

private

open one QFile handler for linear read

Definition at line 109 of file timsbindec.cpp.

{
if(mp_fileLinear == nullptr)
{
mp_fileLinear = new QFile(m_timsBinFile);
if(!mp_fileLinear->open(QIODevice::ReadOnly))
{
throw PappsoException(
QObject::tr("ERROR opening TIMS binary file %1 for read")
.arg(m_timsBinFile));
}
startLinearRead(
frameId, m_linearAccessRawDataChunckDequeSize, frame_record_list);
}
return mp_fileLinear;
}
pappso::TimsBinDec::startLinearRead
void startLinearRead(std::size_t start_frame_id, std::size_t chunk_deque_size, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
populate a fifo buffer with TimsFrameRawDataChunck accelerates inputs from file
Definition timsbindec.cpp:364
pappso::TimsBinDec::m_linearAccessRawDataChunckDequeSize
std::size_t m_linearAccessRawDataChunckDequeSize
Definition timsbindec.h:115

References m_linearAccessRawDataChunckDequeSize, m_timsBinFile, mp_fileLinear, and startLinearRead().

Referenced by getTimsFrameSPtrByOffset().

## getQfileRandom()

QFile * pappso::TimsBinDec::getQfileRandom | ( |  | ) |

private

open one QFile handler for random read

Definition at line 131 of file timsbindec.cpp.

{
if(mp_fileRandom == nullptr)
{
mp_fileRandom = new QFile(m_timsBinFile);
if(!mp_fileRandom->open(QIODevice::ReadOnly))
{
throw PappsoException(
QObject::tr("ERROR opening TIMS binary file %1 for read")
.arg(m_timsBinFile));
}
}
return mp_fileRandom;
}

Referenced by getTimsFrameSPtrByOffset().

## getTimsFrameFromRawDataChunck()

TimsFrameSPtr TimsBinDec::getTimsFrameFromRawDataChunck | ( | const TimsFrameRawDataChunck & | raw_data_chunck | ) |

private

Definition at line 254 of file timsbindec.cpp.

{
// qDebug();
TimsFrameSPtr frame_sptr;
if(raw_data_chunck.getCompressedSize() > 0)
{
// qDebug();
if(m_timsCompressionType == 2)
{
auto decompressed_size2 =
ZSTD_getFrameContentSize(raw_data_chunck.getMemoryBuffer(),
raw_data_chunck.getCompressedSize());
// qDebug();
if(decompressed_size2 == ZSTD_CONTENTSIZE_UNKNOWN)
{
throw PappsoException(
QObject::tr("ERROR TimsBinDec::getTimsFrameFromRawDataChunck "
"reading TIMS frame %1 TIMS binary file %2: "
" decompressed_size2 == ZSTD_CONTENTSIZE_UNKNOWN, "
"frame_length=%3")
.arg(raw_data_chunck.getFrameId())
.arg(m_timsBinFile)
.arg(raw_data_chunck.getFrameLength()));
}
// qDebug();
if(decompressed_size2 == ZSTD_CONTENTSIZE_ERROR)
{
// qDebug();
throw PappsoException(
QObject::tr("ERROR TimsBinDec::getTimsFrameFromRawDataChunck "
"reading TIMS frame %1 TIMS binary file %2: "
" decompressed_size2 == ZSTD_CONTENTSIZE_ERROR, "
"frame_length=%3")
.arg(raw_data_chunck.getFrameId())
.arg(m_timsBinFile)
.arg(raw_data_chunck.getFrameLength()));
}
qDebug() << " decompressed_size2=" << decompressed_size2;
if(m_decompressMemoryBufferSize < (decompressed_size2 + 10))
{
if(mpa_decompressMemoryBuffer != nullptr)
{
delete[] mpa_decompressMemoryBuffer;
}
m_decompressMemoryBufferSize = decompressed_size2 + 10;
mpa_decompressMemoryBuffer =
new char[m_decompressMemoryBufferSize];
}
std::size_t decompressed_size =
ZSTD_decompress(mpa_decompressMemoryBuffer,
m_decompressMemoryBufferSize,
raw_data_chunck.getMemoryBuffer(),
raw_data_chunck.getCompressedSize());
// qDebug();
if(decompressed_size != decompressed_size2)
{
throw PappsoException(
QObject::tr("ERROR TimsBinDec::getTimsFrameFromRawDataChunck "
"reading TIMS frame %1 TIMS binary file %2: "
"decompressed_size != decompressed_size2")
.arg(raw_data_chunck.getFrameId())
.arg(m_timsBinFile)
.arg(decompressed_size)
.arg(decompressed_size2));
}
// qDebug();
frame_sptr =
std::make_shared<TimsFrame>(raw_data_chunck.getFrameId(),
raw_data_chunck.getFrameNumberOfScans(),
mpa_decompressMemoryBuffer,
decompressed_size);
}
else
{
if(m_timsCompressionType == 1)
{
frame_sptr = std::make_shared<TimsFrameType1>(
raw_data_chunck.getFrameId(),
raw_data_chunck.getFrameNumberOfScans(),
raw_data_chunck.getMemoryBuffer(),
raw_data_chunck.getCompressedSize());
}
}
// delete[] mpa_decompressMemoryBuffer;
}
else
{
frame_sptr =
std::make_shared<TimsFrame>(raw_data_chunck.getFrameId(),
raw_data_chunck.getFrameNumberOfScans(),
nullptr,
0);
}
return frame_sptr;
}
pappso::TimsBinDec::m_decompressMemoryBufferSize
std::size_t m_decompressMemoryBufferSize
Definition timsbindec.h:107
pappso::TimsFrameRawDataChunck::getFrameId
std::size_t getFrameId() const
Definition timsframerawdatachunck.cpp:210
pappso::TimsFrameRawDataChunck::getCompressedSize
quint32 getCompressedSize() const
Definition timsframerawdatachunck.cpp:192
pappso::TimsFrameRawDataChunck::getFrameNumberOfScans
quint32 getFrameNumberOfScans() const
Definition timsframerawdatachunck.cpp:198
pappso::TimsFrameRawDataChunck::getMemoryBuffer
char * getMemoryBuffer() const
Definition timsframerawdatachunck.cpp:186
pappso::TimsFrameRawDataChunck::getFrameLength
quint32 getFrameLength() const
Definition timsframerawdatachunck.cpp:204
pappso::TimsFrameSPtr
std::shared_ptr< TimsFrame > TimsFrameSPtr
Definition timsframe.h:41

References pappso::TimsFrameRawDataChunck::getCompressedSize(), pappso::TimsFrameRawDataChunck::getFrameId(), pappso::TimsFrameRawDataChunck::getFrameLength(), pappso::TimsFrameRawDataChunck::getFrameNumberOfScans(), pappso::TimsFrameRawDataChunck::getMemoryBuffer(), m_decompressMemoryBufferSize, m_timsBinFile, m_timsCompressionType, and mpa_decompressMemoryBuffer.

Referenced by getTimsFrameSPtrByOffset().

## getTimsFrameSPtrByOffset()

TimsFrameSPtr TimsBinDec::getTimsFrameSPtrByOffset | ( | std::size_t | frameId,
|  | const std::vector< pappso::TimsFrameRecord > & | frame_record_list
| ) |  |

Definition at line 147 of file timsbindec.cpp.

{
qDebug() << "frameId:" << frameId;
// QMutexLocker locker(&m_mutex);
QFile *p_file = getQfileLinear(frameId, frame_record_list);
if(mp_fileLinear->pos() <
(qint64)frame_record_list[m_firstFrameId].tims_offset)
{
}
else
{
if(frameId > m_lastFrameId)
{
if(frameId - m_lastFrameId < m_linearForwardThreshold)
{
// move forward
moveLinearReadForward(frame_record_list);
}
}
}
auto it = std::find_if(m_linearAccessRawDataChunckList.begin(),
m_linearAccessRawDataChunckList.end(),
[frameId](const TimsFrameRawDataChunck &chunck) {
if(chunck.getFrameId() == frameId)
return true;
return false;
});
if(it != m_linearAccessRawDataChunckList.end())
{
try
{
return getTimsFrameFromRawDataChunck(*it);
}
catch(PappsoException &error)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS binary file %1 with linear QFile: "
"%2")
.arg(m_timsBinFile)
.arg(error.qwhat()));
}
}
// random access file
// qDebug();
p_file = getQfileRandom();
bool seekpos_ok = p_file->seek(frame_record_list[frameId].tims_offset);
if(!seekpos_ok)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"m_timsBinFile.seek(%3) failed")
.arg(frameId)
.arg(m_timsBinFile)
.arg(frame_record_list[frameId].tims_offset));
}
try
{
m_randemAccessFrameRawDataChunck.readTimsFrame(
p_file, frameId, frame_record_list);
}
catch(PappsoException &error)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS binary file %1 with random QFile: "
"%2")
.arg(m_timsBinFile)
.arg(error.qwhat()));
}
return getTimsFrameFromRawDataChunck(m_randemAccessFrameRawDataChunck);
}
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition pappsoexception.h:68
pappso::TimsBinDec::getQfileRandom
QFile * getQfileRandom()
open one QFile handler for random read
Definition timsbindec.cpp:131
pappso::TimsBinDec::m_linearForwardThreshold
std::size_t m_linearForwardThreshold
Definition timsbindec.h:116
pappso::TimsBinDec::getQfileLinear
QFile * getQfileLinear(std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
open one QFile handler for linear read
Definition timsbindec.cpp:109
pappso::TimsBinDec::moveLinearReadForward
void moveLinearReadForward(const std::vector< pappso::TimsFrameRecord > &frame_record_list)
Definition timsbindec.cpp:231
pappso::TimsBinDec::getTimsFrameFromRawDataChunck
TimsFrameSPtr getTimsFrameFromRawDataChunck(const TimsFrameRawDataChunck &raw_data_chunck)
Definition timsbindec.cpp:254
pappso::TimsBinDec::m_randemAccessFrameRawDataChunck
TimsFrameRawDataChunck m_randemAccessFrameRawDataChunck
Definition timsbindec.h:109
pappso::TimsFrameRawDataChunck
Definition timsframerawdatachunck.h:41
pappso::TimsFrameRawDataChunck::readTimsFrame
bool readTimsFrame(QFile *p_file, std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
Definition timsframerawdatachunck.cpp:47

References getQfileLinear(), getQfileRandom(), getTimsFrameFromRawDataChunck(), m_firstFrameId, m_lastFrameId, m_linearAccessRawDataChunckList, m_linearForwardThreshold, m_randemAccessFrameRawDataChunck, m_timsBinFile, moveLinearReadForward(), mp_fileLinear, pappso::PappsoException::qwhat(), and pappso::TimsFrameRawDataChunck::readTimsFrame().

Referenced by pappso::TimsData::getTimsFrameCstSPtr().

## moveLinearReadForward()

void pappso::TimsBinDec::moveLinearReadForward | ( | const std::vector< pappso::TimsFrameRecord > & | frame_record_list | ) |

private

Definition at line 231 of file timsbindec.cpp.

{
// qDebug();
for(std::size_t i = 0; i < m_linearForwardThreshold; i++)
{
auto it = std::min_element(
m_linearAccessRawDataChunckList.begin(),
m_linearAccessRawDataChunckList.end(),
[](const TimsFrameRawDataChunck &a, const TimsFrameRawDataChunck &b) {
return a.getFrameId() < b.getFrameId();
});
m_lastFrameId++;
m_firstFrameId++;
if(m_lastFrameId >= frame_record_list.size())
break;
it->readTimsFrame(mp_fileLinear, m_lastFrameId, frame_record_list);
}
// qDebug();
}
pappso::PeptideIonNter::a
@ a
pappso::PeptideIonNter::b
@ b

References pappso::a, and pappso::b.

Referenced by getTimsFrameSPtrByOffset().

## startLinearRead()

void pappso::TimsBinDec::startLinearRead | ( | std::size_t | start_frame_id,
|  | std::size_t | chunk_deque_size,
|  | const std::vector< pappso::TimsFrameRecord > & | frame_record_list
| ) |  |

private

populate a fifo buffer with TimsFrameRawDataChunck accelerates inputs from file

Definition at line 364 of file timsbindec.cpp.

{
// qDebug();
m_linearAccessRawDataChunckList.resize(chunk_deque_size);
m_firstFrameId = start_frame_id;
m_lastFrameId = start_frame_id;
QFile *p_file = mp_fileLinear;
if(p_file == nullptr)
{
throw PappsoException(QObject::tr("ERROR mp_fileLinear == nullptr"));
}
bool seekpos_ok = p_file->seek(frame_record_list[start_frame_id].tims_offset);
if(!seekpos_ok)
{
throw PappsoException(
QObject::tr("ERROR reading TIMS frame %1 TIMS binary file %2: "
"m_timsBinFile.seek(%3) failed")
.arg(start_frame_id)
.arg(m_timsBinFile)
.arg(frame_record_list[start_frame_id].tims_offset));
}
try
{
for(TimsFrameRawDataChunck &chunck : m_linearAccessRawDataChunckList)
{
chunck.readTimsFrame(p_file, start_frame_id, frame_record_list);
m_lastFrameId = start_frame_id;
start_frame_id++;
}
}
catch(PappsoException &error)
{
throw PappsoException(
QObject::tr(
"ERROR in TimsBinDec::startLinearRead reading TIMS binary file %1:\n "
" start_frame_id=%2 m_firstFrameId=%3 m_lastFrameId=%4 "
"%5")
.arg(m_timsBinFile)
.arg(start_frame_id)
.arg(m_firstFrameId)
.arg(m_lastFrameId)
.arg(error.qwhat()));
}
// qDebug();
}

References pappso::PappsoException::qwhat().

Referenced by getQfileLinear().

## Member Data Documentation

## m_decompressMemoryBufferSize

std::size_t pappso::TimsBinDec::m_decompressMemoryBufferSize = 0

private

Definition at line 107 of file timsbindec.h.

Referenced by getTimsFrameFromRawDataChunck().

## m_firstFrameId

std::size_t pappso::TimsBinDec::m_firstFrameId = 0

private

Definition at line 113 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_lastFrameId

std::size_t pappso::TimsBinDec::m_lastFrameId = 0

private

Definition at line 114 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_linearAccessRawDataChunckDequeSize

std::size_t pappso::TimsBinDec::m_linearAccessRawDataChunckDequeSize = 100

private

Definition at line 115 of file timsbindec.h.

Referenced by getQfileLinear().

## m_linearAccessRawDataChunckList

std::vector<TimsFrameRawDataChunck> pappso::TimsBinDec::m_linearAccessRawDataChunckList

private

Definition at line 112 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_linearForwardThreshold

std::size_t pappso::TimsBinDec::m_linearForwardThreshold = 30

private

Definition at line 116 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_randemAccessFrameRawDataChunck

TimsFrameRawDataChunck pappso::TimsBinDec::m_randemAccessFrameRawDataChunck

private

Definition at line 109 of file timsbindec.h.

Referenced by getTimsFrameSPtrByOffset().

## m_timsBinFile

QString pappso::TimsBinDec::m_timsBinFile

private

Definition at line 101 of file timsbindec.h.

Referenced by TimsBinDec(), getQfileLinear(), getTimsFrameFromRawDataChunck(), and getTimsFrameSPtrByOffset().

## m_timsCompressionType

int pappso::TimsBinDec::m_timsCompressionType

private

Definition at line 100 of file timsbindec.h.

Referenced by TimsBinDec(), and getTimsFrameFromRawDataChunck().

## mp_fileLinear

QFile* pappso::TimsBinDec::mp_fileLinear = nullptr

private

Definition at line 102 of file timsbindec.h.

Referenced by ~TimsBinDec(), getQfileLinear(), and getTimsFrameSPtrByOffset().

## mp_fileRandom

QFile* pappso::TimsBinDec::mp_fileRandom = nullptr

private

Definition at line 103 of file timsbindec.h.

Referenced by ~TimsBinDec().

## mpa_decompressMemoryBuffer

char* pappso::TimsBinDec::mpa_decompressMemoryBuffer = nullptr

private

Definition at line 106 of file timsbindec.h.

Referenced by ~TimsBinDec(), and getTimsFrameFromRawDataChunck().

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

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