Repository navigation
[FIX] MSChromatogram/Mobilogram: keep binary data arrays in sync with the peaks on sort and clear - #9795
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMSChromatogram and Mobilogram sorting now stably reorder peaks with parallel data arrays. Clearing removes associated arrays, selection validates inputs before mutation, and filtering uses index-based selection. Tests cover synchronization, metadata preservation, duplicates, clearing, and precondition exceptions. ChangesPeak and parallel-data consistency
Sequence Diagram(s)sequenceDiagram
participant PeakPickerMobilogram
participant Mobilogram
participant PeakDataArrays
PeakPickerMobilogram->>Mobilogram: select(keep_indices)
Mobilogram->>PeakDataArrays: validate sizes and select matching entries
PeakDataArrays-->>Mobilogram: synchronized filtered arrays
Mobilogram-->>PeakPickerMobilogram: filtered mobilogram
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/openms/include/OpenMS/KERNEL/MSChromatogram.h (1)
221-233: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueBoth new inline
sort()templates callstd::stable_sortwhile only<numeric>was added. The shared root cause is that the sorting logic moved into the headers, but the<algorithm>include stayed in the.cppfiles, leaving header consumers dependent on transitive includes.
src/openms/include/OpenMS/KERNEL/MSChromatogram.h#L221-L233: add#include <algorithm>alongside<numeric>at the top of the header.src/openms/include/OpenMS/KERNEL/Mobilogram.h#L367-L379: add#include <algorithm>alongside<numeric>at the top of the header.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/KERNEL/MSChromatogram.h` around lines 221 - 233, Both inline sort templates use std::stable_sort without directly including its declaration. Add the <algorithm> header alongside <numeric> in src/openms/include/OpenMS/KERNEL/MSChromatogram.h (anchor, lines 221-233) and src/openms/include/OpenMS/KERNEL/Mobilogram.h (sibling, lines 367-379); no changes to the sort implementations are needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/include/OpenMS/KERNEL/Mobilogram.h`:
- Around line 580-589: The pyOpenMS test suite lacks coverage for the Mobilogram
bindings’ generic sort() and select() methods. Add tests for both APIs that
construct mobilograms with associated data arrays, invoke sorting and
selecting/reordering, and assert the peaks and data-array values remain
correctly reordered and aligned; follow the existing Mobilogram.addon test
patterns.
In `@src/openms/source/KERNEL/Mobilogram.cpp`:
- Around line 483-484: Update the Mobilogram::select() path so cached ranges are
refreshed when the selected peak count differs from the original count; invoke
the existing updateRanges() mechanism after shrinking the mobilogram, while
preserving the current return behavior.
- Around line 404-437: In Mobilogram::select, validate every non-empty
float_data_arrays_ lane against data_.size() before moving or swapping any data,
so a mismatch leaves the mobilogram unchanged; then remove the now-redundant
checks from the permutation loop. Apply the same validation-before-mutation
ordering in MSChromatogram::select, preserving existing exception behavior and
selection logic.
In `@src/tests/class_tests/openms/source/MSChromatogram_test.cpp`:
- Around line 353-411: Expand the sortByPosition and sortByIntensity tests
around the existing make fixture with tied RT and intensity values, then assert
the complete resulting order of peaks plus corresponding string and integer data
arrays for ascending and reverse sorts. Ensure the fixtures also verify stable
ordering among equal keys, including all positions rather than only endpoints.
---
Nitpick comments:
In `@src/openms/include/OpenMS/KERNEL/MSChromatogram.h`:
- Around line 221-233: Both inline sort templates use std::stable_sort without
directly including its declaration. Add the <algorithm> header alongside
<numeric> in src/openms/include/OpenMS/KERNEL/MSChromatogram.h (anchor, lines
221-233) and src/openms/include/OpenMS/KERNEL/Mobilogram.h (sibling, lines
367-379); no changes to the sort implementations are needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ef63f4d-28cc-4f92-a96b-ca41ae8f46eb
📒 Files selected for processing (7)
CHANGELOGsrc/openms/include/OpenMS/KERNEL/MSChromatogram.hsrc/openms/include/OpenMS/KERNEL/Mobilogram.hsrc/openms/source/KERNEL/MSChromatogram.cppsrc/openms/source/KERNEL/Mobilogram.cppsrc/tests/class_tests/openms/source/MSChromatogram_test.cppsrc/tests/class_tests/openms/source/Mobilogram_test.cpp
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/KERNEL/MSChromatogram.cpp (1)
359-369: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winApply the required C++ brace and indentation style.
src/openms/source/KERNEL/MSChromatogram.cpp#L359-L369: put the validation-lambda body braces on separate aligned lines.src/openms/source/KERNEL/Mobilogram.cpp#L117-L160: format the newly added sort-lambda bodies with aligned standalone braces.src/openms/source/KERNEL/Mobilogram.cpp#L420-L430: format the validation-lambda body with aligned standalone braces.src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp#L267-L289: use 2-space indentation and standalone braces for the new loops.As per coding guidelines: “format C++ with 2-space indentation … and braces on their own aligned lines.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/KERNEL/MSChromatogram.cpp` around lines 359 - 369, Apply the required C++ formatting: in src/openms/source/KERNEL/MSChromatogram.cpp lines 359-369, place the validation lambda body braces on separate aligned lines; in src/openms/source/KERNEL/Mobilogram.cpp lines 117-160, format the new sort-lambda bodies with standalone aligned braces; in src/openms/source/KERNEL/Mobilogram.cpp lines 420-430, format the validation lambda similarly; and in src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp lines 267-289, use 2-space indentation and standalone aligned braces for the new loops.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/openms/source/KERNEL/MSChromatogram.cpp`:
- Around line 359-369: Apply the required C++ formatting: in
src/openms/source/KERNEL/MSChromatogram.cpp lines 359-369, place the validation
lambda body braces on separate aligned lines; in
src/openms/source/KERNEL/Mobilogram.cpp lines 117-160, format the new
sort-lambda bodies with standalone aligned braces; in
src/openms/source/KERNEL/Mobilogram.cpp lines 420-430, format the validation
lambda similarly; and in
src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp lines 267-289, use
2-space indentation and standalone aligned braces for the new loops.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cc91d97b-7b44-4221-b45c-989f75f020d5
📒 Files selected for processing (10)
CHANGELOGsrc/openms/include/OpenMS/KERNEL/MSChromatogram.hsrc/openms/include/OpenMS/KERNEL/Mobilogram.hsrc/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cppsrc/openms/source/FORMAT/DATAACCESS/MSDataCachedConsumer.cppsrc/openms/source/KERNEL/MSChromatogram.cppsrc/openms/source/KERNEL/Mobilogram.cppsrc/openms_gui/source/VISUAL/VISITORS/LayerStoreData.cppsrc/tests/class_tests/openms/source/MSChromatogram_test.cppsrc/tests/class_tests/openms/source/Mobilogram_test.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
- src/openms/include/OpenMS/KERNEL/MSChromatogram.h
- src/tests/class_tests/openms/source/MSChromatogram_test.cpp
- src/openms/include/OpenMS/KERNEL/Mobilogram.h
- src/tests/class_tests/openms/source/Mobilogram_test.cpp
f6202a5 to
d3a3c32
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp (1)
271-273: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the repository’s required brace placement.
Place the
forbraces on their own aligned lines.As per coding guidelines, “braces on their own aligned lines; always use braces for blocks.”
Also applies to: 281-289
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp` around lines 271 - 273, Update the loops around the visible for statement, including the additionally referenced loop, to place opening and closing braces on their own aligned lines while preserving the existing loop bodies and mandatory-braces style.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms_gui/source/VISUAL/VISITORS/LayerStoreData.cpp`:
- Around line 92-93: Update the filtering logic around the LayerStoreData
operation that assigns out = in and calls out.select(keep) to invoke
out.updateRanges() afterward, ensuring cached RT/intensity bounds reflect only
retained peaks. Add a regression test assertion verifying the filtered
chromatogram ranges are recomputed correctly.
In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp`:
- Around line 269-274: Validate left_index and right_index for each target
mobilogram before the keep.reserve and loop in the mobilogram selection logic,
including the corresponding block around the second range. Reject or skip ranges
where right_index is SIZE_MAX, either bound is outside the mobilogram, or
right_index is less than left_index, preventing size underflow and
non-terminating iteration before calling mobilogram.select(keep).
---
Nitpick comments:
In `@src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp`:
- Around line 271-273: Update the loops around the visible for statement,
including the additionally referenced loop, to place opening and closing braces
on their own aligned lines while preserving the existing loop bodies and
mandatory-braces style.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 760c8c3f-6a37-474f-899d-f1e7032890b7
📒 Files selected for processing (10)
CHANGELOGsrc/openms/include/OpenMS/KERNEL/MSChromatogram.hsrc/openms/include/OpenMS/KERNEL/Mobilogram.hsrc/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cppsrc/openms/source/FORMAT/DATAACCESS/MSDataCachedConsumer.cppsrc/openms/source/KERNEL/MSChromatogram.cppsrc/openms/source/KERNEL/Mobilogram.cppsrc/openms_gui/source/VISUAL/VISITORS/LayerStoreData.cppsrc/tests/class_tests/openms/source/MSChromatogram_test.cppsrc/tests/class_tests/openms/source/Mobilogram_test.cpp
🚧 Files skipped from review as they are similar to previous changes (8)
- src/openms/source/FORMAT/DATAACCESS/MSDataCachedConsumer.cpp
- src/openms/include/OpenMS/KERNEL/MSChromatogram.h
- src/tests/class_tests/openms/source/Mobilogram_test.cpp
- src/openms/include/OpenMS/KERNEL/Mobilogram.h
- CHANGELOG
- src/tests/class_tests/openms/source/MSChromatogram_test.cpp
- src/openms/source/KERNEL/Mobilogram.cpp
- src/openms/source/KERNEL/MSChromatogram.cpp
Both classes carry float/string/integer data arrays that are parallel to
the peaks, but neither kept them in sync when the peaks were permuted or
dropped.
MSChromatogram::sortByPosition() guarded its metadata-ignoring fast path
on float_data_arrays_.empty() alone, ignoring string and integer arrays.
MSChromatogram::sortByIntensity() guarded on an inverted condition:
float_data_arrays_.empty() && !string_data_arrays_.empty() && !integer_data_arrays_.empty()
i.e. it took the fast path precisely when string and integer arrays were
present, and the slow path when no metadata existed at all.
The sortByPosition() case is reachable on the mzML load path: MzMLHandler
populates chromatogram integer/string binary data arrays and then calls
sortByPosition() when 'sort_chromatograms_by_rt' is set, so a chromatogram
with integer/string arrays but no float array had its peaks reordered while
the arrays stayed in file order -- and the mismatch was written back out on
store.
Mobilogram::sortByIntensity()/sortByPosition() were a bare stable_sort over
the peaks and never touched any array family. No in-tree caller sorts a
Mobilogram, but both sorts and all three array accessors are exposed via
pyOpenMS, whose docstring already promised the arrays would follow.
Both classes now permute peaks and all three array families together,
reusing the select()-based approach MSSpectrum already uses. MSChromatogram
already had select() -- the sorts simply never called it. Mobilogram gains
the select() and sort(Predicate) members it was missing; its class test
already contained a placeholder section for the latter, now a real test.
Also fixes clear(): Mobilogram::clear() and MSChromatogram::clear(false)
retained the data arrays while dropping the peaks, leaving the container
internally inconsistent. Both now clear the arrays and ranges, matching
MSSpectrum::clear(); for MSChromatogram the 'clear_meta_data' flag now
governs only ChromatogramSettings and the name. This also removes a latent
accumulation bug in PeakPickerMobilogram, which does clear() -> resize() ->
push_back and would have appended to stale entries on reuse of its output.
Behaviour changes: MSChromatogram sorting is now stable (std::sort ->
std::stable_sort), and a data array whose size does not match the peak
count now throws Exception::Precondition instead of silently corrupting
the association.
Verified by rebuilding with only the buggy logic restored: 18 assertions
fail in MSChromatogram_test and 19 in Mobilogram_test, all passing with
the fix.
Part of #9792
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01APConSDbHrNux6qmuP4oVh
…allers Review follow-ups on the data-array sync fix. Headers: the new sort(Predicate) template calls std::stable_sort but the headers only included <numeric>, relying transitively on another header for <algorithm>. Both now include it directly. select() validated data array sizes only after it had already permuted the peaks, so the advertised Exception::Precondition left the container half-permuted. Both MSChromatogram::select() and Mobilogram::select() now validate every index and every non-empty data array size up front, so a rejected call leaves the container exactly as it was. Out-of-range indices are rejected as well; MSChromatogram::select previously documented that "indices are NOT checked for validity", which the rewritten sorts now rely on. Also switched the string arrays from std::move to copy: duplicate indices previously yielded an empty string for the second occurrence, because the source entry had already been moved from. Three callers rebuilt a container with clear() + push_back and so relied on the data arrays surviving clear(): - PeakPickerMobilogram::filterPeakIntensities_ (both overloads) and the GUI helper filterChrom now use select() instead, which subsets the arrays alongside the peaks. Previously the arrays survived but with a stale size; after the clear() change they would have been dropped. select() is correct under either semantics. - MSDataCachedConsumer's comment claimed string arrays were preserved by its destructive clear. That was already untrue for spectra -- MSSpectrum::clear has always cleared all three families -- so the stale comment is corrected rather than the behaviour. Documented that select() does not recompute cached ranges: a permutation preserves them, but selecting a subset can leave them too wide. Also corrected an overstated claim in the CHANGELOG: a sort that short-circuits because the peaks are already in order does not inspect the data arrays, so a size mismatch is only rejected when the sort actually permutes. New tests: duplicate indices, out-of-range indices, container state after a rejected call, and reverse intensity sort with float arrays present. Part of #9792 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01APConSDbHrNux6qmuP4oVh
d3a3c32 to
09e9693
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/include/OpenMS/KERNEL/MSChromatogram.h`:
- Around line 230-233: Update the sorting method around the indices/lambda
stable_sort to validate all parallel-array sizes before invoking the user
predicate. Extract select()’s existing size validation into a shared helper,
call it before std::stable_sort, and add a regression test covering malformed
arrays with a lambda sort that must raise Exception::Precondition.
- Around line 222-228: Update the public MSChromatogram::sort template
documentation from the current `///` block to a `/** */` Doxygen block with a
required `@brief`. Add `@tparam` documentation for Predicate and `@param`
documentation for lambda, including that it may raise `Exception::Precondition`,
while preserving the existing sorting and data-array behavior details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a176bfc0-96b0-46fd-95cd-147c0a3027d2
📒 Files selected for processing (10)
CHANGELOGsrc/openms/include/OpenMS/KERNEL/MSChromatogram.hsrc/openms/include/OpenMS/KERNEL/Mobilogram.hsrc/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cppsrc/openms/source/FORMAT/DATAACCESS/MSDataCachedConsumer.cppsrc/openms/source/KERNEL/MSChromatogram.cppsrc/openms/source/KERNEL/Mobilogram.cppsrc/openms_gui/source/VISUAL/VISITORS/LayerStoreData.cppsrc/tests/class_tests/openms/source/MSChromatogram_test.cppsrc/tests/class_tests/openms/source/Mobilogram_test.cpp
🚧 Files skipped from review as they are similar to previous changes (7)
- src/openms/source/FORMAT/DATAACCESS/MSDataCachedConsumer.cpp
- CHANGELOG
- src/openms/source/ANALYSIS/OPENSWATH/PeakPickerMobilogram.cpp
- src/openms/source/KERNEL/Mobilogram.cpp
- src/openms/include/OpenMS/KERNEL/Mobilogram.h
- src/tests/class_tests/openms/source/MSChromatogram_test.cpp
- src/openms/source/KERNEL/MSChromatogram.cpp
- sort(Predicate): validate data-array sizes up front via a new shared checkDataArraySizes_() helper, so a mis-sized array throws Exception::Precondition *before* the user predicate can index it out of bounds. select() now reuses the same helper and drops its now-redundant per-lane size checks. (MSChromatogram, Mobilogram) - sort() docs: converted from /// to Doxygen /** */ with @brief/@tparam/@param/@exception. - PeakPickerMobilogram::filterPeakIntensities_ (both overloads): reject empty/inverted/out-of-range [left,right] before building the keep list. An empty mobilogram made findHighestPeak_ return right_index == SIZE_MAX (size()-1 underflow), which underflowed the reserve and spun the fill loop. - LayerStoreData::filterChrom: call updateRanges() after select() so a filtered chromatogram's cached RT/intensity bounds reflect only the retained peaks. - Tests: tied-key stable-order fixtures for MSChromatogram and Mobilogram (assert full peak + string + integer array order for ascending and descending sorts, from a start order that defeats every sort short-circuit) plus a direct sort(lambda) malformed-array precondition test. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01NBHPFbi3DC2mFxeRK6VXXU
…795-review-vaqdlr # Conflicts: # CHANGELOG
…ers, filter-skip logging
- MSChromatogram::sortByIntensity(): add the already-sorted std::is_sorted
short-circuit that sortByPosition() and Mobilogram::sortByIntensity() already
have. All four sort entry points now skip the permutation (and thus the
data-array validation) when the peaks are already ordered, which also makes the
CHANGELOG's "a short-circuiting sort does not inspect the arrays" statement
accurate for this method.
- MSDataCachedConsumer: drop the now-redundant setFloatDataArrays({}) /
setIntegerDataArrays({}) calls after clear(false), which already drops all
parallel arrays -- clear() is the single source of truth. The postconditions
still assert the invariant.
- PeakPickerMobilogram::filterPeakIntensities_ (both overloads): log at DEBUG when
the bounds guard skips filtering (the caller otherwise gets the unfiltered
mobilogram back with no indication), and build the keep list with std::iota.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NBHPFbi3DC2mFxeRK6VXXU
…rings (#9812) * docs(pyOpenMS): fix stale/missing MSChromatogram and Mobilogram docstrings MSChromatogram.findNearest() carried a copy-pasted sortByPosition() docstring instead of describing its own binary-search-nearest-RT behavior. MSChromatogram.clear()/sortByIntensity() and Mobilogram.sortByPosition()/sortByIntensity() had no docstring at all, and Mobilogram.clear() still said "Clear all peaks" even though #9795 made it also clear the parallel data arrays. Bring all of these in line with the corresponding Doxygen comments in MSChromatogram.h / Mobilogram.h. * fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 4 unresolved review comments. Co-authored-by: CodeRabbit <[email protected]> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <[email protected]>
…feature (#9881) The 3.6 section had grown to 217 KB (22x the 3.5 section), mostly because recent entries were appended verbatim as PR-body-style root-cause writeups, with newest entries prepended to "General:" regardless of topic. Collapse incremental/superseded PR chains into one entry per feature: - QPX Parquet export: ~30 entries across #9692-#9878 (long-format conversion, run_file_name resolution, validation, transactional writes, streaming/parallel build) reduced to a 6-item block. The export is new in 3.6, so the intermediate fixes never shipped to users. - ProteinQuantifier/PeptideAndProteinQuant: the per-assay grain change, fractions:aggregate, best_charge rename, the same undetected-peptide aggregation defect fixed at three levels, and the perf work bundled. - pyOpenMS nanobind lifetime/use-after-free work (#9792, #9794, #9795). - ProSE: 30 entries down to 17, grouped by search modes, calibration, FDR, Percolator and FragmentIndex. - Bruker TimsTOF, IMAGING, ThermoRawFile and the native Parquet formats each get one nested block instead of scattered entries. - ~20 near-identical per-tool ".idparquet/.featureparquet support" and "Thermo .raw input" entries folded into "TOPP tools > all:". Remove exact duplicates (ProteinQuantifier -ratios removal, Annotation1DItem DLLAPI, ConsensusMapArrowExport streaming, macOS pkg notarization, Qt removal steps duplicated between General/Dependencies/Build System, IsoelectricPoint and IMAGING multi-region duplicated between General and OpenMS Library). File misplaced entries into the sections they belong to and add a GUI tools section, matching the structure used by 3.5 and earlier releases. Net: 217 KB -> 82 KB with all 440 distinct PR references preserved; the five dropped refs are CI-internal test guards and a historical bug reference. Claude-Session: https://claude.ai/code/session_01DWGycgSTyEwPbaBgffw8LJ Co-authored-by: Claude <[email protected]>
Fixes the correctness bugs recorded as Part V of #9792, in the core library rather than in the bindings.
The bugs
1.
MSChromatogram::sortByPosition()— fast path guarded on float arrays aloneA chromatogram with string or integer data arrays but no float array had its peaks reordered while the arrays stayed put.
This is reachable on the mzML load path.
MzMLHandlerpopulates chromatogram integer and string binary data arrays (MzMLHandler.cpp:603-683) and then callssortByPosition()whensort_chromatograms_by_rtis set (:221-223). The mis-associated arrays are then written back out on store (:5712-5725), so the corruption round-trips to disk.2.
MSChromatogram::sortByIntensity()— inverted guardif (float_data_arrays_.empty() && !string_data_arrays_.empty() && !integer_data_arrays_.empty())The two
!are inverted. This takes the metadata-ignoring fast path precisely when string and integer arrays exist, and takes the slow path when no metadata exists at all (merely wasteful).3.
Mobilogram::sortByIntensity()/sortByPosition()— arrays never touchedBoth were a bare
stable_sortover the peaks; none of the three array families were permuted. No in-tree caller sorts aMobilogram, so this is latent in C++ — but both sorts and all three array accessors are exposed via pyOpenMS, and the binding docstring already promised "Meta data arrays will be sorted accordingly".4.
Mobilogram::clear()andMSChromatogram::clear(false)— arrays survive the peaksBoth dropped the peaks while retaining the parallel data arrays, leaving the container internally inconsistent.
MSSpectrum::clear()already clears them unconditionally, using its flag only forshrink_to_fitand descriptive settings; the two siblings disagreed with it and with each other.This also removes a latent accumulation bug in
PeakPickerMobilogram, which doesclear()→resize()→push_back(:85,:122,:136-140) and would have appended to stale entries on any reuse of the outputMobilogram.The fix
Reuse the approach
MSSpectrumalready uses rather than inventing one: aselect(indices)that permutes peaks and all three array families with size validation, plus asort(Predicate)helper that isiota+stable_sort+select.MSChromatogramalready hadselect()— the sorts simply never called it. Added thesort(Predicate)helper and rewrote both sorts as all-three-empty →stable_sort, elsesort(cmp). This deletes ~80 lines of hand-rolled permutation, which is where both guard bugs lived.Mobilogramhad neither, soselect()andsort(Predicate)were added. Its class test already contained a placeholderSTART_SECTION(template<class Predicate> void sort(const Predicate& lambda))markedNOT_TESTABLE, which is now a real test.clear()variants now clear the arrays and ranges, matchingMSSpectrum::clear().Behavior changes
std::sort→std::stable_sort), matchingMSSpectrum. Deterministic tie order.Exception::Preconditioninstead of silently corrupting the association — for a sort that actually permutes. A sort that short-circuits because the peaks are already in order does not inspect the arrays, so it still passes silently.MSChromatogram::clear(false)now clears data arrays and ranges;clear_meta_datagoverns onlyChromatogramSettingsand the name.Mobilogram::clear()now clears the data arrays.Verification
I rebuilt with only the buggy logic restored (keeping the new members so the tests still compile) and ran the new tests against it:
MSChromatogram_testMobilogram_testThe failure values show the defect directly — e.g. after
sortByPosition()on peaks in RT order 3,1,2:The peaks sorted; the metadata stayed in its original order.
New coverage: per-class sections asserting that
sortByPosition,sortByIntensityandsortByIntensity(reverse=true)permute peaks and every array family, that array names survive, that a size mismatch throws, and thatclear()empties the arrays; plus real tests forMobilogram::select()andMobilogram::sort(Predicate).Review follow-ups
A review pass over this branch turned up several further issues, all fixed here:
MSChromatogram.h/Mobilogram.husedstd::stable_sortin the newsort(Predicate)template but only included<numeric>, relying transitively on another header for<algorithm>. Both now include it directly.select()validated array sizes after it had already permuted the peaks, so the advertised exception left the object half-permuted. Both classes now validate all indices and all array sizes up front, so a rejected call leaves the container untouched. Out-of-range indices are now rejected too, rather than being undefined behaviour (MSChromatogram::selectpreviously documented "indices are NOT checked for validity").select()moved out ofstd::stringentries, so duplicate indices produced empty strings for the second occurrence. String arrays are now copied.clear()leaving the data arrays behind.PeakPickerMobilogram::filterPeakIntensities_(both overloads) and the GUI'sfilterChromrebuilt a container withclear()+push_back, which previously left the arrays present but mis-sized and would now drop them; both now useselect(), which is correct in either case.MSDataCachedConsumer's comment claimed string arrays were preserved — that was already untrue for spectra (MSSpectrum::clearhas always cleared all three families), so the comment is corrected rather than the behaviour.select()does not recompute cached ranges. A permutation preserves them; a subset can leave them too wide. Now documented on both declarations.Scope
Core-library fix only. The pyOpenMS ownership/lifetime design questions stay in #9792; the iterator use-after-free was fixed separately in #9794.
🤖 Generated with Claude Code
https://claude.ai/code/session_01APConSDbHrNux6qmuP4oVh
Summary by CodeRabbit
clear()behavior so it consistently removes peaks and their associated parallel data (and metadata when requested).sortand index-basedselectfor both chromatograms and mobilograms.