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

Function calculateSNmedian

src/openms/source/FORMAT/QcMLFile.cpp:991–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989 }
990
991 float calculateSNmedian(const MSSpectrum& spec, bool norm = true)
992 {
993 if (spec.empty())
994 {
995 return 0;
996 }
997 vector<UInt> intensities;
998 for (auto& pt : spec)
999 {
1000 intensities.push_back(pt.getIntensity());
1001 }
1002 float median = Math::median(intensities.begin(), intensities.end());
1003
1004 float maxi = spec.back().getIntensity();
1005 if (!norm)
1006 {
1007 float sn_by_max2median = maxi / median;
1008 return sn_by_max2median;
1009 }
1010
1011 float sign_int= 0;
1012 float nois_int = 0;
1013 size_t sign_cnt= 0;
1014 size_t nois_cnt = 0;
1015 for (const Peak1D& pt : spec)
1016 {
1017 if (pt.getIntensity() <= median)
1018 {
1019 ++nois_cnt;
1020 nois_int += pt.getIntensity();
1021 }
1022 else
1023 {
1024 ++sign_cnt;
1025 sign_int += pt.getIntensity();
1026 }
1027 }
1028 if (sign_cnt == 0 || nois_cnt == 0 || nois_int <= 0)
1029 {
1030 return 0;
1031 }
1032 return (sign_int / sign_cnt) / (nois_int / nois_cnt);
1033 }
1034
1035 void QcMLFile::collectQCData(vector<ProteinIdentification>& prot_ids,
1036 vector<PeptideIdentification>& pep_ids,

Callers 1

collectQCDataMethod · 0.85

Calls 7

medianFunction · 0.85
backMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45
getIntensityMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected