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

`#include <timsdata.h>`

## Public Member Functions

| TimsData (QDir timsDataDirectory)
| build using the tims data directory
| TimsData (const TimsData &other)
virtual | ~TimsData ()
bool | isDdaRun () const
| tells if this MS run is a DDA run
bool | isDiaRun () const
| tells if this MS run is a DIA run
pappso::MassSpectrumCstSPtr | getMassSpectrumCstSPtrByRawIndex (std::size_t raw_index)
| get a mass spectrum given its spectrum index
pappso::MassSpectrumCstSPtr | getMassSpectrumCstSPtrByGlobalScanIndex (std::size_t index)
pappso::MassSpectrumCstSPtr | getMassSpectrumCstSPtr (std::size_t timsId, std::size_t scanNum)
| get a mass spectrum given the tims frame database id and scan number within tims frame
std::size_t | getTotalNumberOfFrames () const
| Get total number of frames.
std::size_t | getFrameCount () const
std::size_t | getTotalNumberOfScans () const
| get the total number of scans
std::size_t | getTotalScanCount () const
unsigned int | getMsLevelBySpectrumIndex (std::size_t index)
unsigned int | getMsLevelByGlobalScanIndex (std::size_t index)
void | getQualifiedMassSpectrumByRawIndex (const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, std::size_t global_scan_index, bool want_binary_data)
void | getQualifiedMassSpectrumByGlobalScanIndex (const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, std::size_t global_scan_index, bool want_binary_data)
Trace | getTicChromatogram () const
std::vector< std::size_t > | getTimsMS1FrameIdsInRtRange (double rt_begin, double rt_end) const
std::vector< std::size_t > | getTimsMS2FrameIdsInRtRange (double rt_begin, double rt_end) const
TimsFrameCstSPtr | getTimsFrameCstSPtrCached (std::size_t timsId)
| get a Tims frame with his database ID but look in the cache first
TimsFrameCstSPtr | getTimsFrameCstSPtr (std::size_t timsId)
| get a Tims frame with his database ID
TimsDataFastMap & | getRawMsBySpectrumIndex (std::size_t index)
| get raw signal for a spectrum index only to use to see the raw signal
TimsDataFastMap & | getScanByGlobalScanIndex (std::size_t index)
virtual std::vector< double > | getRetentionTimeLine () const
| retention timeline get retention times along the MSrun in seconds
virtual std::vector< double > | getRetentionTimeLineInSeconds () const
const std::vector< FrameIdDescr > & | getFrameIdDescrList () const
const std::vector< TimsFrameRecord > & | getTimsFrameRecordList () const
const QDir & | getTimsDataDirectory () const
TimsDdaPrecursors * | getTimsDdaPrecursorsPtr () const
TimsDiaSlices * | getTimsDiaSlicesPtr () const

## Protected Member Functions

QSqlDatabase | openDatabaseConnection () const
TimsBinDec * | getTimsBinDecPtr () const

## Private Member Functions

std::pair< std::size_t, std::size_t > | getScanCoordinateFromRawIndex (std::size_t spectrum_index) const
std::pair< std::size_t, std::size_t > | getScanCoordinatesByGlobalScanIndex (std::size_t index) const
std::size_t | getRawIndexFromCoordinate (std::size_t frame_id, std::size_t scan_num) const
std::size_t | getGlobalScanIndexByScanCoordinates (std::size_t frame_id, std::size_t index) const
TimsFrameBaseCstSPtr | getTimsFrameBaseCstSPtr (std::size_t timsId)
| get a Tims frame base (no binary data file access) with his database ID
TimsFrameBaseCstSPtr | getTimsFrameBaseCstSPtrCached (std::size_t timsId)
void | fillFrameIdDescrList ()
| private function to fill m_frameIdDescrList

## Private Attributes

friend | TimsDdaPrecursors
friend | TimsDiaSlices
QDir | m_timsDataDirectory
TimsBinDec * | mpa_timsBinDec = nullptr
TimsDdaPrecursors * | mpa_timsDdaPrecursors = nullptr
TimsDiaSlices * | mpa_timsDiaSlices = nullptr
std::size_t | m_totalScanCount
std::size_t | m_frameCount
std::size_t | m_cacheSize = 60
std::deque< TimsFrameCstSPtr > | m_timsFrameCache
std::deque< TimsFrameBaseCstSPtr > | m_timsFrameBaseCache
std::map< int, QSqlRecord > | m_mapMzCalibrationRecord
std::map< int, QSqlRecord > | m_mapTimsCalibrationRecord
std::vector< TimsFrameRecord > | m_mapFramesRecord
MzCalibrationStore * | mpa_mzCalibrationStore
std::vector< FrameIdDescr > | m_frameIdDescrList
| store every frame id and corresponding sizes
std::map< std::size_t, std::size_t > | m_thousandIndexToFrameIdDescrListIndex
| index to find quickly a frameId in the description list with the raw index of spectrum modulo 1000 @key thousands of TOF scans @value corresponding m_frameIdDescrList index
std::vector< std::size_t > | m_someoneIsLoadingFrameId
| tells if someone is loading a frame id
QMutex | m_mutex

## Detailed Description

Todo:
  write docs

Definition at line 69 of file timsdata.h.

## Constructor & Destructor Documentation

## TimsData() [1/2]

pappso::TimsData::TimsData | ( | QDir | timsDataDirectory | ) |

build using the tims data directory

Definition at line 46 of file timsdata.cpp.

: m_timsDataDirectory(timsDataDirectory)
{
qDebug() << "Start of construction of TimsData";
mpa_mzCalibrationStore = new MzCalibrationStore();
if(!m_timsDataDirectory.exists())
{
throw PappsoException(
QObject::tr("ERROR TIMS data directory %1 not found")
.arg(m_timsDataDirectory.absolutePath()));
}
if(!QFileInfo(m_timsDataDirectory.absoluteFilePath("analysis.tdf")).exists())
{
throw PappsoException(
QObject::tr("ERROR TIMS data directory, %1 sqlite file not found")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf")));
}
// Open the database
QSqlDatabase qdb = openDatabaseConnection();
QSqlQuery q(qdb);
if(!q.exec("select Key, Value from GlobalMetadata where "
"Key='TimsCompressionType';"))
{
qDebug();
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(q.lastError().databaseText())
.arg(q.lastError().driverText())
.arg(q.lastError().nativeErrorCode()));
}
int compression_type = 0;
if(q.next())
{
compression_type = q.value(1).toInt();
}
qDebug() << " compression_type=" << compression_type;
mpa_timsBinDec = new TimsBinDec(
QFileInfo(m_timsDataDirectory.absoluteFilePath("analysis.tdf_bin")),
compression_type);
qDebug();
try
{
qDebug();
mpa_timsDdaPrecursors = new TimsDdaPrecursors(q, this);
}
catch(pappso::ExceptionNotFound &not_found)
{
qDebug();
mpa_timsDdaPrecursors = nullptr;
}
qDebug();
try
{
qDebug();
mpa_timsDiaSlices = new TimsDiaSlices(q, this);
}
catch(pappso::ExceptionNotFound &not_found)
{
qDebug();
mpa_timsDiaSlices = nullptr;
}
fillFrameIdDescrList();
// get number of scans
if(!q.exec("SELECT SUM(NumScans),COUNT(Id) FROM Frames"))
{
qDebug();
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
if(q.next())
{
qDebug();
m_totalScanCount = q.value(0).toLongLong();
m_frameCount = q.value(1).toLongLong();
}
if(!q.exec("select * from MzCalibration;"))
{
qDebug();
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(q.lastError().databaseText())
.arg(q.lastError().driverText())
.arg(q.lastError().nativeErrorCode()));
}
while(q.next())
{
QSqlRecord record = q.record();
m_mapMzCalibrationRecord.insert(
std::pair<int, QSqlRecord>(record.value(0).toInt(), record));
}
// m_mapTimsCalibrationRecord
if(!q.exec("select * from TimsCalibration;"))
{
qDebug();
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(q.lastError().databaseText())
.arg(q.lastError().driverText())
.arg(q.lastError().nativeErrorCode()));
}
while(q.next())
{
QSqlRecord record = q.record();
m_mapTimsCalibrationRecord.insert(
std::pair<int, QSqlRecord>(record.value(0).toInt(), record));
}
// store frames
if(!q.exec("select Frames.TimsId, Frames.AccumulationTime, " // 1
"Frames.MzCalibration, " // 2
"Frames.T1, Frames.T2, " // 4
"Frames.Time, Frames.MsMsType, Frames.TimsCalibration, " // 7
"Frames.Id " // 8
" FROM Frames;"))
{
qDebug();
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(q.lastError().databaseText())
.arg(q.lastError().driverText())
.arg(q.lastError().nativeErrorCode()));
}
m_mapFramesRecord.resize(m_frameCount + 1);
while(q.next())
{
QSqlRecord record = q.record();
TimsFrameRecord &frame_record =
m_mapFramesRecord[record.value(8).toULongLong()];
frame_record.frame_id = record.value(8).toULongLong();
frame_record.tims_offset = record.value(0).toULongLong();
frame_record.accumulation_time = record.value(1).toDouble();
frame_record.mz_calibration_id = record.value(2).toULongLong();
frame_record.frame_t1 = record.value(3).toDouble();
frame_record.frame_t2 = record.value(4).toDouble();
frame_record.frame_time = record.value(5).toDouble();
frame_record.msms_type = record.value(6).toInt();
frame_record.tims_calibration_id = record.value(7).toULongLong();
}
qDebug();
}
pappso::ExceptionNotFound
Definition exceptionnotfound.h:32
pappso::TimsData::openDatabaseConnection
QSqlDatabase openDatabaseConnection() const
Definition timsdata.cpp:231
pappso::TimsData::mpa_timsDdaPrecursors
TimsDdaPrecursors * mpa_timsDdaPrecursors
Definition timsdata.h:255
pappso::TimsData::TimsDdaPrecursors
friend TimsDdaPrecursors
Definition timsdata.h:71
pappso::TimsData::m_mapFramesRecord
std::vector< TimsFrameRecord > m_mapFramesRecord
Definition timsdata.h:267
pappso::TimsData::m_totalScanCount
std::size_t m_totalScanCount
Definition timsdata.h:258
pappso::TimsData::m_mapMzCalibrationRecord
std::map< int, QSqlRecord > m_mapMzCalibrationRecord
Definition timsdata.h:265
pappso::TimsData::m_mapTimsCalibrationRecord
std::map< int, QSqlRecord > m_mapTimsCalibrationRecord
Definition timsdata.h:266
pappso::TimsData::fillFrameIdDescrList
void fillFrameIdDescrList()
private function to fill m_frameIdDescrList
Definition timsdata.cpp:288
pappso::TimsData::TimsDiaSlices
friend TimsDiaSlices
Definition timsdata.h:72
pappso::TimsData::m_timsDataDirectory
QDir m_timsDataDirectory
Definition timsdata.h:252
pappso::TimsData::mpa_mzCalibrationStore
MzCalibrationStore * mpa_mzCalibrationStore
Definition timsdata.h:269
pappso::TimsData::mpa_timsBinDec
TimsBinDec * mpa_timsBinDec
Definition timsdata.h:253
pappso::TimsData::mpa_timsDiaSlices
TimsDiaSlices * mpa_timsDiaSlices
Definition timsdata.h:256
pappso::TimsData::m_frameCount
std::size_t m_frameCount
Definition timsdata.h:259

References pappso::TimsFrameRecord::accumulation_time, fillFrameIdDescrList(), pappso::TimsFrameRecord::frame_id, pappso::TimsFrameRecord::frame_t1, pappso::TimsFrameRecord::frame_t2, pappso::TimsFrameRecord::frame_time, m_frameCount, m_mapFramesRecord, m_mapMzCalibrationRecord, m_mapTimsCalibrationRecord, m_timsDataDirectory, m_totalScanCount, mpa_mzCalibrationStore, mpa_timsBinDec, mpa_timsDdaPrecursors, mpa_timsDiaSlices, pappso::TimsFrameRecord::msms_type, pappso::TimsFrameRecord::mz_calibration_id, openDatabaseConnection(), pappso::TimsFrameRecord::tims_calibration_id, pappso::TimsFrameRecord::tims_offset, TimsDdaPrecursors, and TimsDiaSlices.

## TimsData() [2/2]

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

Copy constructor

Parameters

  other | TODO

Definition at line 261 of file timsdata.cpp.

{
qDebug();
}

## ~TimsData()

pappso::TimsData::~TimsData | ( |  | ) |

virtual

Destructor

Definition at line 266 of file timsdata.cpp.

{
// m_qdb.close();
if(mpa_timsBinDec != nullptr)
{
delete mpa_timsBinDec;
}
if(mpa_mzCalibrationStore != nullptr)
{
delete mpa_mzCalibrationStore;
}
if(mpa_timsDdaPrecursors != nullptr)
{
delete mpa_timsDdaPrecursors;
}
if(mpa_timsDiaSlices != nullptr)
{
delete mpa_timsDiaSlices;
}
}

References mpa_mzCalibrationStore, mpa_timsBinDec, mpa_timsDdaPrecursors, and mpa_timsDiaSlices.

## Member Function Documentation

## fillFrameIdDescrList()

void pappso::TimsData::fillFrameIdDescrList | ( |  | ) |

private

private function to fill m_frameIdDescrList

number of scans in mobility dimension (number of TOF scans)

Definition at line 288 of file timsdata.cpp.

{
qDebug();
QSqlDatabase qdb = openDatabaseConnection();
QSqlQuery q =
qdb.exec(QString("SELECT Id, NumScans FROM "
"Frames ORDER BY Id"));
if(q.lastError().isValid())
{
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, executing SQL "
"command %2:\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
TimsFrameSPtr tims_frame;
bool index_found = false;
std::size_t timsId;
/** @brief number of scans in mobility dimension (number of TOF scans)
*/
std::size_t numberScans;
std::size_t cumulScans = 0;
while(q.next() && (!index_found))
{
timsId = q.value(0).toULongLong();
numberScans = q.value(1).toULongLong();
// qDebug() << timsId;
m_thousandIndexToFrameIdDescrListIndex.insert(
std::pair<std::size_t, std::size_t>((cumulScans / 1000),
m_frameIdDescrList.size()));
m_frameIdDescrList.push_back({timsId, numberScans, cumulScans});
cumulScans += numberScans;
}
qDebug();
}
pappso::TimsData::m_frameIdDescrList
std::vector< FrameIdDescr > m_frameIdDescrList
store every frame id and corresponding sizes
Definition timsdata.h:274
pappso::TimsData::m_thousandIndexToFrameIdDescrListIndex
std::map< std::size_t, std::size_t > m_thousandIndexToFrameIdDescrListIndex
index to find quickly a frameId in the description list with the raw index of spectrum modulo 1000 @k...
Definition timsdata.h:281
pappso::TimsFrameSPtr
std::shared_ptr< TimsFrame > TimsFrameSPtr
Definition timsframe.h:42

References m_frameIdDescrList, m_thousandIndexToFrameIdDescrListIndex, m_timsDataDirectory, and openDatabaseConnection().

Referenced by TimsData().

## getFrameCount()

std::size_t pappso::TimsData::getFrameCount | ( |  | ) | const

Definition at line 686 of file timsdata.cpp.

{
return m_frameCount;
}

References m_frameCount.

## getFrameIdDescrList()

const std::vector< FrameIdDescr > & pappso::TimsData::getFrameIdDescrList | ( |  | ) | const

Definition at line 1074 of file timsdata.cpp.

{
return m_frameIdDescrList;
}

References m_frameIdDescrList.

Referenced by pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## getGlobalScanIndexByScanCoordinates()

std::size_t pappso::TimsData::getGlobalScanIndexByScanCoordinates | ( | std::size_t | frame_id,
|  | std::size_t | index
| ) |  | const

private

Definition at line 381 of file timsdata.cpp.

{
for(auto frameDescr : m_frameIdDescrList)
{
if(frameDescr.m_frameId == frame_id)
{
return frameDescr.m_globalScanIndex + index;
}
}
throw ExceptionNotFound(
QObject::tr("ERROR raw index with frame_id=%1 scan_index=%2 not found")
.arg(frame_id)
.arg(index));
}

References m_frameIdDescrList.

Referenced by getQualifiedMassSpectrumByGlobalScanIndex(), getRawIndexFromCoordinate(), and pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## getMassSpectrumCstSPtr()

MassSpectrumCstSPtr pappso::TimsData::getMassSpectrumCstSPtr | ( | std::size_t | timsId,
|  | std::size_t | scanNum
| ) |  |

get a mass spectrum given the tims frame database id and scan number within tims frame

Definition at line 669 of file timsdata.cpp.

{
qDebug() << " timsId=" << timsId << " scanNum=" << scanNum;
TimsFrameCstSPtr frame = getTimsFrameCstSPtrCached(timsId);
return frame->getMassSpectrumCstSPtr(scanNum);
}
pappso::TimsData::getTimsFrameCstSPtrCached
TimsFrameCstSPtr getTimsFrameCstSPtrCached(std::size_t timsId)
get a Tims frame with his database ID but look in the cache first
Definition timsdata.cpp:953
pappso::TimsFrameCstSPtr
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition timsframe.h:43

References getTimsFrameCstSPtrCached().

Referenced by getMassSpectrumCstSPtrByGlobalScanIndex().

## getMassSpectrumCstSPtrByGlobalScanIndex()

pappso::MassSpectrumCstSPtr pappso::TimsData::getMassSpectrumCstSPtrByGlobalScanIndex | ( | std::size_t | index | ) |

Definition at line 410 of file timsdata.cpp.

{
qDebug() << " raw_index=" << raw_index;
try
{
auto coordinate = getScanCoordinatesByGlobalScanIndex(raw_index);
return getMassSpectrumCstSPtr(coordinate.first, coordinate.second);
}
catch(PappsoException &error)
{
throw PappsoException(
QObject::tr("Error TimsData::getMassSpectrumCstSPtrByRawIndex "
"raw_index=%1 :\n%2")
.arg(raw_index)
.arg(error.qwhat()));
}
}
pappso::TimsData::getMassSpectrumCstSPtr
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtr(std::size_t timsId, std::size_t scanNum)
get a mass spectrum given the tims frame database id and scan number within tims frame
Definition timsdata.cpp:669
pappso::TimsData::getScanCoordinatesByGlobalScanIndex
std::pair< std::size_t, std::size_t > getScanCoordinatesByGlobalScanIndex(std::size_t index) const
Definition timsdata.cpp:339

References getMassSpectrumCstSPtr(), getScanCoordinatesByGlobalScanIndex(), and pappso::PappsoException::qwhat().

Referenced by getMassSpectrumCstSPtrByRawIndex().

## getMassSpectrumCstSPtrByRawIndex()

MassSpectrumCstSPtr pappso::TimsData::getMassSpectrumCstSPtrByRawIndex | ( | std::size_t | raw_index | ) |

get a mass spectrum given its spectrum index

Parameters

  raw_index | a number begining at 0, corresponding to a Tims Scan in the order they lies in the binary data file

Definition at line 404 of file timsdata.cpp.

{
return getMassSpectrumCstSPtrByGlobalScanIndex(raw_index);
}
pappso::TimsData::getMassSpectrumCstSPtrByGlobalScanIndex
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtrByGlobalScanIndex(std::size_t index)
Definition timsdata.cpp:410

References getMassSpectrumCstSPtrByGlobalScanIndex().

## getMsLevelByGlobalScanIndex()

unsigned int pappso::TimsData::getMsLevelByGlobalScanIndex | ( | std::size_t | index | ) |

Definition at line 713 of file timsdata.cpp.

{
auto coordinate = getScanCoordinatesByGlobalScanIndex(index);
auto tims_frame = getTimsFrameCstSPtrCached(coordinate.first);
return tims_frame.get()->getMsLevel();
}

References getScanCoordinatesByGlobalScanIndex(), and getTimsFrameCstSPtrCached().

Referenced by getMsLevelBySpectrumIndex().

## getMsLevelBySpectrumIndex()

unsigned int pappso::TimsData::getMsLevelBySpectrumIndex | ( | std::size_t | index | ) |

Definition at line 706 of file timsdata.cpp.

{
return getMsLevelByGlobalScanIndex(index);
}
pappso::TimsData::getMsLevelByGlobalScanIndex
unsigned int getMsLevelByGlobalScanIndex(std::size_t index)
Definition timsdata.cpp:713

References getMsLevelByGlobalScanIndex().

## getQualifiedMassSpectrumByGlobalScanIndex()

void pappso::TimsData::getQualifiedMassSpectrumByGlobalScanIndex | ( | const MsRunIdCstSPtr & | msrun_id,
|  | QualifiedMassSpectrum & | mass_spectrum,
|  | std::size_t | global_scan_index,
|  | bool | want_binary_data
| ) |  |

Definition at line 734 of file timsdata.cpp.

{
try
{
auto coordinate = getScanCoordinatesByGlobalScanIndex(global_scan_index);
TimsFrameBaseCstSPtr tims_frame;
if(want_binary_data)
{
tims_frame = getTimsFrameCstSPtrCached(coordinate.first);
}
else
{
tims_frame = getTimsFrameBaseCstSPtrCached(coordinate.first);
}
MassSpectrumId spectrum_id;
spectrum_id.setSpectrumIndex(global_scan_index);
spectrum_id.setMsRunId(msrun_id);
spectrum_id.setNativeId(
QString("frame_id=%1 scan_index=%2 global_scan_index=%3")
.arg(coordinate.first)
.arg(coordinate.second)
.arg(global_scan_index));
mass_spectrum.setMassSpectrumId(spectrum_id);
mass_spectrum.setMsLevel(tims_frame.get()->getMsLevel());
mass_spectrum.setRtInSeconds(tims_frame.get()->getRtInSeconds());
mass_spectrum.setDtInMilliSeconds(
tims_frame.get()->getDriftTimeInMilliseconds(coordinate.second));
// 1/K0
mass_spectrum.setParameterValue(
QualifiedMassSpectrumParameter::IonMobOneOverK0,
tims_frame.get()->getOneOverK0Transformation(coordinate.second));
mass_spectrum.setEmptyMassSpectrum(true);
if(want_binary_data)
{
mass_spectrum.setMassSpectrumSPtr(
tims_frame.get()->getMassSpectrumSPtr(coordinate.second));
if(mass_spectrum.size() > 0)
{
mass_spectrum.setEmptyMassSpectrum(false);
}
}
else
{
// if(tims_frame.get()->getNbrPeaks(coordinate.second) > 0)
//{
mass_spectrum.setEmptyMassSpectrum(false);
// }
}
if(tims_frame.get()->getMsLevel() > 1)
{
if(mpa_timsDdaPrecursors != nullptr)
{
auto spectrum_descr =
mpa_timsDdaPrecursors->getSpectrumDescrWithScanCoordinates(
coordinate);
if(spectrum_descr.precursor_id > 0)
{
mass_spectrum.appendPrecursorIonData(
spectrum_descr.precursor_ion_data);
MassSpectrumId spectrum_id;
std::size_t prec_spectrum_index =
getGlobalScanIndexByScanCoordinates(
spectrum_descr.parent_frame, coordinate.second);
mass_spectrum.setPrecursorSpectrumIndex(prec_spectrum_index);
mass_spectrum.setPrecursorNativeId(
QString("frame_id=%1 scan_index=%2 global_scan_index=%3")
.arg(spectrum_descr.parent_frame)
.arg(coordinate.second)
.arg(prec_spectrum_index));
mass_spectrum.setParameterValue(
QualifiedMassSpectrumParameter::IsolationMz,
spectrum_descr.isolationMz);
mass_spectrum.setParameterValue(
QualifiedMassSpectrumParameter::IsolationMzWidth,
spectrum_descr.isolationWidth);
mass_spectrum.setParameterValue(
QualifiedMassSpectrumParameter::CollisionEnergy,
spectrum_descr.collisionEnergy);
mass_spectrum.setParameterValue(
QualifiedMassSpectrumParameter::BrukerPrecursorIndex,
(quint64)spectrum_descr.precursor_id);
}
}
}
}
catch(PappsoException &error)
{
throw PappsoException(
QObject::tr("Error TimsData::getQualifiedMassSpectrumByRawIndex "
"spectrum_index=%1 :\n%2")
.arg(global_scan_index)
.arg(error.qwhat()));
}
}
pappso::TimsData::getGlobalScanIndexByScanCoordinates
std::size_t getGlobalScanIndexByScanCoordinates(std::size_t frame_id, std::size_t index) const
Definition timsdata.cpp:381
pappso::TimsData::getTimsFrameBaseCstSPtrCached
TimsFrameBaseCstSPtr getTimsFrameBaseCstSPtrCached(std::size_t timsId)
Definition timsdata.cpp:932
pappso::TimsDdaPrecursors::getSpectrumDescrWithScanCoordinates
SpectrumDescr getSpectrumDescrWithScanCoordinates(const std::pair< std::size_t, std::size_t > &scan_coordinates)
Definition timsddaprecursors.cpp:501
pappso::TimsFrameBaseCstSPtr
std::shared_ptr< const TimsFrameBase > TimsFrameBaseCstSPtr
Definition timsframebase.h:42
pappso::QualifiedMassSpectrumParameter::IsolationMzWidth
@ IsolationMzWidth
m/z isolation window width (left + right)
pappso::QualifiedMassSpectrumParameter::CollisionEnergy
@ CollisionEnergy
Bruker's timsTOF collision energy.
pappso::QualifiedMassSpectrumParameter::IsolationMz
@ IsolationMz
Isolation m/z value.
pappso::QualifiedMassSpectrumParameter::BrukerPrecursorIndex
@ BrukerPrecursorIndex
Bruker's timsTOF precursor index.
pappso::QualifiedMassSpectrumParameter::IonMobOneOverK0
@ IonMobOneOverK0
1/kO value

References pappso::QualifiedMassSpectrum::appendPrecursorIonData(), pappso::BrukerPrecursorIndex, pappso::CollisionEnergy, getGlobalScanIndexByScanCoordinates(), getScanCoordinatesByGlobalScanIndex(), pappso::TimsDdaPrecursors::getSpectrumDescrWithScanCoordinates(), getTimsFrameBaseCstSPtrCached(), getTimsFrameCstSPtrCached(), pappso::IonMobOneOverK0, pappso::IsolationMz, pappso::IsolationMzWidth, mpa_timsDdaPrecursors, pappso::PappsoException::qwhat(), pappso::QualifiedMassSpectrum::setDtInMilliSeconds(), pappso::QualifiedMassSpectrum::setEmptyMassSpectrum(), pappso::QualifiedMassSpectrum::setMassSpectrumId(), pappso::QualifiedMassSpectrum::setMassSpectrumSPtr(), pappso::QualifiedMassSpectrum::setMsLevel(), pappso::MassSpectrumId::setMsRunId(), pappso::MassSpectrumId::setNativeId(), pappso::QualifiedMassSpectrum::setParameterValue(), pappso::QualifiedMassSpectrum::setPrecursorNativeId(), pappso::QualifiedMassSpectrum::setPrecursorSpectrumIndex(), pappso::QualifiedMassSpectrum::setRtInSeconds(), pappso::MassSpectrumId::setSpectrumIndex(), and pappso::QualifiedMassSpectrum::size().

Referenced by getQualifiedMassSpectrumByRawIndex().

## getQualifiedMassSpectrumByRawIndex()

void pappso::TimsData::getQualifiedMassSpectrumByRawIndex | ( | const MsRunIdCstSPtr & | msrun_id,
|  | QualifiedMassSpectrum & | mass_spectrum,
|  | std::size_t | global_scan_index,
|  | bool | want_binary_data
| ) |  |

Definition at line 722 of file timsdata.cpp.

{
return getQualifiedMassSpectrumByGlobalScanIndex(
msrun_id, mass_spectrum, global_scan_index, want_binary_data);
}
pappso::TimsData::getQualifiedMassSpectrumByGlobalScanIndex
void getQualifiedMassSpectrumByGlobalScanIndex(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, std::size_t global_scan_index, bool want_binary_data)
Definition timsdata.cpp:734

References getQualifiedMassSpectrumByGlobalScanIndex().

## getRawIndexFromCoordinate()

std::size_t pappso::TimsData::getRawIndexFromCoordinate | ( | std::size_t | frame_id,
|  | std::size_t | scan_num
| ) |  | const

private

Definition at line 373 of file timsdata.cpp.

{
return getGlobalScanIndexByScanCoordinates(frame_id, index);
}

References getGlobalScanIndexByScanCoordinates().

## getRawMsBySpectrumIndex()

TimsDataFastMap & pappso::TimsData::getRawMsBySpectrumIndex | ( | std::size_t | index | ) |

get raw signal for a spectrum index only to use to see the raw signal

Parameters

  spectrum_index | spcetrum index

Returns
  a map of integers, x=time of flights, y= intensities

Definition at line 1053 of file timsdata.cpp.

{
return getScanByGlobalScanIndex(index);
}
pappso::TimsData::getScanByGlobalScanIndex
TimsDataFastMap & getScanByGlobalScanIndex(std::size_t index)
Definition timsdata.cpp:1059

References getScanByGlobalScanIndex().

## getRetentionTimeLine()

std::vector< double > pappso::TimsData::getRetentionTimeLine | ( |  | ) | const

virtual

retention timeline get retention times along the MSrun in seconds

Returns
  vector of retention times (seconds)

Definition at line 1031 of file timsdata.cpp.

{
return getRetentionTimeLineInSeconds();
}
pappso::TimsData::getRetentionTimeLineInSeconds
virtual std::vector< double > getRetentionTimeLineInSeconds() const
Definition timsdata.cpp:1037

References getRetentionTimeLineInSeconds().

## getRetentionTimeLineInSeconds()

std::vector< double > pappso::TimsData::getRetentionTimeLineInSeconds | ( |  | ) | const

virtual

Definition at line 1037 of file timsdata.cpp.

{
std::vector<double> timeline;
timeline.reserve(m_mapFramesRecord.size());
for(const TimsFrameRecord &frame_record : m_mapFramesRecord)
{
if(frame_record.mz_calibration_id != 0)
{
timeline.push_back(frame_record.frame_time);
}
}
return timeline;
}

References m_mapFramesRecord.

Referenced by getRetentionTimeLine().

## getScanByGlobalScanIndex()

TimsDataFastMap & pappso::TimsData::getScanByGlobalScanIndex | ( | std::size_t | index | ) |

Definition at line 1059 of file timsdata.cpp.

{
qDebug() << " spectrum_index=" << index;
auto coordinate = getScanCoordinatesByGlobalScanIndex(index);
TimsFrameBaseCstSPtr tims_frame;
tims_frame = getTimsFrameCstSPtrCached(coordinate.first);
TimsDataFastMap &raw_spectrum = TimsDataFastMap::getTimsDataFastMapInstance();
raw_spectrum.clear();
tims_frame.get()->combineScansInTofIndexIntensityMap(
raw_spectrum, coordinate.second, coordinate.second);
return raw_spectrum;
}
pappso::TimsDataFastMap::getTimsDataFastMapInstance
static TimsDataFastMap & getTimsDataFastMapInstance()
Definition timsdatafastmap.cpp:41

References pappso::TimsDataFastMap::clear(), getScanCoordinatesByGlobalScanIndex(), pappso::TimsDataFastMap::getTimsDataFastMapInstance(), and getTimsFrameCstSPtrCached().

Referenced by getRawMsBySpectrumIndex().

## getScanCoordinateFromRawIndex()

std::pair< std::size_t, std::size_t > pappso::TimsData::getScanCoordinateFromRawIndex | ( | std::size_t | spectrum_index | ) | const

private

Definition at line 333 of file timsdata.cpp.

{
return getScanCoordinatesByGlobalScanIndex(raw_index);
}

References getScanCoordinatesByGlobalScanIndex().

## getScanCoordinatesByGlobalScanIndex()

std::pair< std::size_t, std::size_t > pappso::TimsData::getScanCoordinatesByGlobalScanIndex | ( | std::size_t | index | ) | const

private

Definition at line 339 of file timsdata.cpp.

{
std::size_t fast_access = raw_index / 1000;
qDebug() << " fast_access=" << fast_access;
auto map_it = m_thousandIndexToFrameIdDescrListIndex.find(fast_access);
if(map_it == m_thousandIndexToFrameIdDescrListIndex.end())
{
throw ExceptionNotFound(
QObject::tr("ERROR raw index %1 not found (fast_access)")
.arg(raw_index));
}
std::size_t start_point_index = map_it->second;
while((start_point_index > 0) &&
(m_frameIdDescrList[start_point_index].m_globalScanIndex > raw_index))
{
start_point_index--;
}
for(std::size_t i = start_point_index; i < m_frameIdDescrList.size(); i++)
{
if(raw_index < (m_frameIdDescrList[i].m_globalScanIndex +
m_frameIdDescrList[i].m_scanCount))
{
return std::pair<std::size_t, std::size_t>(
m_frameIdDescrList[i].m_frameId,
raw_index - m_frameIdDescrList[i].m_globalScanIndex);
}
}
throw ExceptionNotFound(
QObject::tr("ERROR raw index %1 not found").arg(raw_index));
}

References m_frameIdDescrList, and m_thousandIndexToFrameIdDescrListIndex.

Referenced by getMassSpectrumCstSPtrByGlobalScanIndex(), pappso::TimsDdaPrecursors::getMatchPrecursorIdByKo(), getMsLevelByGlobalScanIndex(), getQualifiedMassSpectrumByGlobalScanIndex(), getScanByGlobalScanIndex(), and getScanCoordinateFromRawIndex().

## getTicChromatogram()

Trace pappso::TimsData::getTicChromatogram | ( |  | ) | const

Definition at line 848 of file timsdata.cpp.

{
// In the Frames table, each frame has a record describing the
// SummedIntensities for all the mobility spectra.
MapTrace rt_tic_map_trace;
using Pair = std::pair<double, double>;
using Map = std::map<double, double>;
using Iterator = Map::iterator;
QSqlDatabase qdb = openDatabaseConnection();
QSqlQuery q =
qdb.exec(QString("SELECT Time, SummedIntensities "
"FROM Frames WHERE MsMsType = 0 "
"ORDER BY Time;"));
if(q.lastError().isValid())
{
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, database name %2, "
"executing SQL "
"command %3:\n%4\n%5\n%6")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(qdb.databaseName())
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
while(q.next())
{
bool ok = false;
int cumulated_results = 2;
double rt = q.value(0).toDouble(&ok);
cumulated_results -= ok;
double sumY = q.value(1).toDouble(&ok);
cumulated_results -= ok;
if(cumulated_results)
{
throw PappsoException(
QObject::tr(
"ERROR in TIMS sqlite database file: could not read either the "
"retention time or the summed intensities (%1, database name "
"%2, "
"executing SQL "
"command %3:\n%4\n%5\n%6")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(qdb.databaseName())
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
// Try to insert value sumY at key rt.
std::pair<Iterator, bool> res = rt_tic_map_trace.insert(Pair(rt, sumY));
if(!res.second)
{
// One other same rt value was seen already (like in ion mobility
// mass spectrometry, for example). Only increment the y value.
res.first->second += sumY;
}
}
// qDebug().noquote() << "The TIC chromatogram:\n"
//<< rt_tic_map_trace.toTrace().toString();
return rt_tic_map_trace.toTrace();
}
pappso::PrecisionUnit::res
@ res
pappso::DataKind::rt
@ rt
Retention time.

References m_timsDataDirectory, openDatabaseConnection(), pappso::res, pappso::rt, and pappso::MapTrace::toTrace().

## getTimsBinDecPtr()

TimsBinDec * pappso::TimsData::getTimsBinDecPtr | ( |  | ) | const

protected

Definition at line 1102 of file timsdata.cpp.

{
return mpa_timsBinDec;
}

References mpa_timsBinDec.

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

## getTimsDataDirectory()

const QDir & pappso::TimsData::getTimsDataDirectory | ( |  | ) | const

Definition at line 1086 of file timsdata.cpp.

{
return m_timsDataDirectory;
}

References m_timsDataDirectory.

Referenced by pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId(), pappso::TimsDdaPrecursors::getPrecursorsByMzRtCharge(), pappso::TimsDdaPrecursors::getSpectrumDescrWithPrecursorId(), pappso::TimsDdaPrecursors::getSpectrumDescrWithScanCoordinates(), pappso::TimsDdaPrecursors::ms2ReaderSpectrumCollectionByMsLevel(), and pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## getTimsDdaPrecursorsPtr()

TimsDdaPrecursors * pappso::TimsData::getTimsDdaPrecursorsPtr | ( |  | ) | const

Definition at line 1092 of file timsdata.cpp.

{
if(mpa_timsDdaPrecursors == nullptr)
{
throw pappso::PappsoException("TimsData does not contain DDA precursors");
}
return mpa_timsDdaPrecursors;
}
pappso::PappsoException
Definition pappsoexception.h:42

References mpa_timsDdaPrecursors.

## getTimsDiaSlicesPtr()

TimsDiaSlices * pappso::TimsData::getTimsDiaSlicesPtr | ( |  | ) | const

Definition at line 1124 of file timsdata.cpp.

{
qDebug();
if(mpa_timsDiaSlices == nullptr)
{
throw pappso::PappsoException("TimsData does not contain DIA slices");
}
return mpa_timsDiaSlices;
}

References mpa_timsDiaSlices.

## getTimsFrameBaseCstSPtr()

TimsFrameBaseCstSPtr pappso::TimsData::getTimsFrameBaseCstSPtr | ( | std::size_t | timsId | ) |

private

get a Tims frame base (no binary data file access) with his database ID

Definition at line 430 of file timsdata.cpp.

{
qDebug() << " timsId=" << timsId;
const TimsFrameRecord &frame_record = m_mapFramesRecord[timsId];
if(timsId > m_totalScanCount)
{
throw ExceptionNotFound(
QObject::tr("ERROR Frames database id %1 not found").arg(timsId));
}
TimsFrameBaseSPtr tims_frame;
tims_frame = std::make_shared<TimsFrameBase>(
TimsFrameBase(timsId, frame_record.tims_offset));
auto it_map_record =
m_mapMzCalibrationRecord.find(frame_record.mz_calibration_id);
if(it_map_record != m_mapMzCalibrationRecord.end())
{
double T1_frame = frame_record.frame_t1; // Frames.T1
double T2_frame = frame_record.frame_t2; // Frames.T2
tims_frame.get()->setMzCalibrationInterfaceSPtr(
mpa_mzCalibrationStore->getInstance(
T1_frame, T2_frame, it_map_record->second));
}
else
{
throw ExceptionNotFound(
QObject::tr("ERROR MzCalibration database id %1 not found")
.arg(frame_record.mz_calibration_id));
}
tims_frame.get()->setAcqDurationInMilliseconds(
frame_record.accumulation_time);
tims_frame.get()->setRtInSeconds(frame_record.frame_time);
tims_frame.get()->setMsMsType(frame_record.msms_type);
auto it_map_record_tims_calibration =
m_mapTimsCalibrationRecord.find(frame_record.tims_calibration_id);
if(it_map_record_tims_calibration != m_mapTimsCalibrationRecord.end())
{
tims_frame.get()->setTimsCalibration(
it_map_record_tims_calibration->second.value(1).toInt(),
it_map_record_tims_calibration->second.value(2).toDouble(),
it_map_record_tims_calibration->second.value(3).toDouble(),
it_map_record_tims_calibration->second.value(4).toDouble(),
it_map_record_tims_calibration->second.value(5).toDouble(),
it_map_record_tims_calibration->second.value(6).toDouble(),
it_map_record_tims_calibration->second.value(7).toDouble(),
it_map_record_tims_calibration->second.value(8).toDouble(),
it_map_record_tims_calibration->second.value(9).toDouble(),
it_map_record_tims_calibration->second.value(10).toDouble(),
it_map_record_tims_calibration->second.value(11).toDouble());
}
else
{
throw ExceptionNotFound(
QObject::tr("ERROR TimsCalibration database id %1 not found")
.arg(frame_record.tims_calibration_id));
}
return tims_frame;
}
pappso::MzCalibrationStore::getInstance
MzCalibrationInterfaceSPtr getInstance(double T1_frame, double T2_frame, const QSqlRecord &mzcalibration_record)
Definition mzcalibrationstore.cpp:46
pappso::TimsFrameBaseSPtr
std::shared_ptr< TimsFrameBase > TimsFrameBaseSPtr
Definition timsframebase.h:41

References pappso::TimsFrameRecord::accumulation_time, pappso::TimsFrameRecord::frame_t1, pappso::TimsFrameRecord::frame_t2, pappso::TimsFrameRecord::frame_time, pappso::MzCalibrationStore::getInstance(), m_mapFramesRecord, m_mapMzCalibrationRecord, m_mapTimsCalibrationRecord, m_totalScanCount, mpa_mzCalibrationStore, pappso::TimsFrameRecord::msms_type, pappso::TimsFrameRecord::mz_calibration_id, pappso::TimsFrameRecord::tims_calibration_id, and pappso::TimsFrameRecord::tims_offset.

Referenced by getTimsFrameBaseCstSPtrCached().

## getTimsFrameBaseCstSPtrCached()

TimsFrameBaseCstSPtr pappso::TimsData::getTimsFrameBaseCstSPtrCached | ( | std::size_t | timsId | ) |

private

Definition at line 932 of file timsdata.cpp.

{
QMutexLocker locker(&m_mutex);
for(auto &tims_frame : m_timsFrameBaseCache)
{
if(tims_frame.get()->getId() == timsId)
{
m_timsFrameBaseCache.push_back(tims_frame);
if(m_timsFrameBaseCache.size() > m_cacheSize)
m_timsFrameBaseCache.pop_front();
return tims_frame;
}
}
m_timsFrameBaseCache.push_back(getTimsFrameBaseCstSPtr(timsId));
if(m_timsFrameBaseCache.size() > m_cacheSize)
m_timsFrameBaseCache.pop_front();
return m_timsFrameBaseCache.back();
}
pappso::TimsData::m_cacheSize
std::size_t m_cacheSize
Definition timsdata.h:260
pappso::TimsData::m_mutex
QMutex m_mutex
Definition timsdata.h:288
pappso::TimsData::getTimsFrameBaseCstSPtr
TimsFrameBaseCstSPtr getTimsFrameBaseCstSPtr(std::size_t timsId)
get a Tims frame base (no binary data file access) with his database ID
Definition timsdata.cpp:430
pappso::TimsData::m_timsFrameBaseCache
std::deque< TimsFrameBaseCstSPtr > m_timsFrameBaseCache
Definition timsdata.h:262

References getTimsFrameBaseCstSPtr(), m_cacheSize, m_mutex, and m_timsFrameBaseCache.

Referenced by pappso::TimsDdaPrecursors::getMatchPrecursorIdByKo(), pappso::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), getQualifiedMassSpectrumByGlobalScanIndex(), pappso::TimsDdaPrecursors::getQualifiedMs1MassSpectrumBySpectrumDescr(), pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr(), and pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## getTimsFrameCstSPtr()

TimsFrameCstSPtr pappso::TimsData::getTimsFrameCstSPtr | ( | std::size_t | timsId | ) |

get a Tims frame with his database ID

this function is not thread safe

Definition at line 579 of file timsdata.cpp.

{
qDebug() << " timsId=" << timsId
<< " m_mapFramesRecord.size()=" << m_mapFramesRecord.size();
/*
for(auto pair_i : m_mapFramesRecord)
{
qDebug() << " pair_i=" << pair_i.first;
}
*/
const TimsFrameRecord &frame_record = m_mapFramesRecord[timsId];
if(timsId > m_totalScanCount)
{
throw ExceptionNotFound(
QObject::tr("ERROR Frames database id %1 not found").arg(timsId));
}
TimsFrameSPtr tims_frame;
// QMutexLocker lock(&m_mutex);
tims_frame =
mpa_timsBinDec->getTimsFrameSPtrByOffset(timsId, m_mapFramesRecord);
// lock.unlock();
qDebug();
auto it_map_record =
m_mapMzCalibrationRecord.find(frame_record.mz_calibration_id);
if(it_map_record != m_mapMzCalibrationRecord.end())
{
double T1_frame = frame_record.frame_t1; // Frames.T1
double T2_frame = frame_record.frame_t2; // Frames.T2
tims_frame.get()->setMzCalibrationInterfaceSPtr(
mpa_mzCalibrationStore->getInstance(
T1_frame, T2_frame, it_map_record->second));
}
else
{
throw ExceptionNotFound(
QObject::tr(
"ERROR MzCalibration database id %1 not found for frame_id=%2")
.arg(frame_record.mz_calibration_id)
.arg(timsId));
}
tims_frame.get()->setAcqDurationInMilliseconds(
frame_record.accumulation_time);
tims_frame.get()->setRtInSeconds(frame_record.frame_time);
tims_frame.get()->setMsMsType(frame_record.msms_type);
qDebug();
auto it_map_record_tims_calibration =
m_mapTimsCalibrationRecord.find(frame_record.tims_calibration_id);
if(it_map_record_tims_calibration != m_mapTimsCalibrationRecord.end())
{
tims_frame.get()->setTimsCalibration(
it_map_record_tims_calibration->second.value(1).toInt(),
it_map_record_tims_calibration->second.value(2).toDouble(),
it_map_record_tims_calibration->second.value(3).toDouble(),
it_map_record_tims_calibration->second.value(4).toDouble(),
it_map_record_tims_calibration->second.value(5).toDouble(),
it_map_record_tims_calibration->second.value(6).toDouble(),
it_map_record_tims_calibration->second.value(7).toDouble(),
it_map_record_tims_calibration->second.value(8).toDouble(),
it_map_record_tims_calibration->second.value(9).toDouble(),
it_map_record_tims_calibration->second.value(10).toDouble(),
it_map_record_tims_calibration->second.value(11).toDouble());
}
else
{
throw ExceptionNotFound(
QObject::tr("ERROR TimsCalibration database id %1 not found")
.arg(frame_record.tims_calibration_id));
}
qDebug();
return tims_frame;
}
pappso::TimsBinDec::getTimsFrameSPtrByOffset
TimsFrameSPtr getTimsFrameSPtrByOffset(std::size_t frameId, const std::vector< pappso::TimsFrameRecord > &frame_record_list)
Definition timsbindec.cpp:147

References pappso::TimsFrameRecord::accumulation_time, pappso::TimsFrameRecord::frame_t1, pappso::TimsFrameRecord::frame_t2, pappso::TimsFrameRecord::frame_time, pappso::MzCalibrationStore::getInstance(), pappso::TimsBinDec::getTimsFrameSPtrByOffset(), m_mapFramesRecord, m_mapMzCalibrationRecord, m_mapTimsCalibrationRecord, m_totalScanCount, mpa_mzCalibrationStore, mpa_timsBinDec, pappso::TimsFrameRecord::msms_type, pappso::TimsFrameRecord::mz_calibration_id, and pappso::TimsFrameRecord::tims_calibration_id.

Referenced by getTimsFrameCstSPtrCached().

## getTimsFrameCstSPtrCached()

TimsFrameCstSPtr pappso::TimsData::getTimsFrameCstSPtrCached | ( | std::size_t | timsId | ) |

get a Tims frame with his database ID but look in the cache first

thread safe

Definition at line 953 of file timsdata.cpp.

{
qDebug();
QMutexLocker locker(&m_mutex);
for(auto &tims_frame : m_timsFrameCache)
{
if(tims_frame.get()->getId() == timsId)
{
m_timsFrameCache.push_back(tims_frame);
if(m_timsFrameCache.size() > m_cacheSize)
m_timsFrameCache.pop_front();
return tims_frame;
}
}
TimsFrameCstSPtr frame_sptr = getTimsFrameCstSPtr(timsId);
// locker.relock();
qDebug();
m_timsFrameCache.push_back(frame_sptr);
if(m_timsFrameCache.size() > m_cacheSize)
m_timsFrameCache.pop_front();
qDebug();
return m_timsFrameCache.back();
/*
// the frame is not in the cache
if(std::find(m_someoneIsLoadingFrameId.begin(),
m_someoneIsLoadingFrameId.end(),
timsId) == m_someoneIsLoadingFrameId.end())
{
// not found, we are alone on this frame
m_someoneIsLoadingFrameId.push_back(timsId);
qDebug();
//locker.unlock();
TimsFrameCstSPtr frame_sptr = getTimsFrameCstSPtr(timsId);
// locker.relock();
qDebug();
m_someoneIsLoadingFrameId.erase(
std::find(m_someoneIsLoadingFrameId.begin(),
m_someoneIsLoadingFrameId.end(),
timsId));
m_timsFrameCache.push_back(frame_sptr);
if(m_timsFrameCache.size() > m_cacheSize)
m_timsFrameCache.pop_front();
qDebug();
return m_timsFrameCache.back();
}
else
{
// this frame is loading by someone else, we have to wait
qDebug();
// locker.unlock();
// std::size_t another_frame_id = timsId;
while(true)
{
QThread::usleep(1);
// locker.relock();
for(auto &tims_frame : m_timsFrameCache)
{
if(tims_frame.get()->getId() == timsId)
{
m_timsFrameCache.push_back(tims_frame);
return tims_frame;
}
}
// locker.unlock();
}
} // namespace pappso
*/
}
pappso::TimsData::getTimsFrameCstSPtr
TimsFrameCstSPtr getTimsFrameCstSPtr(std::size_t timsId)
get a Tims frame with his database ID
Definition timsdata.cpp:579
pappso::TimsData::m_timsFrameCache
std::deque< TimsFrameCstSPtr > m_timsFrameCache
Definition timsdata.h:261

References getTimsFrameCstSPtr(), m_cacheSize, m_mutex, and m_timsFrameCache.

Referenced by pappso::TimsDiaSlices::getCombinedMs2ScansByGlobalSliceIndex(), pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId(), getMassSpectrumCstSPtr(), pappso::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), getMsLevelByGlobalScanIndex(), getQualifiedMassSpectrumByGlobalScanIndex(), pappso::TimsDdaPrecursors::getQualifiedMs1MassSpectrumBySpectrumDescr(), pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr(), getScanByGlobalScanIndex(), and pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## getTimsFrameRecordList()

const std::vector< TimsFrameRecord > & pappso::TimsData::getTimsFrameRecordList | ( |  | ) | const

Definition at line 1080 of file timsdata.cpp.

{
return m_mapFramesRecord;
}

References m_mapFramesRecord.

## getTimsMS1FrameIdsInRtRange()

std::vector< std::size_t > pappso::TimsData::getTimsMS1FrameIdsInRtRange | ( | double | rt_begin,
|  | double | rt_end
| ) |  | const

Definition at line 504 of file timsdata.cpp.

{
qDebug() << " rt_begin=" << rt_begin << " rt_end=" << rt_end;
if(rt_begin < 0)
rt_begin = 0;
std::vector<std::size_t> tims_frameid_list;
QSqlDatabase qdb = openDatabaseConnection();
QSqlQuery q = qdb.exec(QString("SELECT Frames.Id FROM Frames WHERE "
"Frames.MsMsType=0 AND (Frames.Time>=%1) "
"AND (Frames.Time<=%2) ORDER BY "
"Frames.Time;")
.arg(rt_begin)
.arg(rt_end));
if(q.lastError().isValid())
{
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, database name %2, "
"executing SQL "
"command %3:\n%4\n%5\n%6")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(qdb.databaseName())
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
while(q.next())
{
tims_frameid_list.push_back(q.value(0).toULongLong());
}
return tims_frameid_list;
}

References m_timsDataDirectory, and openDatabaseConnection().

## getTimsMS2FrameIdsInRtRange()

std::vector< std::size_t > pappso::TimsData::getTimsMS2FrameIdsInRtRange | ( | double | rt_begin,
|  | double | rt_end
| ) |  | const

Definition at line 541 of file timsdata.cpp.

{
qDebug() << " rt_begin=" << rt_begin << " rt_end=" << rt_end;
if(rt_begin < 0)
rt_begin = 0;
std::vector<std::size_t> tims_frameid_list;
QSqlDatabase qdb = openDatabaseConnection();
QSqlQuery q =
qdb.exec(QString("SELECT Frames.Id FROM Frames WHERE "
"Frames.MsMsType=8 AND "
"(Frames.Time>=%1) AND (Frames.Time<=%2) ORDER BY "
"Frames.Time;")
.arg(rt_begin)
.arg(rt_end));
if(q.lastError().isValid())
{
throw PappsoException(
QObject::tr("ERROR in TIMS sqlite database file %1, database name %2, "
"executing SQL "
"command %3:\n%4\n%5\n%6")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(qdb.databaseName())
.arg(q.lastQuery())
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
while(q.next())
{
tims_frameid_list.push_back(q.value(0).toULongLong());
}
return tims_frameid_list;
}

References m_timsDataDirectory, and openDatabaseConnection().

## getTotalNumberOfFrames()

std::size_t pappso::TimsData::getTotalNumberOfFrames | ( |  | ) | const

Get total number of frames.

Definition at line 679 of file timsdata.cpp.

{
return m_frameCount;
}

References m_frameCount.

## getTotalNumberOfScans()

std::size_t pappso::TimsData::getTotalNumberOfScans | ( |  | ) | const

get the total number of scans

Definition at line 693 of file timsdata.cpp.

{
return m_totalScanCount;
}

References m_totalScanCount.

## getTotalScanCount()

std::size_t pappso::TimsData::getTotalScanCount | ( |  | ) | const

Definition at line 700 of file timsdata.cpp.

{
return m_totalScanCount;
}

References m_totalScanCount.

Referenced by pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## isDdaRun()

bool pappso::TimsData::isDdaRun | ( |  | ) | const

tells if this MS run is a DDA run

Returns
  true if it contains DDA precursors

Definition at line 1108 of file timsdata.cpp.

{
if(mpa_timsDdaPrecursors == nullptr)
return false;
return true;
}

References mpa_timsDdaPrecursors.

## isDiaRun()

bool pappso::TimsData::isDiaRun | ( |  | ) | const

tells if this MS run is a DIA run

Returns
  true if it contains DIA slices

Definition at line 1116 of file timsdata.cpp.

{
if(mpa_timsDiaSlices == nullptr)
return false;
return true;
}

## openDatabaseConnection()

QSqlDatabase pappso::TimsData::openDatabaseConnection | ( |  | ) | const

protected

Definition at line 231 of file timsdata.cpp.

{
QString database_connection_name = QString("%1_%2")
.arg(m_timsDataDirectory.absolutePath())
.arg((quintptr)QThread::currentThread());
// Open the database
QSqlDatabase qdb = QSqlDatabase::database(database_connection_name);
if(!qdb.isValid())
{
qDebug() << database_connection_name;
qdb = QSqlDatabase::addDatabase("QSQLITE", database_connection_name);
qdb.setDatabaseName(m_timsDataDirectory.absoluteFilePath("analysis.tdf"));
}
if(!qdb.open())
{
qDebug();
throw PappsoException(
QObject::tr("ERROR opening TIMS sqlite database file %1, database name "
"%2 :\n%3\n%4\n%5")
.arg(m_timsDataDirectory.absoluteFilePath("analysis.tdf"))
.arg(database_connection_name)
.arg(qdb.lastError().databaseText())
.arg(qdb.lastError().driverText())
.arg(qdb.lastError().nativeErrorCode()));
}
return qdb;
}

References m_timsDataDirectory.

Referenced by TimsData(), fillFrameIdDescrList(), pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId(), pappso::TimsDdaPrecursors::getPrecursorsByMzRtCharge(), pappso::TimsDdaPrecursors::getSpectrumDescrListByFrameId(), pappso::TimsDdaPrecursors::getSpectrumDescrWithPrecursorId(), pappso::TimsDdaPrecursors::getSpectrumDescrWithScanCoordinates(), getTicChromatogram(), getTimsMS1FrameIdsInRtRange(), getTimsMS2FrameIdsInRtRange(), pappso::TimsDdaPrecursors::getXicCoordTimsFromPrecursorId(), pappso::TimsDdaPrecursors::ms2ReaderSpectrumCollectionByMsLevel(), and pappso::TimsDdaPrecursors::rawReaderSpectrumCollectionByMsLevel().

## Member Data Documentation

## m_cacheSize

std::size_t pappso::TimsData::m_cacheSize = 60

private

Definition at line 260 of file timsdata.h.

Referenced by getTimsFrameBaseCstSPtrCached(), and getTimsFrameCstSPtrCached().

## m_frameCount

std::size_t pappso::TimsData::m_frameCount

private

Definition at line 259 of file timsdata.h.

Referenced by TimsData(), getFrameCount(), and getTotalNumberOfFrames().

## m_frameIdDescrList

std::vector<FrameIdDescr> pappso::TimsData::m_frameIdDescrList

private

store every frame id and corresponding sizes

Definition at line 274 of file timsdata.h.

Referenced by fillFrameIdDescrList(), getFrameIdDescrList(), getGlobalScanIndexByScanCoordinates(), and getScanCoordinatesByGlobalScanIndex().

## m_mapFramesRecord

std::vector<TimsFrameRecord> pappso::TimsData::m_mapFramesRecord

private

Definition at line 267 of file timsdata.h.

Referenced by TimsData(), getRetentionTimeLineInSeconds(), getTimsFrameBaseCstSPtr(), getTimsFrameCstSPtr(), and getTimsFrameRecordList().

## m_mapMzCalibrationRecord

std::map<int, QSqlRecord> pappso::TimsData::m_mapMzCalibrationRecord

private

Definition at line 265 of file timsdata.h.

Referenced by TimsData(), getTimsFrameBaseCstSPtr(), and getTimsFrameCstSPtr().

## m_mapTimsCalibrationRecord

std::map<int, QSqlRecord> pappso::TimsData::m_mapTimsCalibrationRecord

private

Definition at line 266 of file timsdata.h.

Referenced by TimsData(), getTimsFrameBaseCstSPtr(), and getTimsFrameCstSPtr().

## m_mutex

QMutex pappso::TimsData::m_mutex

private

Definition at line 288 of file timsdata.h.

Referenced by getTimsFrameBaseCstSPtrCached(), and getTimsFrameCstSPtrCached().

## m_someoneIsLoadingFrameId

std::vector<std::size_t> pappso::TimsData::m_someoneIsLoadingFrameId

private

tells if someone is loading a frame id

Definition at line 286 of file timsdata.h.

## m_thousandIndexToFrameIdDescrListIndex

std::map<std::size_t, std::size_t> pappso::TimsData::m_thousandIndexToFrameIdDescrListIndex

private

index to find quickly a frameId in the description list with the raw index of spectrum modulo 1000 @key thousands of TOF scans @value corresponding m_frameIdDescrList index

Definition at line 281 of file timsdata.h.

Referenced by fillFrameIdDescrList(), and getScanCoordinatesByGlobalScanIndex().

## m_timsDataDirectory

QDir pappso::TimsData::m_timsDataDirectory

private

Definition at line 252 of file timsdata.h.

Referenced by TimsData(), fillFrameIdDescrList(), pappso::TimsDdaPrecursors::getSpectrumDescrListByFrameId(), getTicChromatogram(), getTimsDataDirectory(), getTimsMS1FrameIdsInRtRange(), getTimsMS2FrameIdsInRtRange(), pappso::TimsDdaPrecursors::getXicCoordTimsFromPrecursorId(), and openDatabaseConnection().

## m_timsFrameBaseCache

std::deque<TimsFrameBaseCstSPtr> pappso::TimsData::m_timsFrameBaseCache

private

Definition at line 262 of file timsdata.h.

Referenced by getTimsFrameBaseCstSPtrCached().

## m_timsFrameCache

std::deque<TimsFrameCstSPtr> pappso::TimsData::m_timsFrameCache

private

Definition at line 261 of file timsdata.h.

Referenced by getTimsFrameCstSPtrCached().

## m_totalScanCount

std::size_t pappso::TimsData::m_totalScanCount

private

Definition at line 258 of file timsdata.h.

Referenced by TimsData(), getTimsFrameBaseCstSPtr(), getTimsFrameCstSPtr(), getTotalNumberOfScans(), and getTotalScanCount().

## mpa_mzCalibrationStore

MzCalibrationStore* pappso::TimsData::mpa_mzCalibrationStore

private

Definition at line 269 of file timsdata.h.

Referenced by TimsData(), ~TimsData(), getTimsFrameBaseCstSPtr(), and getTimsFrameCstSPtr().

## mpa_timsBinDec

TimsBinDec* pappso::TimsData::mpa_timsBinDec = nullptr

private

Definition at line 253 of file timsdata.h.

Referenced by TimsData(), ~TimsData(), getTimsBinDecPtr(), and getTimsFrameCstSPtr().

## mpa_timsDdaPrecursors

TimsDdaPrecursors* pappso::TimsData::mpa_timsDdaPrecursors = nullptr

private

Definition at line 255 of file timsdata.h.

Referenced by TimsData(), ~TimsData(), getQualifiedMassSpectrumByGlobalScanIndex(), getTimsDdaPrecursorsPtr(), and isDdaRun().

## mpa_timsDiaSlices

TimsDiaSlices* pappso::TimsData::mpa_timsDiaSlices = nullptr

private

Definition at line 256 of file timsdata.h.

Referenced by TimsData(), ~TimsData(), and getTimsDiaSlicesPtr().

## TimsDdaPrecursors

friend pappso::TimsData::TimsDdaPrecursors

private

Definition at line 71 of file timsdata.h.

Referenced by TimsData().

## TimsDiaSlices

friend pappso::TimsData::TimsDiaSlices

private

Definition at line 72 of file timsdata.h.

Referenced by TimsData().

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

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