MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / computeConsensus

Method computeConsensus

src/openms/source/KERNEL/ConsensusFeature.cpp:170–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168 }
169
170 void ConsensusFeature::computeConsensus()
171 {
172 // for computing average position and intensity
173 double rt = 0.0;
174 double mz = 0.0;
175 double intensity = 0.0;
176
177 // The most frequent charge state wins. Tie breaking prefers smaller charge.
178 std::map<Int, UInt> charge_occ;
179 Int charge_most_frequent = 0;
180 UInt charge_most_frequent_occ = 0;
181
182 for (ConsensusFeature::HandleSetType::const_iterator it = handles_.begin(); it != handles_.end(); ++it)
183 {
184 rt += it->getRT();
185 mz += it->getMZ();
186 intensity += it->getIntensity();
187 const Int it_charge = it->getCharge();
188 const UInt it_charge_occ = ++charge_occ[it_charge];
189 if (it_charge_occ > charge_most_frequent_occ)
190 {
191 charge_most_frequent_occ = it_charge_occ;
192 charge_most_frequent = it_charge;
193 }
194 else
195 {
196 if (it_charge_occ >= charge_most_frequent_occ && abs(it_charge) < abs(charge_most_frequent))
197 {
198 charge_most_frequent = it_charge;
199 }
200 }
201 }
202
203 // compute the average position and intensity
204 setRT(rt / size());
205 setMZ(mz / size());
206 setIntensity(intensity / size());
207 setCharge(charge_most_frequent);
208 return;
209 }
210
211 void ConsensusFeature::computeMonoisotopicConsensus()
212 {

Callers 8

testConsensusFeatureFunction · 0.95
main_Method · 0.80
runMethod · 0.80
addConsensusFeature_Method · 0.80
runMethod · 0.80

Calls 11

setChargeFunction · 0.85
setRTFunction · 0.50
sizeFunction · 0.50
setMZFunction · 0.50
setIntensityFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
getRTMethod · 0.45
getMZMethod · 0.45
getIntensityMethod · 0.45
getChargeMethod · 0.45

Tested by 1

testConsensusFeatureFunction · 0.76