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

Method clusterSIPPeptides

src/topp/MetaProSIP.cpp:321–358  ·  view source on GitHub ↗

@Note sip peptides get reordered in same order as clusters

Source from the content-addressed store, hash-verified

319
320 //@Note sip peptides get reordered in same order as clusters
321 static vector<vector<SIPPeptide> > clusterSIPPeptides(const vector<double>& centers, vector<SIPPeptide>& sip_peptides)
322 {
323 // one cluster for each cluster center
324 vector<vector<SIPPeptide> > clusters(centers.size(), vector<SIPPeptide>());
325
326 // assign sip peptide to cluster center with largest RIA
327 for (vector<SIPPeptide>::const_iterator sit = sip_peptides.begin(); sit != sip_peptides.end(); ++sit)
328 {
329 const vector<SIPIncorporation>& incs = sit->incorporations;
330 if (!incs.empty())
331 {
332 double largest_ria = incs[incs.size() - 1].rate;
333 Size closest_cluster_idx = 0;
334 double closest_cluster_dist = std::numeric_limits<double>::max();
335 for (Size i = 0; i != centers.size(); ++i)
336 {
337 double dist = std::fabs(centers[i] - largest_ria);
338 if (dist < closest_cluster_dist)
339 {
340 closest_cluster_dist = dist;
341 closest_cluster_idx = i;
342 }
343 }
344
345 // add SIP peptide to closest cluster
346 clusters[closest_cluster_idx].push_back(*sit);
347 }
348 }
349
350 // rearrange SIP peptides to reflect new order
351 sip_peptides.clear();
352 for (vector<vector<SIPPeptide> >::const_iterator sit = clusters.begin(); sit != clusters.end(); ++sit)
353 {
354 sip_peptides.insert(sip_peptides.end(), sit->begin(), sit->end());
355 }
356
357 return clusters;
358 }
359
360};
361

Callers

nothing calls this directly

Calls 7

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected