libpappsomspp
Library for mass spectrometry
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 TimsDataFastMapgetTimsDataFastMapInstance ()
 

Static Public Attributes

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

Private Member Functions

 TimsDataFastMap ()
 

Private Attributes

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

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

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

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

61{
62 qDebug();
63 try
64 {
65 TimsDataFastMapElement &map_element = mapTofIndexIntensity.at(key);
66
67 if(map_element.first_access)
68 {
69 map_element.first_access = false;
70 map_element.count = intensity;
71 tofIndexList.push_back(key);
72 }
73 else
74 {
75 map_element.count += intensity;
76 }
77 qDebug();
78 return map_element.count;
79 }
80 catch(std::out_of_range &error)
81 {
83 QObject::tr("out of range exception for tof index %1 ").arg(key));
84 }
85}
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 118 of file timsdatafastmap.cpp.

119{
120 qDebug() << "tofIndexList.size()=" << tofIndexList.size();
121 if(tofIndexList.size() > 2)
122 {
123 std::vector<quint32> tof_index_list_tmp = tofIndexList;
124 std::sort(tof_index_list_tmp.begin(), tof_index_list_tmp.end());
125
126 tofIndexList.clear();
127
128 quint32 previous_tof_index = tof_index_list_tmp[0];
129 std::size_t previous_intensity = readIntensity(previous_tof_index);
130 for(std::size_t i = 1; i < tof_index_list_tmp.size(); i++)
131 {
132 quint32 tof_index = tof_index_list_tmp[i];
133 if(previous_tof_index == tof_index - 1)
134 {
135 std::size_t intensity = readIntensity(tof_index);
136 if(previous_intensity > intensity)
137 {
138 // flush writing current accumulated intensity
139 accumulateIntensity(previous_tof_index,
140 previous_intensity + intensity);
141 previous_intensity = 0;
142 previous_tof_index = tof_index;
143 }
144 else
145 {
146 // accumulate while intensity increases
147 previous_intensity += intensity;
148 previous_tof_index = tof_index;
149 }
150 }
151 else
152 {
153 // write accumulated intensity :
154 if(previous_intensity > 0)
155 {
156 // flush
157 accumulateIntensity(previous_tof_index, previous_intensity);
158 }
159 previous_tof_index = tof_index;
160 previous_intensity = readIntensity(tof_index);
161 }
162 }
163
164 // write remaining intensity :
165 if(previous_intensity > 0)
166 {
167 // flush
168 accumulateIntensity(previous_tof_index, previous_intensity);
169 }
170 }
171
172 qDebug() << "tofIndexList.size()=" << tofIndexList.size();
173}
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::TimsDiaSlices::getMs1QualifiedSpectrumByGlobalSliceIndex(), pappso::TimsDiaSlices::getMs2QualifiedSpectrumByGlobalSliceIndex(), and pappso::TimsDdaPrecursors::getQualifiedMs2MassSpectrumBySpectrumDescr().

◆ clear()

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

98{
99 std::vector<std::pair<quint32, std::size_t>> temp_vector;
100 for(quint32 tof_index : tofIndexList)
101 {
102 temp_vector.push_back({tof_index, readIntensity(tof_index)});
103 }
104
105 tofIndexList.clear();
106
107 for(auto &pair_tof_intensity : temp_vector)
108 {
109
110 quint32 mzkey = (pair_tof_intensity.first / mzindex_merge_window);
111 mzkey = (mzkey * mzindex_merge_window) + (mzindex_merge_window / 2);
112
113 accumulateIntensity(mzkey, pair_tof_intensity.second);
114 }
115}

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

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

◆ getTimsDataFastMapInstance()

◆ getTofIndexList()

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

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

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

177{
178
179 std::vector<quint32> tof_index_list_tmp = tofIndexList;
180 tofIndexList.clear();
181 for(quint32 tof_index : tof_index_list_tmp)
182 {
183 if((tof_index > 0) && mapTofIndexIntensity[tof_index - 1].first_access &&
184 mapTofIndexIntensity[tof_index + 1].first_access &&
185 (mapTofIndexIntensity[tof_index].count == 10))
186 {
187 // this measure is too small and alone : remove it
188 mapTofIndexIntensity[tof_index].first_access = true;
189 }
190 else
191 {
192 tofIndexList.push_back(tof_index);
193 }
194 }
195}

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

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