52 windowsize_ = (double)param_.getValue(
"windowsize");
53 peakcount_ = (
UInt)param_.getValue(
"peakcount");
61 std::set<double> positions;
62 for (ConstIterator it = old_spectrum.begin(); it != old_spectrum.end(); ++it)
66 for (ConstIterator it2 = it; (it2->getPosition() - it->getPosition() < windowsize_); )
68 window.push_back(*it2);
69 if (++it2 == old_spectrum.end())
78 for (
Size i = 0; i < peakcount_; ++i)
80 if (i < window.size())
82 positions.insert(window[i].getMZ());
90 std::vector<Size> indices;
91 for (ConstIterator it = spectrum.begin(); it != spectrum.end(); ++it)
93 if (positions.find(it->getMZ()) != positions.end())
95 Size index(it - spectrum.begin());
96 indices.push_back(index);
110 if (spectrum.empty())
117 windowsize_ =
static_cast<double>(param_.getValue(
"windowsize"));
118 peakcount_ =
static_cast<UInt>(param_.getValue(
"peakcount"));
125 double window_start = spectrum[0].getMZ();
126 for (
Size i = 0; i != spectrum.size(); ++i)
128 if (spectrum[i].getMZ() - window_start < windowsize_)
130 peaks_in_window.push_back(spectrum[i]);
134 window_start = spectrum[i].getMZ();
137 if (peaks_in_window.size() > peakcount_)
139 std::partial_sort(peaks_in_window.begin(), peaks_in_window.begin() + peakcount_, peaks_in_window.end(), [](
auto &left,
auto &right) {typename SpectrumType::PeakType::IntensityLess cmp; return cmp(right, left);});
140 copy(peaks_in_window.begin(), peaks_in_window.begin() + peakcount_, back_inserter(out));
144 std::sort(peaks_in_window.begin(), peaks_in_window.end(), [](
auto &left,
auto &right) {typename SpectrumType::PeakType::IntensityLess cmp; return cmp(right, left);});
145 copy(peaks_in_window.begin(), peaks_in_window.end(), back_inserter(out));
148 peaks_in_window.
clear(
false);
149 peaks_in_window.push_back(spectrum[i]);
153 if (!peaks_in_window.empty())
159 double last_window_size = peaks_in_window.back().getMZ() - window_start;
160 double last_window_size_fraction = last_window_size / windowsize_;
161 Size last_window_peakcount =
static_cast<Size>(std::round(last_window_size_fraction * peakcount_));
163 if (peaks_in_window.size() > last_window_peakcount)
165 std::partial_sort(peaks_in_window.begin(), peaks_in_window.begin() + last_window_peakcount, peaks_in_window.end(),
166 [](
auto &left,
auto &right) {typename SpectrumType::PeakType::IntensityLess cmp; return cmp(right, left);});
167 std::copy(peaks_in_window.begin(), peaks_in_window.begin() + last_window_peakcount, back_inserter(out));
171 std::copy(peaks_in_window.begin(), peaks_in_window.end(), std::back_inserter(out));
176 std::vector<Size> indices;
179 if (std::find(out.begin(), out.end(), *it) != out.end())
181 Size index(it - spectrum.begin());
182 indices.push_back(index);