Skip to content

Refactor MzPAF: rename isStandardFragmentIon, make toString total - #10197

Merged
timosachsenberg merged 4 commits into
developfrom
claude/modest-ptolemy-4phhom
Sep 19, 2026
Merged

timosachsenberg merged 4 commits into
developfrom
claude/modest-ptolemy-4phhom

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up cleanups to the MzPAF satellite-ion support merged in #10180. Only point 2 changes behaviour.

  1. Rename isStandardFragmentIon() to isPeptideFragmentIon(). The predicate returns true for d/v/w, whose calculateTheoreticalMZ() returns std::nullopt by design, so the old name promised more than it delivers — the natural caller pattern if (isStandardFragmentIon(s)) mz = *calculateTheoreticalMZ(...) would dereference an empty optional. The documentation already said "peptide"; the name now agrees, and a @note records that a true result does not imply a computable mass. This is a public API break, but MzPAF is unreleased (3.6.0, under development) and has no callers outside the class, its test and the bindings, so no deprecation shim is warranted.

  2. Make MzPAF::toString() total. It threw Exception::InvalidParameter for a satellite subtype mzPAF does not allow, while writing an equally invalid UNKNOWN series as ? without complaint — two contracts in one function. The throw also escaped through three callers that should not throw: operator<<(), so a log line or a failing TEST_EQUAL's printer could raise; toString(MzPAFPeakAnnotations), where one bad entry discarded the whole list; and toPeakAnnotation(). It now drops the non-conformant subtype instead, mirroring the UNKNOWN precedent. Rejecting such annotations stays isValid()'s job, which still refuses them.

  3. Revert the clang-format churn in bind_chemistry.cpp. The binding diff in Support mzPAF satellite-ion annotations (d, v, w) #10180 was 87 insertions and 58 deletions, nearly all reindentation of blocks the change never touched, which buried the handful of lines that mattered. Restoring the surrounding formatting leaves only the substantive edits: measured against the merge base, that file is now 8 insertions and 2 deletions rather than 145 changed lines. Reformatting it is worth doing, but as its own commit. One trailing space on the restored MzPAFAnnotation line is stripped rather than faithfully reintroduced, so git diff --check stays clean.

  4. Tests updated to the new contract. The TEST_EXCEPTION / pytest.raises cases on toString() become assertions on the lenient output, plus a new case streaming an invalid annotation through operator<<().

Validation

⚠️ These commits were not compiled or run locally. The authoring environment had no OpenMS build available (empty contrib submodule, no system Boost). Verification so far is limited to: exhaustive grep confirming the rename leaves no stale references, python -m py_compile on the changed test module, and git diff --check.

CI on this PR is the first real build and test run — please weigh it over the checklist below.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file — not updated: the satellite-ion feature is already recorded under 3.6.0 by Support mzPAF satellite-ion annotations (d, v, w) #10180 and has not shipped, so that entry describes the final state. Happy to add a line for the rename if reviewers prefer.
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes — not verified locally; see Validation above.
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82

The d/v/w enumerators were appended after UNKNOWN so that every pre-existing
MzPAFIonSeries value stays stable, which matters because pyOpenMS exposes the
enum arithmetically (nb::is_arithmetic). Without a note, the odd-looking order
invites a later reordering that would silently shift those values.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
toString() threw Exception::InvalidParameter for a satellite subtype that mzPAF
does not allow, while writing an equally invalid UNKNOWN series as '?' without
complaint -- two contracts in one function. The throw also escaped through three
callers that should not throw: operator<<(), so a log line or a failing
TEST_EQUAL's printer could raise; toString(MzPAFPeakAnnotations), where one bad
entry discarded the whole list; and toPeakAnnotation().

Drop the non-conformant subtype when serialising instead, matching the UNKNOWN
precedent, and leave rejection to isValid(), which still refuses these
annotations. Tests assert the lenient output in place of the exception and cover
streaming an invalid annotation.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
The predicate now returns true for d/v/w, whose calculateTheoreticalMZ() returns
std::nullopt by design, so the name promised more than it delivers: the natural
caller pattern `if (isStandardFragmentIon(s)) mz = *calculateTheoreticalMZ(...)`
would dereference an empty optional. The documentation already said "peptide";
the name now agrees, and a @note spells out that a true result does not imply a
computable mass.

Renaming a public static is an API break, but MzPAF is unreleased (3.6.0, under
development) and has no callers outside the class, its test and the bindings, so
no deprecation shim is warranted.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
…g change

The binding diff was 87 insertions and 58 deletions, nearly all of it
reindentation of MzPAFAnnotation, MzPAFIonSeries and MzPAF blocks the change
never touched, which buried the handful of lines that actually matter. Restore
the surrounding formatting so the diff carries only the substantive edits: the
satellite_subtype field, the D/V/W enum values, the two docstring lines, the
isPeptideFragmentIon rename and the missing newline at end of file.

Same resulting binding, 8 insertions and 2 deletions instead of 145 changed
lines. Reformatting this file is worth doing, but as its own commit.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2a6de644-cd99-4a38-b294-2ce35b28c27e

📥 Commits

Reviewing files that changed from the base of the PR and between 7b28dad and 3650eca.

📒 Files selected for processing (5)
  • src/openms/include/OpenMS/CHEMISTRY/MzPAF.h
  • src/openms/source/CHEMISTRY/MzPAF.cpp
  • src/pyOpenMS/bindings/bind_chemistry.cpp
  • src/pyOpenMS/tests/test_MzPAF.py
  • src/tests/class_tests/openms/source/MzPAF_test.cpp

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

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

@timosachsenberg
timosachsenberg merged commit fabe1a7 into develop Sep 19, 2026
33 checks passed
@timosachsenberg
timosachsenberg deleted the claude/modest-ptolemy-4phhom branch September 19, 2026 05:34
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