libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::TimsDataFastMap Struct Reference

replacement for std::map More...

#include <timsdatafastmap.h>

Classes

struct  TimsDataFastMapElement
 

Public Member Functions

 TimsDataFastMap ()
 
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 ()
 

Static Public Member Functions

static TimsDataFastMapgetTimsDataFastMapInstance ()
 

Public Attributes

std::vector< quint32 > tofIndexList
 
std::vector< TimsDataFastMapElementmapTofIndexIntensity
 

Static Public Attributes

static std::map< QThread *, TimsDataFastMapm_preAllocatedFastaMapPerThread = {}
 

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 ( )

Definition at line 53 of file timsdatafastmap.cpp.

54{
55 // map.resize(500000);
56}

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.

60{
61 TimsDataFastMapElement &map_element = mapTofIndexIntensity.at(key);
62 if(map_element.first_access)
63 {
64 map_element.first_access = false;
65 map_element.count = intensity;
66 tofIndexList.push_back(key);
67 }
68 else
69 {
70 map_element.count += intensity;
71 }
72 return map_element.count;
73}
std::vector< quint32 > tofIndexList
std::vector< TimsDataFastMapElement > mapTofIndexIntensity

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 105 of file timsdatafastmap.cpp.

106{
107 qDebug() << "tofIndexList.size()=" << tofIndexList.size();
108 if(tofIndexList.size() > 2)
109 {
110 std::vector<quint32> tof_index_list_tmp = tofIndexList;
111 std::sort(tof_index_list_tmp.begin(), tof_index_list_tmp.end());
112
113 tofIndexList.clear();
114
115 quint32 previous_tof_index = tof_index_list_tmp[0];
116 std::size_t previous_intensity = readIntensity(previous_tof_index);
117 for(std::size_t i = 1; i < tof_index_list_tmp.size(); i++)
118 {
119 quint32 tof_index = tof_index_list_tmp[i];
120 if(previous_tof_index == tof_index - 1)
121 {
122 std::size_t intensity = readIntensity(tof_index);
123 if(previous_intensity > intensity)
124 {
125 // flush writing current accumulated intensity
126 accumulateIntensity(previous_tof_index,
127 previous_intensity + intensity);
128 previous_intensity = 0;
129 previous_tof_index = tof_index;
130 }
131 else
132 {
133 // accumulate while intensity increases
134 previous_intensity += intensity;
135 previous_tof_index = tof_index;
136 }
137 }
138 else
139 {
140 // write accumulated intensity :
141 if(previous_intensity > 0)
142 {
143 // flush
144 accumulateIntensity(previous_tof_index, previous_intensity);
145 }
146 previous_tof_index = tof_index;
147 previous_intensity = readIntensity(tof_index);
148 }
149 }
150
151 // write remaining intensity :
152 if(previous_intensity > 0)
153 {
154 // flush
155 accumulateIntensity(previous_tof_index, previous_intensity);
156 }
157 }
158
159 qDebug() << "tofIndexList.size()=" << tofIndexList.size();
160}
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

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

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

◆ 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_windowwidth of the mzindex window used to merge all intensities into a single point. This results in faster computing.

Definition at line 84 of file timsdatafastmap.cpp.

85{
86 std::vector<std::pair<quint32, std::size_t>> temp_vector;
87 for(quint32 tof_index : tofIndexList)
88 {
89 temp_vector.push_back({tof_index, readIntensity(tof_index)});
90 }
91
92 tofIndexList.clear();
93
94 for(auto &pair_tof_intensity : temp_vector)
95 {
96
97 quint32 mzkey = (pair_tof_intensity.first / mzindex_merge_window);
98 mzkey = (mzkey * mzindex_merge_window) + (mzindex_merge_window / 2);
99
100 accumulateIntensity(mzkey, pair_tof_intensity.second);
101 }
102}

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

Referenced by pappso::TimsFrame::cumulateScansToTraceMzDownResolution(), and pappso::TimsFrame::cumulateScansToTraceMzDownResolution2().

◆ getTimsDataFastMapInstance()

pappso::TimsDataFastMap & pappso::TimsDataFastMap::getTimsDataFastMapInstance ( )
static

◆ 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 76 of file timsdatafastmap.cpp.

77{
78 TimsDataFastMapElement &map_element = mapTofIndexIntensity.at(key);
79 map_element.first_access = true;
80 return map_element.count;
81}

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

Referenced by builtInCentroid(), pappso::TimsFrame::cumulateScansToTrace(), pappso::TimsFrame::cumulateScansToTraceMzDownResolution(), pappso::TimsFrame::cumulateScansToTraceMzDownResolution2(), downsizeMzRawMap(), and pappso::TimsFrameBase::getTraceFromCumulatedScans().

◆ removeArtefactualSpike()

void pappso::TimsDataFastMap::removeArtefactualSpike ( )

Definition at line 163 of file timsdatafastmap.cpp.

164{
165
166 std::vector<quint32> tof_index_list_tmp = tofIndexList;
167 tofIndexList.clear();
168 for(quint32 tof_index : tof_index_list_tmp)
169 {
170 if((tof_index > 0) && mapTofIndexIntensity[tof_index - 1].first_access &&
171 mapTofIndexIntensity[tof_index + 1].first_access &&
172 (mapTofIndexIntensity[tof_index].count == 10))
173 {
174 // this measure is too small and alone : remove it
175 mapTofIndexIntensity[tof_index].first_access = true;
176 }
177 else
178 {
179 tofIndexList.push_back(tof_index);
180 }
181 }
182}

References mapTofIndexIntensity, and tofIndexList.

Member Data Documentation

◆ m_preAllocatedFastaMapPerThread

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

Definition at line 48 of file timsdatafastmap.h.

Referenced by getTimsDataFastMapInstance().

◆ mapTofIndexIntensity

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

◆ tofIndexList


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