| 11 | namespace OpenMS |
| 12 | { |
| 13 | void MapConversion::convert(UInt64 const input_map_index, |
| 14 | PeakMap& input_map, |
| 15 | ConsensusMap& output_map, |
| 16 | Size n) |
| 17 | { |
| 18 | output_map.clear(true); |
| 19 | |
| 20 | // see @todo above |
| 21 | output_map.setUniqueId(); |
| 22 | |
| 23 | input_map.updateRanges(1); |
| 24 | if (n > input_map.getSize()) |
| 25 | { |
| 26 | n = input_map.getSize(); |
| 27 | } |
| 28 | output_map.reserve(n); |
| 29 | std::vector<Peak2D> tmp; |
| 30 | tmp.reserve(input_map.getSize()); |
| 31 | |
| 32 | // TODO Avoid tripling the memory consumption by this call |
| 33 | input_map.get2DData(tmp); |
| 34 | |
| 35 | std::partial_sort(tmp.begin(), |
| 36 | tmp.begin() + n, |
| 37 | tmp.end(), |
| 38 | [](auto &left, auto &right) {Peak2D::IntensityLess cmp; return cmp(right, left);}); |
| 39 | |
| 40 | for (Size element_index = 0; element_index < n; ++element_index) |
| 41 | { |
| 42 | output_map.push_back(ConsensusFeature(input_map_index, |
| 43 | tmp[element_index], |
| 44 | element_index)); |
| 45 | } |
| 46 | |
| 47 | output_map.getColumnHeaders()[input_map_index].size = n; |
| 48 | output_map.updateRanges(); |
| 49 | } |
| 50 | |
| 51 | void MapConversion::convert(ConsensusMap const& input_map, |
| 52 | const bool keep_uids, |