Skip to content

[PARAM,TOPP,TEST] ProteomicsLFQ: remove -in_feat and -out_feat - #9882

Merged
timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:lfq-infeat-duplicate-psms
Aug 8, 2026
Merged

timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:lfq-infeat-duplicate-psms

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Removes both -in_feat and -out_feat from ProteomicsLFQ. Splitting a run into a per-file feature detection step and a combining step is not something the tool is ready to offer, so neither half of that seam stays exposed.

The net diff against develop is a pure removal.

Scope

-in_feat did not originate in this PR — it came from #8796, merged during the unreleased 3.6.0 cycle. It has never appeared in a release, so removing it breaks no released API, and its CHANGELOG entry could simply be deleted rather than replaced with a removal note. -out_feat was added on this branch and never left it.

What was removed

src/topp/ProteomicsLFQ.cpp:

  • both parameter registrations, and the positional-count validation in main_ that tied each list to -in
  • the pre-computed-feature path in quantifyFraction_: the -mass_recalibration incompatibility guard, the requires_ms_data skip of mzML loading / FWHM estimation / seeding, the featureXML load with its run-path and identifier reconciliation, and the -out_feat writer
  • the ProteomicsLFQ_median_fwhm map-level meta value, which existed only to carry the measured FWHM from a writing run to a reading one (the linker derives its RT tolerance from it, and a reading run cannot recompute it without the mzML)
  • the tool documentation section describing the split workflow
  • the FeatureXMLFile.h include — feat(ProteomicsLFQ): Add -in_feat parameter to bypass internal feature finding #8796 added it for this path, and nothing else used it

FeatureFinderIdentification is unconditional again, exactly as before #8796.

Tests: the TOPP_ProteomicsLFQ_in_feat* and TOPP_ProteomicsLFQ_out_feat* blocks, plus their four fixtures (ProteomicsLFQ_in_feat_1.featureXML, ProteomicsLFQ_in_feat_2.featureXML, ProteomicsLFQ_in_feat_multi_out.mzTab, ProteomicsLFQ_in_feat_out.mzTab).

CHANGELOG: all three 3.6.0 entries — the -out_feat feature, the -in_feat duplication fix, and #8796's original -in_feat addition.

Effect on #9871

The OpenMS half of #9871 was a PSM duplication that only ever occurred on the -in_feat path: an incoming featureXML arrives already partitioned into feature-attached and unassigned identifications, and the tool replaced the unassigned list with all identifications, so every already-attached PSM was present twice. Consumers reading both lists saw it twice — mzTab reported duplicate rows, the QPX psm view refused the repeated primary key, and PSM/peptide FDR (estimated over both lists together) counted each duplicate as an extra target.

Removing the path removes the defect along with it, so that half of the issue is moot rather than fixed. The normal FeatureFinderIdentification path was never affected; it partitions the two lists correctly.

The other half of #9871 — one PSM row per search engine — is unrelated to this and remains open. Two engines matching one spectrum are two distinct identifications in OpenMS's model; combining them is ConsensusIDAlgorithm's job, which ProteomicsLFQ does not run.

History of this branch

The earlier commits fixed the -in_feat duplication and added -out_feat with a round-trip test. The final commit removes both, which supersedes them. They are kept in the history rather than squashed away, since the analysis of the duplication defect is what documents why the path behaved as it did.

Verification

ProteomicsLFQ builds clean. ctest -R TOPP_ProteomicsLFQ: 75/75 pass. ctest -N -R "in_feat|out_feat": 0 tests, confirming the removed tests are gone rather than silently skipped.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm

…ached PSM (OpenMS#9871)

The two identification lists of a FeatureMap partition the PSMs: attached to a
feature, or unassigned. IDMapper and FeatureFinderIdentification both produce
them that way. The -in_feat branch did not: it replaced the unassigned list with
EVERY identification passed to the tool, including the ones the incoming
featureXML had already attached to features. Each of those was then present
twice.

Measured on the shipped fixture: 18 of 62 PSM entries were duplicates, and every
single collision was one attached copy plus one unassigned copy - no attached +
attached, no unassigned + unassigned.

Consumers reading both lists saw each duplicate twice:

  - mzTab reported it twice. ProteomicsLFQ_in_feat_multi_out.mzTab has carried 18
    duplicate PSM rows since the test was added on 2026-03-02.
  - PSM/peptide FDR is estimated over both lists together, so each duplicate
    counted as an extra target: q-values were 1/63 where the data supports 1/45.
    With psmFDR at its 1.0 default nothing is filtered, but any cutoff between
    those two values changes which identifications survive. This is the part that
    makes it a correctness bug rather than bookkeeping.
  - The QPX psm view refuses a repeated primary key, so -in_feat with -out_qpx
    aborted the whole export.

The unassigned list is now built from the identifications not attached to a
feature, matched on spectrum reference. Two guards: an empty spectrum reference
cannot establish attachment (otherwise one attached PSM without a reference would
exclude every input PSM that also lacks one), and an identification sharing a
spectrum with an attached one but assigning a different peptide is kept and
warned about rather than silently dropped - that means the featureXML was not
produced from these identifications.

Only -in_feat is affected. The normal FeatureFinderIdentification path already
partitions correctly; its QPX exports have unique psm keys (measured 104/104 and
115/115).

TOPP_ProteomicsLFQ_in_feat now also writes -out_qpx, and a ParquetDiff check
asserts schema and primary-key uniqueness on the psm view - a row-count floor
cannot catch this, since a floor is satisfied by a table containing duplicates.
Verified to fail for its stated reason: with the old behaviour restored, the
producer, the mzTab diff and the psm check all go red.

The clean step also removes the mzTab. Without that, the producer aborting left
the previous run's file in place and the mzTab diff passed against output the
tool had not just written - observed while probing this.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@coderabbitai

coderabbitai Bot commented Aug 6, 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

Walkthrough

ProteomicsLFQ no longer supports precomputed featureXML input through -in_feat. It now always loads MS data, performs preprocessing and feature detection, and removes the related regression tests, fixtures, and changelog entry.

Changes

ProteomicsLFQ featureXML input removal

Layer / File(s) Summary
Remove precomputed featureXML processing
src/topp/ProteomicsLFQ.cpp
The -in_feat option, featureXML loading, input-count validation, and conditional processing are removed. Feature detection now runs for all MS inputs.
Remove featureXML regression coverage
src/tests/topp/CMakeLists.txt, src/tests/topp/ProteomicsLFQ_in_feat_*.featureXML, src/tests/topp/ProteomicsLFQ_in_feat_*.mzTab
The -in_feat regression tests and their featureXML and mzTab fixtures are deleted.
Update project history
CHANGELOG
The changelog entry for precomputed featureXML support is removed.

Suggested reviewers: cbielow, pjones

Poem

A rabbit finds the feature trail,
No stored XML rides the rail.
MS data guides the run,
Detection starts when loading’s done.
Old test maps rest in the vale.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

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.
Title check ⚠️ Warning The title correctly identifies removal of -in_feat but incorrectly states that -out_feat is removed, while the objectives specify adding -out_feat support. Update the title to describe removal of -in_feat and addition of -out_feat support.
✅ Passed checks (3 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.
✨ 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

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

@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: 1

🤖 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/topp/ProteomicsLFQ.cpp`:
- Around line 1174-1187: Update the attached_psms tracking in the
feature/peptide-identification loop to retain every distinct sequence-and-charge
pair for each spectrum reference, rather than allowing emplace to keep only the
first pair. Use a per-reference set or collection of full (sequence, charge)
keys, and update the later input-PSM comparison to match against those keys so
all attached identifications are excluded from unassigned_pep_ids.
🪄 Autofix

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: b9000f22-9497-48b2-b24c-7e4d18855193

📥 Commits

Reviewing files that changed from the base of the PR and between af31c76 and f87b580.

📒 Files selected for processing (4)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteomicsLFQ_in_feat_multi_out.mzTab
  • src/topp/ProteomicsLFQ.cpp

Comment thread src/topp/ProteomicsLFQ.cpp Outdated
Comment on lines +1174 to +1187
std::map<std::string, std::pair<std::string, Int>> attached_psms; // spectrum ref -> (sequence, charge)
for (const Feature& feature : fm)
{
for (const PeptideIdentification& pid : feature.getPeptideIdentifications())
{
// An empty reference identifies nothing, so it cannot establish that a PSM is attached.
// Without this guard a single feature PSM without a reference would exclude every
// input PSM that also lacks one.
const std::string& ref = pid.getSpectrumReference();
if (ref.empty() || pid.getHits().empty()) { continue; }
attached_psms.emplace(ref, std::make_pair(pid.getHits()[0].getSequence().toString(),
pid.getHits()[0].getCharge()));
}
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Look for any deduplication of feature-level peptide identifications by spectrum
# reference that runs before the partition, and confirm the resolve() call order.
set -euo pipefail

# Show the -in_feat block and the later conflict resolution call.
rg -n -C6 'IDConflictResolverAlgorithm::resolve|keep_feature_top_psm_only|attached_psms' src/topp/ProteomicsLFQ.cpp

# Does any FeatureMap consumer assume one identification per spectrum reference per map?
rg -nP -C4 'getSpectrumReference\s*\(\s*\)' --type=cpp -g '!**/tests/**' src/openms/source/ANALYSIS/ID

Repository: OpenMS/OpenMS

Length of output: 7809


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== File size and relevant run function outline/section =="
wc -l src/topp/ProteomicsLFQ.cpp
sed -n '1120,1235p' src/topp/ProteomicsLFQ.cpp | cat -n

echo
echo "== Earlier featureXML processing around fm/population creation =="
sed -n '1300,1430p' src/topp/ProteomicsLFQ.cpp | cat -n

echo
echo "== IDConflictResolverAlgorithm header/docs and resolve behavior =="
fd -a 'IDConflictResolverAlgorithm' src/openms | sed 's#^\./##'
for f in $(fd 'IDConflictResolverAlgorithm\.(h|hpp)$' src/openms); do
  echo "--- $f ---"
  wc -l "$f"
  sed -n '1,240p' "$f" | cat -n
done
for f in $(fd 'IDConflictResolverAlgorithm\.cpp$' src/openms); do
  echo "--- $f ---"
  wc -l "$f"
  sed -n '1,260p' "$f" | cat -n
done

echo
echo "== Deterministic map behavior probe =="
python3 - <<'PY'
import re
from pathlib import Path
p = Path('src/topp/ProteomicsLFQ.cpp')
s = p.read_text()
# Extract inserted block and later loop body without executing repository code.
m0 = re.search(r'attached_psms\s*=.*?PeptideIdentificationList unassigned_pep_ids', s, re.S)
m1 = re.search(r'for \(const PeptideIdentification& pid : peptide_ids\).*?(?=^\s*(?!}\s*$|\} else {|IDConflictResolverAlgorithm))', s, re.S|re.M)
print("attached_psms map key type:", bool(re.search(r'std::map<[^<]*(?:string|const char[^\n]*)[^;]*attached_psms', s)) != 0)
print("attach insertion after line 1174:")
print("\n".join(re.findall(r'attached_psms\..*?\);', s, re.S)))
print("\nlookup body:")
print(m1.group(0) if m1 else "not found")
# Simulate std::map emplace: first value for key stays, later identical key ignored.
attached = {}
for ref, value in [("spt1", ("p1", 2)), ("spt1", ("p2", 3)), ("spt2", ("p1", 2))]:
    if ref not in attached:
        attached[ref] = value
print("attached_psms after emplacing duplicate ref:", attached)

# Simulate current logic: presence of ref passes the first-attached peptide only.
peptide_ids = [
    ("spt1", ("p1", 2)),
    ("spt1", ("p2", 3)),
    ("unknown", ("p1", 2)),
]
unassigned = []
for ref, hit in peptide_ids:
    if not ref:
        unassigned.append(hit)
        continue
    attached_ref = attached.get(ref)
    if attached_ref is None:
        unassigned.append(hit)
        continue
    if hit != attached_ref:
        unassigned.append(hit)

print("input PSMs pushed to unassigned:", unassigned)
print("duplication of original (spt1,p2,3) avoided?", ("spt1", ("p2", 3)) not in unassigned)
PY

Repository: OpenMS/OpenMS

Length of output: 37976


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== File size and relevant run function outline/section =="
wc -l src/topp/ProteomicsLFQ.cpp
sed -n '1120,1235p' src/topp/ProteomicsLFQ.cpp | cat -n

echo
echo "== Earlier featureXML processing around fm/population creation =="
sed -n '1300,1430p' src/topp/ProteomicsLFQ.cpp | cat -n

echo
echo "== IDConflictResolverAlgorithm header/docs and resolve behavior =="
fd -a 'IDConflictResolverAlgorithm' src/openms | sed 's#^\./##'
for f in $(fd 'IDConflictResolverAlgorithm\.(h|hpp)$' src/openms); do
  echo "--- $f ---"
  wc -l "$f"
  sed -n '1,240p' "$f" | cat - n
done
for f in $(fd 'IDConflictResolverAlgorithm\.cpp$' src/openms); do
  echo "--- $f ---"
  wc -l "$f"
  sed -n '1,260p' "$f" | cat -n
done

echo
echo "== Deterministic map behavior probe =="
python3 - <<'PY'
import re
from pathlib import Path
p = Path('src/topp/ProteomicsLFQ.cpp')
s = p.read_text()
print("attach insertion after line 1174:")
for value in re.findall(r'attached_psms\..*?\);', s, re.S):
    print(value)
print("\nlookup body:")
m1 = re.search(r'for \(const PeptideIdentification& pid : peptide_ids\).*?(?=^\s*(?!}\s*$|\} else {|IDConflictResolverAlgorithm))', s, re.S|re.M)
print(m1.group(0) if m1 else "not found")
attached = {}
for ref, value in [("spt1", ("p1", 2)), ("spt1", ("p2", 3)), ("spt2", ("p1", 2))]:
    if ref not in attached:
        attached[ref] = value
print("attached_psms after emplacing duplicate ref:", attached)

peptide_ids = [
    ("spt1", ("p1", 2)),
    ("spt1", ("p2", 3)),
    ("unknown", ("p1", 2)),
]
unassigned = []
for ref, hit in peptide_ids:
    if not ref:
        unassigned.append(hit)
        continue
    attached_ref = attached.get(ref)
    if attached_ref is None:
        unassigned.append(hit)
        continue
    if hit != attached_ref:
        unassigned.append(hit)

print("input PSMs pushed to unassigned:", unassigned)
print("original duplicate (spt1,p2,3) avoided?", ("spt1", ("p2", 3)) not in unassigned)
PY

Repository: OpenMS/OpenMS

Length of output: 25869


Key attached_psms by sequence and charge, too.

std::map::emplace keeps the first (sequence, charge) for each spectrum reference. If input features attach two identifications to the same spectrum reference with different peptides, this partition only excludes the first one, and the second matching input PSM is pushed into unassigned_pep_ids instead, creating duplicate output.

Store a set of per-reference (sequence, charge) pairs, or a multiset/deque of the full key, before comparing the input PSM.

🤖 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/topp/ProteomicsLFQ.cpp` around lines 1174 - 1187, Update the
attached_psms tracking in the feature/peptide-identification loop to retain
every distinct sequence-and-charge pair for each spectrum reference, rather than
allowing emplace to keep only the first pair. Use a per-reference set or
collection of full (sequence, charge) keys, and update the later input-PSM
comparison to match against those keys so all attached identifications are
excluded from unassigned_pep_ids.

…n from quantification

Feature detection is the expensive per-file part of the workflow and is
independent between files; alignment, linking, inference and quantification need
all files at once. -in_feat could already read pre-computed features, but nothing
produced them in the state it expects - ProteomicsLFQ wrote per-file featureXML
only as debug output at debug_level > 666 - so splitting the run meant
reconstructing its internal FeatureFinderIdentification setup by hand.

-out_feat writes them directly, positionally matched to -in like -in_feat:

  1. per file, in parallel:  -in run1.mzML -ids run1.idXML -out_feat run1.featureXML
  2. once, over everything:  -in run1.mzML run2.mzML ... -in_feat run1.featureXML ...

The combining run reads no mzML at all (measured: no peak picking, no FWHM
estimation, no seeding), though the files must still exist because the list
identifies the runs.

The map also carries the chromatographic FWHM the producing run measured. That is
not decoration: with -in_feat the mzML is never read, so median_fwhm stayed at its
0 initializer, and link_() derives the feature linker's RT tolerance from it
(distance_RT:max_difference = 2*max_alignment_diff + 2*median_fwhm, plus PIP-ECHO's
local_rt:median_fwhm). A split run therefore linked with a narrower window than the
single-shot run it is meant to reproduce. Honest limitation: neither shipped
fixture is sensitive enough to show a difference - the 2-file and 6-file BSA
designs reproduce identically with and without the stamped value - so this is
justified by the parameter it feeds, not by an observed delta. featureXML from any
other source does not carry it, which is warned about rather than silently taken
as 0.

Round-trip test: a single-shot run writing -out_feat, a second run consuming it via
-in_feat, and ParquetDiff between the two -out_qpx collections on all three views.
Key matching is what makes this assertable - the two runs' mzTab PSM sections hold
the same rows in a different order, and consensus feature unique ids are drawn per
run, so a positional text diff would report differences that mean nothing. The
feature view additionally pins that the split reproduces the feature identities,
since rt and observed_mz are part of its key.

Compared at ratio 1.01 because writing a feature to featureXML and back is a
decimal text round trip that moves search engine scores in the last bit. Verified
live rather than vacuous: at the exact default it reports precisely those 6 values
(absdiff ~1e-16), at 1.01 none.

Note this test could not have passed before the -in_feat duplication fix in the
preceding commit: the second run would have aborted on a repeated QPX psm key.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@timosachsenberg timosachsenberg changed the title [FIX,TEST] ProteomicsLFQ -in_feat: stop duplicating every feature-attached PSM (#9871) [FIX,FEATURE,TEST] ProteomicsLFQ: fix -in_feat PSM duplication, add -out_feat to split feature detection (#9871) Aug 6, 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.

♻️ Duplicate comments (1)
src/topp/ProteomicsLFQ.cpp (1)

1223-1262: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Still unresolved: attached_psms remembers only one peptide per spectrum reference.

attached_psms is std::map<std::string, std::pair<std::string, Int>>, filled with attached_psms.emplace(ref, ...). emplace keeps only the first (sequence, charge) inserted for a given spectrum reference; a second feature-attached PSM with the same ref but a different peptide is silently dropped from the map.

When two different features carry PSMs attached to the same spectrum reference (for example, chimeric spectra with overlapping isolation windows), only one of the corresponding input PSMs matches the map entry and is excluded from unassigned_pep_ids. The other input PSM does not match and is pushed into unassigned_pep_ids, even though it is already attached to a feature. That PSM is then present twice in the output, which is the exact duplicate-PSM defect this PR fixes for the common case.

Store every distinct (sequence, charge) pair per spectrum reference, for example with std::map<std::string, std::set<std::pair<std::string, Int>>>, and check membership in that set instead of equality against a single pair.

🐛 Proposed fix for the multi-peptide-per-spectrum case
-        std::map<std::string, std::pair<std::string, Int>> attached_psms; // spectrum ref -> (sequence, charge)
+        std::map<std::string, std::set<std::pair<std::string, Int>>> attached_psms; // spectrum ref -> set of (sequence, charge)
         for (const Feature& feature : fm)
         {
           for (const PeptideIdentification& pid : feature.getPeptideIdentifications())
           {
             const std::string& ref = pid.getSpectrumReference();
             if (ref.empty() || pid.getHits().empty()) { continue; }
-            attached_psms.emplace(ref, std::make_pair(pid.getHits()[0].getSequence().toString(),
-                                                      pid.getHits()[0].getCharge()));
+            attached_psms[ref].emplace(pid.getHits()[0].getSequence().toString(),
+                                        pid.getHits()[0].getCharge());
           }
         }

         PeptideIdentificationList unassigned_pep_ids;
         unassigned_pep_ids.reserve(peptide_ids.size());
         Size mismatched_attached = 0;
         for (const PeptideIdentification& pid : peptide_ids)
         {
           const auto attached = pid.getSpectrumReference().empty()
                                   ? attached_psms.end()
                                   : attached_psms.find(pid.getSpectrumReference());
           if (attached == attached_psms.end())
           {
             unassigned_pep_ids.push_back(pid);
             continue;
           }
-          if (! pid.getHits().empty()
-              && (pid.getHits()[0].getSequence().toString() != attached->second.first
-                  || pid.getHits()[0].getCharge() != attached->second.second))
+          if (! pid.getHits().empty()
+              && attached->second.count(std::make_pair(pid.getHits()[0].getSequence().toString(),
+                                                        pid.getHits()[0].getCharge())) == 0)
           {
             ++mismatched_attached;
             unassigned_pep_ids.push_back(pid);
           }
         }
🤖 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/topp/ProteomicsLFQ.cpp` around lines 1223 - 1262, Update attached_psms in
the surrounding feature-attachment logic to map each spectrum reference to a set
of distinct (sequence, charge) pairs, inserting every valid feature PSM rather
than retaining only the first via emplace. In the peptide_ids filtering loop,
consider a PSM attached when its reference exists and its sequence/charge pair
is present in that set; preserve the existing handling for empty references,
empty hits, and mismatched attached identifications.
🧹 Nitpick comments (1)
src/topp/ProteomicsLFQ.cpp (1)

1029-1036: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Move the -mass_recalibration/-in_feat conflict check out of the per-file loop.

This check runs inside quantifyFraction_'s per-file loop, after loadAndCleanupIDFile_ has already loaded and possibly re-indexed the current file's identifications against the FASTA database. On the first file, that work runs before the tool aborts with the incompatibility error.

Move the check to main_()'s parameter validation block, alongside the other -in_feat/-out_feat checks. main_() already has in_feat and can read -mass_recalibration there, so the check can run before any per-file processing starts.

♻️ Proposed relocation
     StringList in_feat = getStringList_("in_feat");
+    StringList out_feat = getStringList_("out_feat");
+
+    // Validate parameters
+    if (! in_feat.empty() && getStringOption_("mass_recalibration") == "true")
+    {
+      throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+        "Option '-mass_recalibration' is not supported together with '-in_feat' because pre-computed features bypass internal feature finding.");
+    }
       MSExperiment ms_centroided;
       bool is_im_peak_data = false;
-      const bool mass_recalibration = (getStringOption_("mass_recalibration") == "true");
-
-      if (! in_feat_list.empty() && mass_recalibration)
-      {
-        throw Exception::InvalidParameter(
-          __FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
-          "Option '-mass_recalibration' is not supported together with '-in_feat' because pre-computed features bypass internal feature finding.");
-      }
+      const bool mass_recalibration = (getStringOption_("mass_recalibration") == "true");
🤖 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/topp/ProteomicsLFQ.cpp` around lines 1029 - 1036, Move the
mass_recalibration and in_feat incompatibility validation from
quantifyFraction_’s per-file loop into main_()’s parameter-validation block,
alongside the existing in_feat/out_feat checks. Use main_()’s in_feat value and
mass_recalibration option there, and remove the loop-local check so the error is
raised before any file loading or re-indexing.
🤖 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.

Duplicate comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 1223-1262: Update attached_psms in the surrounding
feature-attachment logic to map each spectrum reference to a set of distinct
(sequence, charge) pairs, inserting every valid feature PSM rather than
retaining only the first via emplace. In the peptide_ids filtering loop,
consider a PSM attached when its reference exists and its sequence/charge pair
is present in that set; preserve the existing handling for empty references,
empty hits, and mismatched attached identifications.

---

Nitpick comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 1029-1036: Move the mass_recalibration and in_feat incompatibility
validation from quantifyFraction_’s per-file loop into main_()’s
parameter-validation block, alongside the existing in_feat/out_feat checks. Use
main_()’s in_feat value and mass_recalibration option there, and remove the
loop-local check so the error is raised before any file loading or re-indexing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f123734e-afcd-4ea8-9af9-4a7f119e440a

📥 Commits

Reviewing files that changed from the base of the PR and between f87b580 and dfee5a0.

📒 Files selected for processing (3)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/topp/ProteomicsLFQ.cpp

OpenMS#9880 (ProteomicsLFQ stops normalizing, exports raw intensities) landed on
develop and changes the same lines as this branch. Two conflicts, both in
files the two changes share:

CHANGELOG -- both sides append bullets to the ProteomicsLFQ section. Kept
both, develop's BREAKING entry first.

ProteomicsLFQ_in_feat_multi_out.mzTab -- neither side's reference is correct
after the merge. This branch's version has the deduplicated PSM rows and the
q-values that follow from them; develop's still has the 18 duplicates but
carries the raw, un-normalized intensities. Regenerated by running the merged
tool, then verified to be exactly the composition of the two rather than
accepted on the strength of the test going green:

  vs this branch's reference: the only fields that move are abundances (PEP
  col 19, PRT cols 13/17), and every one of them moves by the identical
  factor 1.583596 -- the fraction-2 median scaling OpenMS#9880 removed. No q-value
  and no row-set change.

  vs develop's reference: 18 fewer PSM rows (62 -> 44) and 36 q-value changes
  across the 18 shared PEP rows, and zero abundance differences.

So the new reference is this branch's rows and q-values with develop's raw
intensities, which is what the merged code should produce. The four
whitelisted MTD lines (software[1..2], ms_run[1..2]-location) are kept in the
reference's own form instead of the local build's version string and paths.

src/topp/ProteomicsLFQ.cpp and src/tests/topp/CMakeLists.txt auto-merged;
checked that OpenMS#9880's normalization removal and its five qpx_flags tests
survive alongside this branch's -in_feat dedup and -out_feat tests.

Local: TOPP_ProteomicsLFQ_{in_feat,out_feat}* 11/11, and 221/221 over
QPX/Arrow/ParquetDiff/ProteomicsLFQ/ProteinQuantifier/IsobaricWorkflow/
MzTab/ConsensusMapNormalizer.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg and others added 2 commits August 7, 2026 23:45
Splitting a ProteomicsLFQ run into a per-file feature detection step and a
combining step is not something the tool is ready to offer, so neither half of
that seam is exposed: -out_feat (added in this PR) is dropped, and -in_feat
(OpenMS#8796, added during the unreleased 3.6.0 cycle and never shipped in a release)
is removed with it.

Removed:
- the two parameters and their positional-count validation in main_
- the pre-computed-feature load path in quantifyFraction_, including the
  -mass_recalibration incompatibility guard, the skip of mzML loading /
  FWHM estimation / seeding, and the ProteomicsLFQ_median_fwhm map meta value
  that carried the FWHM between a writing and a reading run
- the now-unused FeatureXMLFile.h include (OpenMS#8796 added it for this path)
- the TOPP_ProteomicsLFQ_in_feat / _out_feat tests and their four fixtures
- the corresponding CHANGELOG entries, all in the unreleased 3.6.0 section

FeatureFinderIdentification is now unconditional again, as it was before OpenMS#8796;
the diff against develop is a pure removal. Local TOPP_ProteomicsLFQ suite:
75/75 pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01S7QNzj4dhRnX5htcHZFmDm
@timosachsenberg timosachsenberg changed the title [FIX,FEATURE,TEST] ProteomicsLFQ: fix -in_feat PSM duplication, add -out_feat to split feature detection (#9871) [PARAM,TOPP,TEST] ProteomicsLFQ: remove -in_feat and -out_feat Aug 8, 2026
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Feature fire parallel feature finding will be postponed.

@timosachsenberg
timosachsenberg merged commit 1131d8f into OpenMS:develop Aug 8, 2026
33 checks passed
timosachsenberg added a commit that referenced this pull request Aug 11, 2026
Audited PRs merged since the last CHANGELOG update (#9881): most of
them (#9879, #9880, #9882, #9884, #9886, #9892, #9896, #9898, #9900,
#9901, #9888) already carried their own CHANGELOG entries. Only the
Docker library-stage fix (#9891) was missing one.


Claude-Session: https://claude.ai/code/session_01Jgrv6mFL3oawgLdYs1efPH

Co-authored-by: Claude <[email protected]>
timosachsenberg added a commit that referenced this pull request Aug 29, 2026
…e detection via -feat_dir

Feature detection is the expensive part of the workflow and each MS run is
detected independently of every other; alignment, linking, inference and
quantification need all runs at once. Until now that seam was not reachable: the
per-run half could neither be resumed nor spread over machines.

-feat_dir names a directory of per-run feature checkpoints and applies ONE rule
to every row of the experimental design: reuse its checkpoint if a valid one is
there, otherwise detect the run from -in/-ids and write one, otherwise fail.
Everything else follows from that rather than from a second code path:

  resumable      -design d.tsv -in *.mzML -ids *.idXML -feat_dir ckpt/ -out r.mzTab
                 interrupt it, run it again, it continues

  distributed    -design d.tsv -in a.mzML -ids a.idXML -feat_dir ckpt/ -detect_only
                 one invocation per run, any order, no coordination

  combine        -design d.tsv -feat_dir ckpt/ -out r.mzTab
                 no mzML, no idXML, no run-level FASTA content is read

This is the second attempt. The first (-in_feat, #8796) was removed wholesale in
#9882, and the reasons are what shaped this one:

- A checkpoint is tool-internal state, not an interchange format. It carries the
  measured chromatographic FWHM, the decoy affix and modification sets from
  peptide indexing, and the canonical run identifier -- everything the combining
  step cannot recompute without the raw data. #8796 accepted feature maps from
  anywhere and had to guess at all of it.

- Reuse is guarded rather than trusted. A checkpoint records the parameters that
  shaped it, the OpenMS build, its design row and its input files, and is refused
  if any disagree -- naming the setting that differs, since diffing INIs across
  200 nodes by hand is exactly when nobody will. The parameter scope is a
  blacklist of combine-only keys, not an allowlist: forgetting to exclude a new
  combine-only parameter is a loud false mismatch, forgetting to include a new
  detection parameter in an allowlist would silently combine checkpoints that
  disagree. Only a differing build may be waved through, with
  -feat_dir_accept_mismatch, which is recorded in the result rather than only in
  a log nobody reads later.

- A checkpoint is complete or absent. It is written under a temporary name inside
  -feat_dir and renamed into place once every file is closed, so a resuming run
  can trust a plain existence check; a directory that is nonetheless incomplete
  is refused rather than half-read.

- -design is mandatory. A generated design would assign Fraction_Group 1 to the
  single run a detect-only invocation sees, so every machine would independently
  label its run the first one. -fasta likewise: without peptide indexing there is
  no decoy affix, no uniqueness annotation and no protein sequences, and a
  combining run cannot obtain them afterwards.

A split run reproduces a single-shot run EXACTLY. Six detect-only invocations
followed by a combine give QPX feature, psm and pg views that ParquetDiff finds
identical at its default (exact) ratio. The comparison is made there rather than
on mzTab or consensusXML because those carry per-run unique ids drawn from a
process-global generator, which necessarily differ once runs are detected in
separate processes; QPX keys rows on content instead.

Getting that exact took one fix beyond the seam itself: the Parquet reader
annotates every PeptideHit with 'scan' and 'reference_file_name' whether or not
the written hit had them, which made a checkpointed run emit two mzTab opt_
columns a single-shot run does not. A detected run never carries those, so they
are removed on load. This was recorded as a known FeatureMapArrowIO wart when the
format was audited; it is worked around here rather than changed underneath other
consumers.

-in and -ids are no longer mandatory parameters, since a combining invocation has
neither. They are still required whenever -feat_dir does not cover every run, and
the error is the same one TOPPBase used to raise.

Tests: 14 new, covering the cluster shape (two independent detect-only
invocations over disjoint halves writing into one directory, then a combine with
no inputs), exact equivalence on all three QPX views, resume reporting 6 reused /
0 detected, and four refusals -- a parameter mismatch, an incomplete checkpoint
directory, a design row with no checkpoint, and -feat_dir without -design. Full
TOPP_ProteomicsLFQ suite: 86/86.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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