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

Method findNearest

src/openms/source/KERNEL/Mobilogram.cpp:86–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 Size Mobilogram::findNearest(CoordinateType mb) const
87 {
88 // no peak => no search
89 if (empty())
90 {
91 throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "There must be at least one peak to determine the nearest peak!");
92 }
93 // search for position for inserting
94 ConstIterator it = MBBegin(mb);
95 // border cases
96 if (it == cbegin())
97 {
98 return 0;
99 }
100 if (it == cend())
101 {
102 return size() - 1;
103 }
104 // the peak before or the current peak are closest
105 auto it2 = it;
106 --it2;
107 if (std::fabs(it->getMobility() - mb) < std::fabs(it2->getMobility() - mb))
108 {
109 return Size(it - cbegin());
110 }
111 else
112 {
113 return Size(it2 - cbegin());
114 }
115 }
116
117 Int Mobilogram::findNearest(CoordinateType mb, CoordinateType tolerance) const
118 {

Calls 6

emptyFunction · 0.50
cbeginFunction · 0.50
cendFunction · 0.50
sizeFunction · 0.50
operator[]Method · 0.45
sizeMethod · 0.45

Tested by 2

computeHyperScore_Method · 0.36
addIonMatchStatisticsMethod · 0.36