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

replacement for std::map More...

`#include <timsdatafastmap.h>`

## Classes

struct | TimsDataFastMapElement

## Public Member Functions

std::size_t | accumulateIntensity (quint32 tofIndex, std::size_t intensity)
| accumulates intesity for the given tof index
std::size_t | readIntensity (quint32)
| reads intensity for a tof_index
void | downsizeMzRawMap (std::size_t mzindex_merge_window)
| downsize mz resolution to lower the number of real mz computations
void | builtInCentroid ()
| simple filter to agregate counts on neigbhor mobility slots (+1)
void | removeArtefactualSpike ()
const std::vector< quint32 > & | getTofIndexList () const
void | clear ()

## Static Public Member Functions

static TimsDataFastMap & | getTimsDataFastMapInstance ()

## Static Public Attributes

static std::map< QThread *, TimsDataFastMap > | m_preAllocatedFastMapPerThread = {}

## Private Member Functions

| TimsDataFastMap ()

## Private Attributes

std::vector< quint32 > | tofIndexList
std::vector< TimsDataFastMapElement > | mapTofIndexIntensity

## Detailed Description

replacement for std::map

Beware to use it carefully : clear the tofIndexList before using it

Definition at line 45 of file timsdatafastmap.h.

## Constructor & Destructor Documentation

## TimsDataFastMap()

pappso::TimsDataFastMap::TimsDataFastMap | ( |  | ) |

private

Definition at line 53 of file timsdatafastmap.cpp.

{
// map.resize(500000);
}

Referenced by getTimsDataFastMapInstance().

## Member Function Documentation

## accumulateIntensity()

std::size_t pappso::TimsDataFastMap::accumulateIntensity | ( | quint32 | tofIndex,
|  | std::size_t | intensity )

accumulates intesity for the given tof index

sets the count value on the first access ( first_access is true) and add the tof index to the tofIndexList then increments it if it is called on the same tof index

Definition at line 59 of file timsdatafastmap.cpp.

{
qDebug();
try
{
TimsDataFastMapElement &map_element = mapTofIndexIntensity.at(key);
if(map_element.first_access)
{
map_element.first_access = false;
map_element.count = intensity;
tofIndexList.push_back(key);
}
else
{
map_element.count += intensity;
}
qDebug();
return map_element.count;
}
catch(std::out_of_range &error)
{
throw pappso::ExceptionOutOfRange(
QObject::tr("out of range exception for tof index %1 ").arg(key));
}
}
pappso::TimsDataFastMap::tofIndexList
std::vector< quint32 > tofIndexList
Definition timsdatafastmap.h:104
pappso::TimsDataFastMap::mapTofIndexIntensity
std::vector< TimsDataFastMapElement > mapTofIndexIntensity
Definition timsdatafastmap.h:106
pappso::TimsDataFastMap::TimsDataFastMapElement
Definition timsdatafastmap.h:55

References pappso::TimsDataFastMap::TimsDataFastMapElement::count, pappso::TimsDataFastMap::TimsDataFastMapElement::first_access, mapTofIndexIntensity, and tofIndexList.

Referenced by builtInCentroid(), pappso::TimsFrame::cumulateScan(), pappso::TimsFrameType1::cumulateScan(), pappso::TimsFrame::cumulateScan2(), pappso::TimsFrameType1::cumulateScan2(), and downsizeMzRawMap().

## builtInCentroid()

void pappso::TimsDataFastMap::builtInCentroid | ( |  | ) |

simple filter to agregate counts on neigbhor mobility slots (+1)

the map is modified in place

Definition at line 117 of file timsdatafastmap.cpp.

{
qDebug() << "tofIndexList.size()=" << tofIndexList.size();
if(tofIndexList.size() > 2)
{
std::vector<quint32> tof_index_list_tmp = tofIndexList;
std::sort(tof_index_list_tmp.begin(), tof_index_list_tmp.end());
tofIndexList.clear();
quint32 previous_tof_index = tof_index_list_tmp[0];
std::size_t previous_intensity = readIntensity(previous_tof_index);
for(std::size_t i = 1; i < tof_index_list_tmp.size(); i++)
{
quint32 tof_index = tof_index_list_tmp[i];
if(previous_tof_index == tof_index - 1)
{
std::size_t intensity = readIntensity(tof_index);
if(previous_intensity > intensity)
{
// flush writing current accumulated intensity
accumulateIntensity(previous_tof_index, previous_intensity + intensity);
previous_intensity = 0;
previous_tof_index = tof_index;
}
else
{
// accumulate while intensity increases
previous_intensity += intensity;
previous_tof_index = tof_index;
}
}
else
{
// write accumulated intensity :
if(previous_intensity > 0)
{
// flush
accumulateIntensity(previous_tof_index, previous_intensity);
}
previous_tof_index = tof_index;
previous_intensity = readIntensity(tof_index);
}
}
// write remaining intensity :
if(previous_intensity > 0)
{
// flush
accumulateIntensity(previous_tof_index, previous_intensity);
}
}
qDebug() << "tofIndexList.size()=" << tofIndexList.size();
}
pappso::TimsDataFastMap::accumulateIntensity
std::size_t accumulateIntensity(quint32 tofIndex, std::size_t intensity)
accumulates intesity for the given tof index
Definition timsdatafastmap.cpp:59
pappso::TimsDataFastMap::readIntensity
std::size_t readIntensity(quint32)
reads intensity for a tof_index
Definition timsdatafastmap.cpp:87

References accumulateIntensity(), readIntensity(), and tofIndexList.

Referenced by pappso::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), and pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr().

## clear()

void pappso::TimsDataFastMap::clear | ( |  | ) |

Definition at line 202 of file timsdatafastmap.cpp.

{
tofIndexList.clear();
}

References tofIndexList.

Referenced by pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution(), pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2(), pappso::TimsFrame::cumulateScansToTrace(), pappso::TimsDiaSlices::getCombinedMs2ScansByGlobalSliceIndex(), pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId(), pappso::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr(), and pappso::TimsData::getScanByGlobalScanIndex().

## downsizeMzRawMap()

void pappso::TimsDataFastMap::downsizeMzRawMap | ( | std::size_t | mzindex_merge_window | ) |

downsize mz resolution to lower the number of real mz computations

the map is modified in place

Parameters

  mzindex_merge_window | width of the mzindex window used to merge all intensities into a single point. This results in faster computing.

Definition at line 96 of file timsdatafastmap.cpp.

{
std::vector<std::pair<quint32, std::size_t>> temp_vector;
for(quint32 tof_index : tofIndexList)
{
temp_vector.push_back({tof_index, readIntensity(tof_index)});
}
tofIndexList.clear();
for(auto &pair_tof_intensity : temp_vector)
{
quint32 mzkey = (pair_tof_intensity.first / mzindex_merge_window);
mzkey = (mzkey * mzindex_merge_window) + (mzindex_merge_window / 2);
accumulateIntensity(mzkey, pair_tof_intensity.second);
}
}

References accumulateIntensity(), readIntensity(), and tofIndexList.

Referenced by pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution(), and pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2().

## getTimsDataFastMapInstance()

pappso::TimsDataFastMap & pappso::TimsDataFastMap::getTimsDataFastMapInstance | ( |  | ) |

static

Definition at line 40 of file timsdatafastmap.cpp.

{
auto it = TimsDataFastMap::m_preAllocatedFastMapPerThread.insert(
{QThread::currentThread(), TimsDataFastMap()});
if(it.second)
{
it.first->second.mapTofIndexIntensity.resize(500000);
}
return it.first->second;
}
pappso::TimsDataFastMap::TimsDataFastMap
TimsDataFastMap()
Definition timsdatafastmap.cpp:53
pappso::TimsDataFastMap::m_preAllocatedFastMapPerThread
static std::map< QThread *, TimsDataFastMap > m_preAllocatedFastMapPerThread
Definition timsdatafastmap.h:48

References TimsDataFastMap(), and m_preAllocatedFastMapPerThread.

Referenced by pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution(), pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2(), pappso::TimsFrame::cumulateScansToTrace(), pappso::TimsFrameMobilityTraces::extractMobilityTraces(), pappso::TimsDiaSlices::getCombinedMs2ScansByGlobalSliceIndex(), pappso::TimsDdaPrecursors::getCombinedMs2ScansByPrecursorId(), pappso::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr(), and pappso::TimsData::getScanByGlobalScanIndex().

## getTofIndexList()

const std::vector< quint32 > & pappso::TimsDataFastMap::getTofIndexList | ( |  | ) | const

Definition at line 196 of file timsdatafastmap.cpp.

{
return tofIndexList;
}

References tofIndexList.

Referenced by pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution(), pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2(), pappso::TimsFrame::cumulateScansToTrace(), pappso::TimsFrameMobilityTraces::extractMobilityTraces(), and pappso::TimsFrameBase::getTraceFromTofIndexIntensityMap().

## readIntensity()

std::size_t pappso::TimsDataFastMap::readIntensity | ( | quint32 | key | ) |

reads intensity for a tof_index

reads the cumulated intensity for this tof index and replaces the first access boolean to true. => this is important to reuse the map in an other computation No need to erase the content or initialize it

Definition at line 87 of file timsdatafastmap.cpp.

{
TimsDataFastMapElement &map_element = mapTofIndexIntensity.at(key);
// FIXME: why set first_access to true below?
map_element.first_access = true;
return map_element.count;
}

References pappso::TimsDataFastMap::TimsDataFastMapElement::count, pappso::TimsDataFastMap::TimsDataFastMapElement::first_access, and mapTofIndexIntensity.

Referenced by builtInCentroid(), pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution(), pappso::TimsFrame::combineScansToTraceWithDowngradedMzResolution2(), pappso::TimsFrame::cumulateScansToTrace(), downsizeMzRawMap(), pappso::TimsFrameMobilityTraces::extractMobilityTraces(), and pappso::TimsFrameBase::getTraceFromTofIndexIntensityMap().

## removeArtefactualSpike()

void pappso::TimsDataFastMap::removeArtefactualSpike | ( |  | ) |

Definition at line 174 of file timsdatafastmap.cpp.

{
std::vector<quint32> tof_index_list_tmp = tofIndexList;
tofIndexList.clear();
for(quint32 tof_index : tof_index_list_tmp)
{
if((tof_index > 0) && mapTofIndexIntensity[tof_index - 1].first_access &&
mapTofIndexIntensity[tof_index + 1].first_access &&
(mapTofIndexIntensity[tof_index].count == 10))
{
// this measure is too small and alone : remove it
mapTofIndexIntensity[tof_index].first_access = true;
}
else
{
tofIndexList.push_back(tof_index);
}
}
}

References mapTofIndexIntensity, and tofIndexList.

## Member Data Documentation

## m_preAllocatedFastMapPerThread

std::map< QThread *, TimsDataFastMap > pappso::TimsDataFastMap::m_preAllocatedFastMapPerThread = {}

static

Definition at line 48 of file timsdatafastmap.h.

Referenced by getTimsDataFastMapInstance().

## mapTofIndexIntensity

std::vector<TimsDataFastMapElement> pappso::TimsDataFastMap::mapTofIndexIntensity

private

Definition at line 106 of file timsdatafastmap.h.

Referenced by accumulateIntensity(), readIntensity(), and removeArtefactualSpike().

## tofIndexList

std::vector<quint32> pappso::TimsDataFastMap::tofIndexList

private

Definition at line 104 of file timsdatafastmap.h.

Referenced by accumulateIntensity(), builtInCentroid(), clear(), downsizeMzRawMap(), getTofIndexList(), and removeArtefactualSpike().

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

- pappsomspp/core/vendors/tims/timsdatafastmap.h
- pappsomspp/core/vendors/tims/timsdatafastmap.cpp