Skip to content

[FIX] IDFilter typed peptide-score filter, MorphologicalFilter thread safety, random-scan noise sampling - #9616

Merged
timosachsenberg merged 13 commits into
OpenMS:developfrom
timosachsenberg:fix/9488-processing-filter-contracts
Oct 16, 2026
Merged

timosachsenberg merged 13 commits into
OpenMS:developfrom
timosachsenberg:fix/9488-processing-filter-contracts

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes in processing code. All are still present on develop.

IDFilter: typed peptide-score filter

IDFilter -score:peptide X -score:type_peptide T passed the protein identifications to IDFilter::filterHitsByScore(), so the PSMs were not filtered. It now filters the peptide identifications. TOPP_IDFilter_25 runs the typed filter (PEP) on ConsensusID_1_input.idXML and compares it with the main-score filter (-score:psm).

filterHitsByScore() with a score type is documented as removing the hits of an identification that has the score neither as its main score nor as a secondary score, but it kept them. It now removes them, as documented, and warns only when that happens. Otherwise a missing score type would let every hit through the fixed filter. Behaviour change for its callers:

  • IDFilter -score:type_peptide and -score:type_protein.
  • PercolatorAdapter -score:fdr (applyPostFilters_(), q-value). Its results do not change, because both Percolator backends write the q-value (MS:1001491) on every hit.

MorphologicalFilter: scratch buffers shared between threads

filterRange(), applyErosion_() and applyDilation_() kept their scratch buffers in function-local static vectors. MapAlignerPoseClustering aligns maps in an OpenMP loop, and its superimposer applies a tophat filter to its histograms. With three or more input maps, the threads therefore wrote to the same vector. The buffers are static thread_local now. A test runs two filter instances concurrently against serial reference results.

estimateNoiseFromRandomScans(): sampling by the wrong index

The function selects the non-empty spectra of the requested MS level, then indexed the experiment with the position in that selection. It therefore read spectra of other MS levels, or an empty spectrum (tmp[idx] on an empty vector). It now samples through the selection, over all of its entries; n_scans == 0 returns 0, and the percentile is clamped to [0, 100]. Its caller is TOPPView's intensity cutoff when a file is opened.

Dropped from the original version

develop is merged in, and the tracker references are gone from the comments.

🤖 Generated with Claude Code

https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL

…p FAIMS-merge meta, IDFilter score-type removal, Morph reentrancy (OpenMS#9488 PROC-15/16/23/31/32/33)

Part of OpenMS#9488 (POLS high-severity checklist — **FEATUREFINDER / PROCESSING**).

### [PROC-15] `NLargest::filterSpectrum` / [PROC-16] `RankScaler::filterSpectrum` — left spectrum intensity-sorted
Both filters reorder peaks by intensity internally and returned the spectrum still in that order, violating the usual m/z-sorted post-condition.

**Fix:** `spectrum.sortByPosition()` at the end of each, restoring m/z order.

### [PROC-23] `SignalToNoiseEstimator::estimateNoiseFromRandomScans` — sampled by raw index
The random-scan picker indexed `exp[]` directly with a random draw instead of via the filtered scan-index list, so it could sample wrong-MS-level / empty spectra and overrun `exp`.

**Fix:** index through the filtered `spec_indices` list; cast the draw to `Size`; clamp the percentile index.

### [PROC-31] `FeatureOverlapFilter::mergeFAIMSFeatures` — wiped IDs/meta
`feature_map.clear()` wiped protein/peptide IDs, data processing and meta info.

**Fix:** `feature_map.clear(false)` — preserves IDs/meta while clearing features.

### [PROC-32] `IDFilter::filterHitsByScore` (ScoreType overload) — silent keep vs documented removal ⚠️ behavior change
The doc and warning said hits are removed when the requested `score_type` is absent, but they were silently **kept**.

**Fix:** when the score type is present as neither main nor secondary score, clear that identification's hits (matching the long-standing `@note`) and warn precisely. **This is a behavior change** (silent-keep → remove); a `TOPP_IDFilter` reference that relied on keep-all would change, which is correct rather than something to whitelist.

### [PROC-33] `MorphologicalFilter` — non-reentrant function-local statics
`filterRange`/`applyErosion_`/`applyDilation_` used `static` scratch buffers, making `filter()`/`filterExperiment()` non-reentrant / not thread-safe.

**Fix:** drop `static` (each call gets its own buffer; semantically identical, now reentrant per instance).

**ABI:** all none, except PROC-33 source-compatible (storage duration of locals).
**Tests:** m/z-sorted output (NLargest/RankScaler); correct MS-level sampling (SNE); IDs/meta survive the FAIMS merge; hits removed when score type missing (IDFilter); two-thread reentrancy (MorphologicalFilter).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

This PR updates OpenMS processing components to use thread-local filtering storage, preserve ascending m/z ordering, handle missing identification score types, retain FeatureMap metadata during FAIMS merging, and safely process random-scan noise estimation edge cases.

Changes: MorphologicalFilter Reentrancy Fix

Layer / File(s) Summary
Thread-local filtering buffers
src/openms/include/OpenMS/PROCESSING/BASELINE/MorphologicalFilter.h
Uses thread-local scratch buffers and documents the instance-sharing constraint.
Concurrent filter validation
src/tests/class_tests/openms/source/MorphologicalFilter_test.cpp
Adds concurrent filtering coverage using separate filter instances and serial expected results.

Restore m/z Order After Peak Filtering

Layer / File(s) Summary
NLargest sorts retained peaks
src/openms/include/OpenMS/PROCESSING/FILTERING/NLargest.h, src/tests/class_tests/openms/source/NLargest_test.cpp
Sorts retained peaks by position after intensity selection and verifies ascending m/z output.
RankScaler order preservation
src/openms/include/OpenMS/PROCESSING/SCALING/RankScaler.h, src/tests/class_tests/openms/source/RankScaler_test.cpp, src/pyOpenMS/tests/unittests/test_SpectraFilter.py
Documents position restoration and tests m/z ordering across C++ and Python interfaces.

IDFilter Score-Type Hit Removal

Layer / File(s) Summary
Handle missing score types and peptide filtering
src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h, src/topp/IDFilter.cpp, src/tests/class_tests/openms/source/IDFilter_test.cpp, src/tests/topp/CMakeLists.txt
Clears hits when the requested score type is absent, applies peptide filtering to peptide hits, updates warning behavior, and adds regression coverage.

FeatureOverlapFilter Metadata Preservation

Layer / File(s) Summary
Preserve metadata during merge
src/openms/source/PROCESSING/FEATURE/FeatureOverlapFilter.cpp, src/tests/class_tests/openms/source/FeatureOverlapFilter_test.cpp
Uses clear(false) during FAIMS recombination and tests preservation of attached FeatureMap metadata.

SignalToNoiseEstimator Random Scan Sampling Fix

Layer / File(s) Summary
Fix scan sampling and percentile bounds
src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.cpp, src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.h, src/tests/class_tests/openms/source/SignalToNoiseEstimator_test.cpp
Samples eligible spectra correctly, handles empty cases, bounds percentile selection, documents behavior, and adds edge-case tests.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies three substantive fixes in the pull request: typed peptide-score filtering, MorphologicalFilter thread safety, and random-scan noise sampling. It is concise and specific, …
Full details: Title check

Explanation

The title clearly identifies three substantive fixes in the pull request: typed peptide-score filtering, MorphologicalFilter thread safety, and random-scan noise sampling. It is concise and specific, although it does not list every change, which is acceptable for a pull request title.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

A rabbit found buffers bright,
Each thread got one for quiet flight.
Peaks hop back in m/z row,
Missing scores make hits go.
Metadata stays, noise is sound—
Fresh fixes burrow underground! 🐇

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Adversarial review result: no blocking behavioral issue found in this pass.

Required source cleanup before merge: many added implementation, Doxygen, and test comments include tracker references. Please remove those from the source and keep the comments phrased as durable behavior/contracts. I did not run the tests locally.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (1)
src/openms/include/OpenMS/PROCESSING/BASELINE/MorphologicalFilter.h (1)

174-175: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider thread_local to retain allocation reuse.

Making the buffer a plain local restores correctness but reintroduces per-call heap allocation/resizing in a hot-path filtering routine (van Herk erosion/dilation is called per spectrum/window). A thread_local static buffer would preserve amortized reuse within a thread while still satisfying the "no cross-thread sharing" contract documented at lines 128-131.

Also applies to: 334-335, 445-446

🤖 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/PROCESSING/BASELINE/MorphologicalFilter.h` around
lines 174 - 175, The scratch buffer in MorphologicalFilter’s hot-path routines
is now a plain local, which fixes reentrancy but loses allocation reuse; update
the buffer handling in MorphologicalFilter (including the occurrences around the
van Herk filtering code paths) to use a thread-local static buffer so each
thread reuses its own storage without sharing across threads. Keep the
no-cross-thread-sharing contract intact by making the buffer thread-local in the
affected methods and reuse the same pattern consistently at all listed buffer
declarations.
🤖 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/PROCESSING/ID/IDFilter.h`:
- Around line 912-913: Update the implementation comment in
IDFilter::removeHitType (the score_type handling block) to remove the
issue-tracker reference “issue `#9488`, PROC-32” and rewrite it as a durable
behavior description. Keep the note focused on the actual contract: when
score_type is not present as a main or secondary score for an ID, all of its
hits are removed, matching the documented behavior above.

In `@src/openms/source/PROCESSING/FEATURE/FeatureOverlapFilter.cpp`:
- Around line 514-519: Remove the tracker-specific text from the implementation
comment near feature_map.clear(false) in FeatureOverlapFilter.cpp and rewrite it
as a durable behavior note. Keep the explanation focused on what clear(false)
preserves and why unassigned peptide identifications are not carried over,
without mentioning issue or ticket identifiers. Use the surrounding
FeatureOverlapFilter logic to ensure the comment still documents the contract
for combining FAIMS and non-FAIMS features.

In `@src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.cpp`:
- Around line 42-44: Remove the tracker references from the comment in
SignalToNoiseEstimator.cpp and rewrite it as a durable behavior description
only. Update the nearby comment around the scan-index selection logic in
SignalToNoiseEstimator so it explains that the code samples only non-empty
spectra for the requested ms_level and clamps the percentile index, without
mentioning issue or ticket IDs.
- Around line 45-46: The random selection in SignalToNoiseEstimator’s scan
picking has an off-by-one bias because multiplying by spec_indices.size() - 1
prevents the last index from ever being chosen. Update the pick calculation in
the sampling logic so the range covers the full spec_indices vector uniformly,
and keep the scan lookup via spec_indices[pick] consistent with the corrected
random index generation.

In `@src/tests/class_tests/openms/source/IDFilter_test.cpp`:
- Around line 490-491: Update the test comments in IDFilter_test.cpp to remove
the tracker citations (“issue `#9488`, PROC-32”) and replace them with a plain
description of the documented contract; keep the note focused on the behavior
that hits are removed when the score_type is not found. Make the same cleanup in
the nearby related comment block so the wording is consistent across the
IDFilter test cases.

In `@src/tests/class_tests/openms/source/MorphologicalFilter_test.cpp`:
- Around line 706-751: Guard the intensity comparison in
MorphologicalFilter_test by stopping the element-wise loop unless the output
sizes match the expected spectra. In the concurrent test around worker,
result_a, result_b, expected_a, and expected_b, replace the current size checks
with a hard assertion/failure path that prevents the subsequent for-loop from
running on mismatched sizes. Keep the loop that compares intensities only after
the size validation succeeds, so the test cannot index result_a[i] or
result_b[i] out of bounds.

In `@src/tests/class_tests/openms/source/SignalToNoiseEstimator_test.cpp`:
- Around line 110-113: Remove the tracker reference from the test comment in
SignalToNoiseEstimator_test and rewrite it as a plain behavioral note; keep the
explanation about interleaved MS1/MS2 intensities and ms_level-specific
sampling, but drop “issue `#9488`, PROC-23” and any other ticket-style
identifiers. Update the nearby comment in the same test block so it still
explains why the picker is level-deterministic, using only descriptive wording.

---

Nitpick comments:
In `@src/openms/include/OpenMS/PROCESSING/BASELINE/MorphologicalFilter.h`:
- Around line 174-175: The scratch buffer in MorphologicalFilter’s hot-path
routines is now a plain local, which fixes reentrancy but loses allocation
reuse; update the buffer handling in MorphologicalFilter (including the
occurrences around the van Herk filtering code paths) to use a thread-local
static buffer so each thread reuses its own storage without sharing across
threads. Keep the no-cross-thread-sharing contract intact by making the buffer
thread-local in the affected methods and reuse the same pattern consistently at
all listed buffer declarations.
🪄 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

Run ID: 2d6cff15-5b79-4338-83cc-d1fd0a623231

📥 Commits

Reviewing files that changed from the base of the PR and between 02545db and 5f524f6.

📒 Files selected for processing (13)
  • src/openms/include/OpenMS/PROCESSING/BASELINE/MorphologicalFilter.h
  • src/openms/include/OpenMS/PROCESSING/FILTERING/NLargest.h
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h
  • src/openms/include/OpenMS/PROCESSING/SCALING/RankScaler.h
  • src/openms/source/PROCESSING/FEATURE/FeatureOverlapFilter.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.cpp
  • src/pyOpenMS/tests/unittests/test_SpectraFilter.py
  • src/tests/class_tests/openms/source/FeatureOverlapFilter_test.cpp
  • src/tests/class_tests/openms/source/IDFilter_test.cpp
  • src/tests/class_tests/openms/source/MorphologicalFilter_test.cpp
  • src/tests/class_tests/openms/source/NLargest_test.cpp
  • src/tests/class_tests/openms/source/RankScaler_test.cpp
  • src/tests/class_tests/openms/source/SignalToNoiseEstimator_test.cpp

@timosachsenberg timosachsenberg changed the title [FIX] PROCESSING: m/z-sort after filtering, correct SNE sampling, keep FAIMS-merge meta, IDFilter score-type removal, Morph reentrancy (#9488 PROC-15/16/23/31/32/33) [FIX] PROCESSING: m/z-sort after filtering, correct SNE sampling, keep FAIMS-merge meta, IDFilter score-type removal, Morph thread safety (#9488 PROC-15/16/23/31/32/33) Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.h`:
- Around line 149-151: The documentation for the public function described near
the percentile behavior lacks the required Doxygen structure. Add an `@brief` line
summarizing its purpose, followed by a blank line and the existing detailed
description, preserving the documented zero-scan and percentile-clamping
behavior.
- Line 150: Update the documentation comment near the SignalToNoiseEstimator API
to state that 0.0 is returned when n_scans is zero or no non-empty scans with
the required level are present, replacing the broader “no scans” wording without
changing implementation behavior.
🪄 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

Run ID: 3d70bfda-59f1-40b5-ae42-01133cec4267

📥 Commits

Reviewing files that changed from the base of the PR and between 5f524f6 and 0570ab6.

📒 Files selected for processing (13)
  • src/openms/include/OpenMS/PROCESSING/BASELINE/MorphologicalFilter.h
  • src/openms/include/OpenMS/PROCESSING/FILTERING/NLargest.h
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h
  • src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.h
  • src/openms/include/OpenMS/PROCESSING/SCALING/RankScaler.h
  • src/openms/source/PROCESSING/FEATURE/FeatureOverlapFilter.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.cpp
  • src/tests/class_tests/openms/source/FeatureOverlapFilter_test.cpp
  • src/tests/class_tests/openms/source/IDFilter_test.cpp
  • src/tests/class_tests/openms/source/MorphologicalFilter_test.cpp
  • src/tests/class_tests/openms/source/NLargest_test.cpp
  • src/tests/class_tests/openms/source/RankScaler_test.cpp
  • src/tests/class_tests/openms/source/SignalToNoiseEstimator_test.cpp
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/tests/class_tests/openms/source/RankScaler_test.cpp
  • src/openms/source/PROCESSING/FEATURE/FeatureOverlapFilter.cpp
  • src/tests/class_tests/openms/source/SignalToNoiseEstimator_test.cpp
  • src/openms/include/OpenMS/PROCESSING/FILTERING/NLargest.h
  • src/tests/class_tests/openms/source/IDFilter_test.cpp
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimator.cpp
  • src/tests/class_tests/openms/source/FeatureOverlapFilter_test.cpp
  • src/tests/class_tests/openms/source/MorphologicalFilter_test.cpp
  • src/tests/class_tests/openms/source/NLargest_test.cpp
  • src/openms/include/OpenMS/PROCESSING/SCALING/RankScaler.h
  • src/openms/include/OpenMS/PROCESSING/ID/IDFilter.h

timosachsenberg added a commit that referenced this pull request Jul 24, 2026
…audit

Fixes 14 of the "no-doubt, easy" defects catalogued in the implementation-
consistency audit #9767. Each fix is small and localized, ships with a focused
regression test that fails (crash/hang/assert) before and passes after, and
preserves behavior on valid inputs (only the buggy edge cases change). The set
was reviewed with Codex and CodeRabbit; their findings are incorporated below.

Boundary / crash / underflow:
- #4  QTClusterFinder / FeatureGroupingAlgorithmKD: guard the empty mass range so
      feature-empty input maps don't dereference front()/back()/size()-1. The
      guards run before the linking work: KD calls postprocess_() first so per-map
      protein/unassigned-peptide IDs survive; QT returns before the single-partition
      branch, whose setParameters_() otherwise throws on the empty maps' invalid
      max m/z (the <2-maps case is validated by the caller).
- #5  TheoreticalSpectrumGenerator: internal-fragment loop bound underflowed for
      peptides shorter than 4 (l < size-1-2) -> use additive l+3 < size.
- #18 MzTab nextPSMRow (both streams): empty hit list underflowed size()-1 and
      looped forever with export_all_psms -> use current_psm_idx_+1 >= size().
- #30 OMSSACSVFile::load: bound the quote-skipping scan by line.end().

Correctness (wrong field / sentinel / flag):
- #3  IDScoreGetterSetter::addToPeptideScoreMap_: the try_emplace "inserted" flag
      was misused, so a duplicated sequence never kept a later better score. Now
      updates BOTH the score and its target/decoy label, and resolves equal-score
      target/decoy ties to the target (matching getPickedProteinScores_), so the
      peptide-level representative is deterministic and input-order independent.
- #6  MRMFeatureFilter: group retention_time_u %RSD read the _l mean/variance.
- #12 ConsensusFeature range max sentinel minPositive() -> minNegative().
- #35 TIC::Result::operator== now includes relative_intensities.

Serialization round-trip:
- #17 Base64::decodeStrings: keep length-1 segments (dropped single-char strings).
      Also updates the malformed "====" corrupted-input expectation (now decodes
      to one placeholder byte instead of being silently dropped).
- #19 ArrowIOHelpers: parse int meta with stoll -> SignedSize (was 32-bit).
- #20 FeatureMapArrowIO::importPSMsFromArrow: group PSM rows by P_ID value, not by
      row adjacency (matches QPXFile/ConsensusMapArrowIO).

Stale-state on reload / clear:
- #27 QcMLFile::load: also clear derived run_/set_Name_ID_map_.
- #32 CalibrationData::clear: also clear groups_.
- #33 KDTreeFeatureMaps: init num_maps_{0}; clear() also clears rt_ cache.

Not included: #1 (=#9488 PROC-23, already in open PR #9616); #2 (correct but the
pooled split-charge FDR path has order-dependent side effects that preclude a
clean regression test in isolation); #7 (percentile index -- verified NOT a bug:
the "-1" is part of the double expression, so the negative value truncates to 0,
no underflow); #38 (TOPP-tool aux-array desync, needs a CLI test). Remaining audit
items need an API/deprecate decision.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
timosachsenberg added a commit that referenced this pull request Jul 24, 2026
…audit (#9790)

Fixes 14 of the "no-doubt, easy" defects catalogued in the implementation-
consistency audit #9767. Each fix is small and localized, ships with a focused
regression test that fails (crash/hang/assert) before and passes after, and
preserves behavior on valid inputs (only the buggy edge cases change). The set
was reviewed with Codex and CodeRabbit; their findings are incorporated below.

Boundary / crash / underflow:
- #4  QTClusterFinder / FeatureGroupingAlgorithmKD: guard the empty mass range so
      feature-empty input maps don't dereference front()/back()/size()-1. The
      guards run before the linking work: KD calls postprocess_() first so per-map
      protein/unassigned-peptide IDs survive; QT returns before the single-partition
      branch, whose setParameters_() otherwise throws on the empty maps' invalid
      max m/z (the <2-maps case is validated by the caller).
- #5  TheoreticalSpectrumGenerator: internal-fragment loop bound underflowed for
      peptides shorter than 4 (l < size-1-2) -> use additive l+3 < size.
- #18 MzTab nextPSMRow (both streams): empty hit list underflowed size()-1 and
      looped forever with export_all_psms -> use current_psm_idx_+1 >= size().
- #30 OMSSACSVFile::load: bound the quote-skipping scan by line.end().

Correctness (wrong field / sentinel / flag):
- #3  IDScoreGetterSetter::addToPeptideScoreMap_: the try_emplace "inserted" flag
      was misused, so a duplicated sequence never kept a later better score. Now
      updates BOTH the score and its target/decoy label, and resolves equal-score
      target/decoy ties to the target (matching getPickedProteinScores_), so the
      peptide-level representative is deterministic and input-order independent.
- #6  MRMFeatureFilter: group retention_time_u %RSD read the _l mean/variance.
- #12 ConsensusFeature range max sentinel minPositive() -> minNegative().
- #35 TIC::Result::operator== now includes relative_intensities.

Serialization round-trip:
- #17 Base64::decodeStrings: keep length-1 segments (dropped single-char strings).
      Also updates the malformed "====" corrupted-input expectation (now decodes
      to one placeholder byte instead of being silently dropped).
- #19 ArrowIOHelpers: parse int meta with stoll -> SignedSize (was 32-bit).
- #20 FeatureMapArrowIO::importPSMsFromArrow: group PSM rows by P_ID value, not by
      row adjacency (matches QPXFile/ConsensusMapArrowIO).

Stale-state on reload / clear:
- #27 QcMLFile::load: also clear derived run_/set_Name_ID_map_.
- #32 CalibrationData::clear: also clear groups_.
- #33 KDTreeFeatureMaps: init num_maps_{0}; clear() also clears rt_ cache.

Not included: #1 (=#9488 PROC-23, already in open PR #9616); #2 (correct but the
pooled split-charge FDR path has order-dependent side effects that preclude a
clean regression test in isolation); #7 (percentile index -- verified NOT a bug:
the "-1" is part of the double expression, so the negative value truncates to 0,
no underflow); #38 (TOPP-tool aux-array desync, needs a CLI test). Remaining audit
items need an API/deprecate decision.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
timosachsenberg and others added 2 commits October 15, 2026 13:42
- FeatureOverlapFilter: develop already keeps the IDs and meta data in
  mergeFAIMSFeatures() (OpenMS#10001), so the test section goes too.
- NLargest/RankScaler: every caller in the library re-sorts the peaks,
  and RankScaler has no caller outside pyOpenMS; no output changes.

What stays: MorphologicalFilter thread-local buffers, the IDFilter
typed peptide-score fix with remove-on-missing score type, and the
estimateNoiseFromRandomScans() sampling fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
@timosachsenberg timosachsenberg changed the title [FIX] PROCESSING: m/z-sort after filtering, correct SNE sampling, keep FAIMS-merge meta, IDFilter score-type removal, Morph thread safety (#9488 PROC-15/16/23/31/32/33) [FIX] IDFilter typed peptide-score filter, MorphologicalFilter thread safety, random-scan noise sampling Oct 15, 2026

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR bundles three independent fixes: IDFilter's typed peptide-score filter, thread-local scratch buffers in MorphologicalFilter, and sampling through spec_indices in estimateNoiseFromRandomScans(). I checked each one separately and all three look correct.

  • Conflict: only CHANGELOG conflicts with develop. Develop added FIX entries right next to yours under 3.7.0 → OpenMS Library, so keeping both resolves it. src/tests/topp/CMakeLists.txt merges automatically, and the name TOPP_IDFilter_25 is still unused on develop.
  • Not superseded: develop still has all three bugs: filterHitsByScore(proteins, pep_score, score_type_enum), the plain static buffers, and the exp[scan] indexing. Since the merge-base, develop changed none of the touched source files.
  • IDFilter: TOPP_IDFilter_25 fails without the fix, but it only covers the main-score path. The meta-value and missing-score paths are covered by the class test. The description calls -score:type_peptide/-score:type_protein the only callers of the typed overload, but PercolatorAdapter::applyPostFilters_ (-score:fdr, QVAL) uses it too. Its results don't change, because both Percolator backends stamp MS:1001491 on every hit.
  • MorphologicalFilter: the race is real. MapAlignerPoseClustering's omp parallel for over the input files reaches the filter created locally in PoseClusteringAffineSuperimposer.
  • Noise estimation: both new test cases fail on develop: the interleaved MS1/MS2 case and the case with the only eligible spectrum at the last index.

CI was green on the last head.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The merge with develop is pushed (0ef4f00). The CHANGELOG conflict is resolved by keeping both entries. The description now lists PercolatorAdapter's -score:fdr among the callers of the typed filterHitsByScore(), with the note that its results don't change.


Generated by Claude Code

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@timosachsenberg
timosachsenberg merged commit b347a13 into OpenMS:develop Oct 16, 2026
7 of 8 checks passed
timosachsenberg pushed a commit that referenced this pull request Oct 16, 2026
timosachsenberg pushed a commit that referenced this pull request Oct 16, 2026
…lection, #10600 pyOpenMS docstrings)

Conflicts:
- FileHandler.cpp: the include list (this branch sorts it); develop's new
  IONMOBILITY/IMTypes.h include is added.
- bind_analysis/chemistry/kernel/processing.cpp: develop corrected the
  docstrings and nested ConsensusFeature.Ratio, this branch had reformatted
  the same blocks. Develop's blocks are taken; this branch's additions are
  kept (RNaseDigestion.digest(run), the IdentificationData methods of
  FeatureMap, the native IDFilter entry points) and get docstrings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants