Skip to content

feat(ProteomicsLFQ): Add -in_feat parameter to bypass internal feature finding - #8796

Merged
timosachsenberg merged 8 commits into
OpenMS:developfrom
satyam102006:feat/8673-plfq-featurexml-input
Mar 2, 2026
Merged

timosachsenberg merged 8 commits into
OpenMS:developfrom
satyam102006:feat/8673-plfq-featurexml-input

Conversation

@satyam102006

@satyam102006 satyam102006 commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR introduces a new -in_feat parameter to the ProteomicsLFQ TOPP tool to allow the use of pre-computed feature maps.

Summary of changes:

  • Registered the -in_feat parameter to accept a list of featureXML files.
  • Added input validation in main_ to ensure the number of input feature files exactly matches the number of input mzML spectra files, throwing an ILLEGAL_PARAMETERS error if they differ.
  • Modified quantifyFraction_ to include a conditional branch: if -in_feat is provided, the tool safely locates the corresponding featureXML and loads the features directly into the FeatureMap (bypassing FeatureFinderIdentificationAlgorithm).
  • Memory & Metadata Safety: Implemented strict iterator validation during file matching to prevent out-of-bounds segfaults. Unconditionally injected protein_ids and peptide_ids into the loaded FeatureMap to guarantee that Experimental Design tags (fraction, fraction_group) are preserved for downstream inferProteinGroups_ and FDR algorithms.

Motivation:
Previously, ProteomicsLFQ strictly relied on its internal feature detection step. This update allows researchers to utilize alternative, external feature detection methods while still leveraging the robust protein inference, quantification, alignment, and linking logic of the OpenMS pipeline.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

Summary by CodeRabbit

  • New Features

    • Added in_feat option to supply pre-computed feature files and optionally bypass internal feature finding.
    • Quantification now propagates fixed and variable modification settings through ID loading, feature handling, and consensus building.
  • Bug Fixes

    • Validation and error handling ensure in_feat count matches inputs; clearer parameter validation messages.
  • Tests

    • Added bypass tests, expected-output tests, and a mismatch-failure test; new test data for in_feat and mzTab scenarios.
  • Chores

    • Minor formatting and string consistency fixes.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Adds an in_feat input option to accept pre-computed FeatureXML files and bypass internal feature finding when provided; threads fixed_modifications and variable_modifications through ID loading, quantification, and consensus-building by changing quantifyFraction_ and loadAndCleanupIDFile_ signatures and call sites; validates in_feat count matches mzML inputs.

Changes

Cohort / File(s) Summary
ProteomicsLFQ core
src/topp/ProteomicsLFQ.cpp
Added public in_feat option; validate in_feat length against -in mzML inputs; load pre-computed FeatureXMLs (via FeatureXMLFile) or fallback to FeatureFinderIdentification; updated signatures to propagate fixed_modifications and variable_modifications through loadAndCleanupIDFile_ and quantifyFraction_; updated call sites, plumbing, validation messages, and includes.
Tests — TOPP CMake
src/tests/topp/CMakeLists.txt
Updated test wiring: added TOPP_ProteomicsLFQ_in_feat, TOPP_ProteomicsLFQ_in_feat_out, and a WILL_FAIL TOPP_ProteomicsLFQ_in_feat_mismatch to exercise -in_feat behavior; minor test invocation/format tweaks.
Test resources — FeatureXML
src/tests/topp/ProteomicsLFQ_in_feat_1.featureXML
New FeatureXML fixture with spectra refs, ProteinIdentification/PeptideIdentification entries and 43 features containing per-feature identifications to validate pre-computed feature loading and mapping.
Test resources — mzTab
src/tests/topp/ProteomicsLFQ_in_feat_out.mzTab
New expected mzTab output for in_feat tests, with detailed metadata, MS-run/assay mappings, protein/peptide/PSM sections and modification/score annotations for comparison.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant CLI as "CLI (ProteomicsLFQ)"
    participant Run as "ProteomicsLFQ::run"
    participant IDLoader as "loadAndCleanupIDFile_"
    participant Feature as "FeatureLoader / FeatureFinderIdentification"
    participant Quant as "quantifyFraction_"
    participant Consensus as "ConsensusMap builder"

    CLI->>Run: parse inputs (mzML list, id files, in_feat?, fixed/variable mods)
    Run->>IDLoader: load IDs (propagate fixed/variable mods)
    alt in_feat provided
        Run->>Feature: load FeatureXML(s) (validate MS run association)
    else
        Run->>Feature: run FeatureFinderIdentification (use mods)
    end
    Feature->>Quant: provide FeatureMap(s) + mods
    IDLoader->>Quant: provide Peptide/Protein IDs + mods
    Quant->>Consensus: build consensus (mods applied)
    Consensus->>Run: return ConsensusMap
Loading

Possibly related PRs

Suggested labels

Review effort 2/5

Suggested reviewers

  • jpfeuffer
  • timosachsenberg

Poem

🐇
I hop on features, old and new,
carry mods in my soft fur too.
IDs aligned, maps stitched tight,
consensus dawns in morning light.
A tiny leap — the results feel true.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new -in_feat parameter to ProteomicsLFQ to bypass internal feature finding.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

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

🧹 Nitpick comments (5)
src/topp/ProteomicsLFQ.cpp (5)

138-139: LGTM — minor style nit: missing space before StringList().

-    registerInputFileList_("in_feat", "<files>",StringList(), "Optional input featureXML files containing pre-computed features. Bypasses internal feature finding. Must match the number of '-in' files.", false, false);
+    registerInputFileList_("in_feat", "<files>", StringList(), "Optional input featureXML files containing pre-computed features. Bypasses internal feature finding. Must match the number of '-in' files.", false, false);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 138 - 139, The call to
registerInputFileList_ for the "in_feat" option is missing a space before the
StringList() argument; update the code in the registerInputFileList_ invocation
(identifier: registerInputFileList_, option name "in_feat") to add a space
before StringList() so it reads ... "<files>", StringList(), ... to match
project style.

908-914: Seed computation is always executed, even when it is unused in the in_feat path.

When in_feat_list is non-empty the else branch (FeatureFinderIdentification) is skipped, but the untargeted seeds (lines 909–913) have already been computed and stored in seeds — only to be discarded. Guard the seed calculation with the same condition:

♻️ Proposed fix
-      if (!targeted_only)
+      if (!targeted_only && in_feat_list.empty())
       {
         DDAWorkflowCommons::calculateSeeds(...);
         ...
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 908 - 914, The untargeted seed
computation (DDAWorkflowCommons::calculateSeeds) and debug store
(FileHandler().storeFeatures) are currently always run even when in_feat_list is
non-empty and the FeatureFinderIdentification path will be used; wrap the call
that fills seeds and the debug write in the same condition that gates the
FeatureFinderMetabo/untargeted path (i.e., only when in_feat_list is empty or
when the code would proceed to FeatureFinderMetabo), checking the in_feat_list
variable before calling DDAWorkflowCommons::calculateSeeds and the debug
FileHandler store so seeds are only computed/used when needed.

932-935: Use FileHandler instead of FeatureXMLFile directly, and replace size_t with Size.

Direct FeatureXMLFile::load bypasses the unified FileHandler abstraction (progress logging, format validation) that is used everywhere else in the tool. Additionally, size_t should be the OpenMS Size type per project conventions.

♻️ Proposed fix
-        size_t file_idx = std::distance(in_list.begin(), it);
+        Size file_idx = static_cast<Size>(std::distance(in_list.begin(), it));
 
-        FeatureXMLFile f_file;
-        f_file.load(in_feat_list[file_idx], fm);
+        FileHandler().loadFeatures(in_feat_list[file_idx], fm, {FileTypes::FEATUREXML}, log_type_);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 932 - 935, Replace the use of size_t
and direct FeatureXMLFile::load with the OpenMS abstractions: change variable
type file_idx from size_t to Size and obtain the index via std::distance as
before but cast/assign to Size; replace the direct FeatureXMLFile f_file;
f_file.load(in_feat_list[file_idx], fm); with using FileHandler to load the file
(e.g. use FileHandler::loadFile / a FileHandler instance to load
in_feat_list[file_idx] into the FeatureXMLFile object with the fm
File::FormatHandler) so progress logging and format validation are preserved
(refer to symbols file_idx, in_list, it, FeatureXMLFile, FileHandler,
in_feat_list, fm).

923-923: Prefer \n over std::endl in log output.

Per coding guidelines, std::endl flushes the stream and hurts performance; use \n instead. Applies to line 923 and line 964.

♻️ Proposed fix
-        OPENMS_LOG_INFO << "Bypassing FeatureFinderIdentification. Loading pre-computed features..." << std::endl;
+        OPENMS_LOG_INFO << "Bypassing FeatureFinderIdentification. Loading pre-computed features...\n";
-            OPENMS_LOG_INFO << "Adding offset peptides as quant. decoys." << std::endl;
+            OPENMS_LOG_INFO << "Adding offset peptides as quant. decoys.\n";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` at line 923, Replace the use of std::endl in the
logging statements with '\n' to avoid unnecessary stream flushes: locate the
OPENMS_LOG_INFO calls in ProteomicsLFQ.cpp that currently end with << std::endl
(e.g., the lines logging "Bypassing FeatureFinderIdentification. Loading
pre-computed features..." and the similar log at the other occurrence) and
change them to terminate with << '\n' instead so the messages keep the newline
without forcing a flush.

847-847: Use UInt instead of unsigned int in the pair signature, pending alignment with ExperimentalDesign::getFractionToMSFilesMapping() API.

The unsigned int key type here matches the current return type of ExperimentalDesign::getFractionToMSFilesMapping() (which returns std::map<unsigned int, std::vector<String>>), but per coding guidelines, OpenMS primitive types from OpenMS/CONCEPT/Types.h should be used instead. Both this parameter and the ExperimentalDesign API should be updated to use UInt for consistency with OpenMS conventions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` at line 847, Replace the use of built-in unsigned
int with OpenMS primitive UInt in the pair signature (change const pair<unsigned
int, std::vector<String> >& ms_files to use pair<UInt, std::vector<String>>&) in
ProteomicsLFQ (symbol: ms_files) and update the related ExperimentalDesign API
(ExperimentalDesign::getFractionToMSFilesMapping) to return std::map<UInt,
std::vector<String>> so the types align; also ensure Types.h
(OpenMS/CONCEPT/Types.h) is included where needed and update any downstream call
sites or typedefs that assume unsigned int to use UInt.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Line 434: The debug log call using writeDebug_("Using " + String() + " points
in fit.", 1) prints an empty count because String() constructs an empty string;
replace the String() placeholder with the actual data-point count from the
current transformation (e.g., use the transformation object's
size/getDataPointCount/getNTuples method converted to string, such as
std::to_string(transformation.getDataPointCount()) or equivalent). Locate the
writeDebug_ call in ProteomicsLFQ.cpp and wire it to the correct transformation
variable or method that returns the number of points so the message reads "Using
X points in fit." with the real count.
- Around line 1334-1343: Replace the inconsistent error handling for file-count
mismatches: remove the OPENMS_LOG_ERROR + return ILLEGAL_PARAMETERS for the
in_feat size check and instead throw an appropriate exception (e.g.,
Exception::InvalidParameter or Exception::IllegalArgument) with a clear message
referencing in_feat and in sizes; likewise change the in_ids size check to throw
the same exception type (do not use Exception::FileNotFound) and normalize the
messages so both checks report "Number of input <type> files must exactly match
number of input mzML files" (reference symbols: in_feat, in, in_ids,
OPENMS_LOG_ERROR, Exception::FileNotFound).
- Around line 944-945: Before calling setProteinIdentifications(protein_ids) and
setUnassignedPeptideIdentifications(peptide_ids) check the existing collections
on the FeatureMap (fm.getProteinIdentifications() and
fm.getUnassignedPeptideIdentifications()) and if either is non-empty emit a
clear warning via the file's logger (or standard warning facility) stating that
existing IDs will be overwritten; then proceed to call the setters. Ensure the
warning mentions which collection (protein or unassigned peptide) is non-empty
so users know what will be lost.
- Around line 919-935: getStringList_("in_feat") and getStringList_("in") are
being called inside the per-file loop (used with mz_file) which causes repeated
lookups and fragile string comparisons; hoist the calls out of the loop (e.g.,
read in_feat_list and in_list once in quantifyFraction_ or before the for
(String const & mz_file : ...) loop) and use the same path-normalization used
elsewhere (frac2ms or the normalization from main_) before comparing entries
with mz_file so std::find reliably matches; update references where
f_file.load(in_feat_list[file_idx], fm) is used to use the precomputed lists and
ensure file_idx calculation uses normalized paths.
- Around line 939-942: Fix the over-indentation and add a warning when an
existing primary MS run path differs from mz_file: adjust the block that checks
run_paths (the if (run_paths.empty()) { fm.setPrimaryMSRunPath({mz_file}); }) to
use 8-space indentation, and add a branch for the non-empty case that compares
run_paths[0] (or the existing primary path on fm) to mz_file and emits a warning
using the same logging pattern as loadAndCleanupIDFile_ if they differ (do not
silently overwrite). Keep the setPrimaryMSRunPath({mz_file}) behavior only for
the empty case and mirror the warning style and message structure used in
loadAndCleanupIDFile_.

---

Nitpick comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 138-139: The call to registerInputFileList_ for the "in_feat"
option is missing a space before the StringList() argument; update the code in
the registerInputFileList_ invocation (identifier: registerInputFileList_,
option name "in_feat") to add a space before StringList() so it reads ...
"<files>", StringList(), ... to match project style.
- Around line 908-914: The untargeted seed computation
(DDAWorkflowCommons::calculateSeeds) and debug store
(FileHandler().storeFeatures) are currently always run even when in_feat_list is
non-empty and the FeatureFinderIdentification path will be used; wrap the call
that fills seeds and the debug write in the same condition that gates the
FeatureFinderMetabo/untargeted path (i.e., only when in_feat_list is empty or
when the code would proceed to FeatureFinderMetabo), checking the in_feat_list
variable before calling DDAWorkflowCommons::calculateSeeds and the debug
FileHandler store so seeds are only computed/used when needed.
- Around line 932-935: Replace the use of size_t and direct FeatureXMLFile::load
with the OpenMS abstractions: change variable type file_idx from size_t to Size
and obtain the index via std::distance as before but cast/assign to Size;
replace the direct FeatureXMLFile f_file; f_file.load(in_feat_list[file_idx],
fm); with using FileHandler to load the file (e.g. use FileHandler::loadFile / a
FileHandler instance to load in_feat_list[file_idx] into the FeatureXMLFile
object with the fm File::FormatHandler) so progress logging and format
validation are preserved (refer to symbols file_idx, in_list, it,
FeatureXMLFile, FileHandler, in_feat_list, fm).
- Line 923: Replace the use of std::endl in the logging statements with '\n' to
avoid unnecessary stream flushes: locate the OPENMS_LOG_INFO calls in
ProteomicsLFQ.cpp that currently end with << std::endl (e.g., the lines logging
"Bypassing FeatureFinderIdentification. Loading pre-computed features..." and
the similar log at the other occurrence) and change them to terminate with <<
'\n' instead so the messages keep the newline without forcing a flush.
- Line 847: Replace the use of built-in unsigned int with OpenMS primitive UInt
in the pair signature (change const pair<unsigned int, std::vector<String> >&
ms_files to use pair<UInt, std::vector<String>>&) in ProteomicsLFQ (symbol:
ms_files) and update the related ExperimentalDesign API
(ExperimentalDesign::getFractionToMSFilesMapping) to return std::map<UInt,
std::vector<String>> so the types align; also ensure Types.h
(OpenMS/CONCEPT/Types.h) is included where needed and update any downstream call
sites or typedefs that assume unsigned int to use UInt.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55f9a70 and 40ebfe5.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp

Comment thread src/topp/ProteomicsLFQ.cpp Resolved
Comment thread src/topp/ProteomicsLFQ.cpp Resolved
Comment thread src/topp/ProteomicsLFQ.cpp Resolved
Comment thread src/topp/ProteomicsLFQ.cpp Resolved
@jpfeuffer

Copy link
Copy Markdown
Contributor

Thanks, I think this needs integration tests before we run CI. You can use the BSA featurexmls either from the test data or (maybe better) from running ProteomicsLFQ from the idXML files only (current test) with additional debug level to output the featureXMLs and then use those.

@jpfeuffer

Copy link
Copy Markdown
Contributor

Also please address the coderabbit comments

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

🧹 Nitpick comments (1)
src/topp/ProteomicsLFQ.cpp (1)

874-903: -in_feat mode still pays full mzML centroid/correction cost per run.

centroidAndCorrectPrecursors_ executes before the precomputed-feature branch check. For large cohorts, this can dominate runtime/memory and reduce the practical benefit of bypassing internal feature finding. Consider gating this path to only the cases where it is strictly needed (e.g., recalibration/metadata recovery/fallback FWHM estimation).

Based on learnings, be mindful of memory usage when processing large datasets.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 874 - 903, The code always calls
centroidAndCorrectPrecursors_(mz_file, ms_centroided) even when precomputed
features are used; change the control flow so centroidAndCorrectPrecursors_ is
only invoked when ms_centroided is actually needed (e.g., when
getStringOption_("mass_recalibration") == "true", when
SpectrumMetaDataLookup::addMissingFAIMSToPeptideIDs requires raw spectra, or
when DDAWorkflowCommons::estimateMedianChromatographicFWHM must run as a
fallback), otherwise skip it to avoid the full mzML centroid/correction cost;
move the centroidAndCorrectPrecursors_ call (and creation of ms_centroided) into
the conditional branches that call DDAWorkflowCommons::recalibrateMS1,
SpectrumMetaDataLookup::addMissingFAIMSToPeptideIDs, or
DDAWorkflowCommons::estimateMedianChromatographicFWHM, and ensure ms_centroided
is present only when those functions will be executed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 923-961: The new -in_feat branch (the in_feat_list handling in
ProteomicsLFQ.cpp) lacks integration tests to cover external feature loading and
its behaviors; add TOPP integration tests that exercise
FeatureFinderIdentification bypass using in_feat_list and verify:
FileHandler().loadFeatures loads the correct featureXML for the given mz_file
(matching via std::find on in_list), fm.getPrimaryMSRunPath is set when empty
and preserved (or logs a warning) when run path basename mismatches mz_file, and
that fm.setProteinIdentifications and fm.setUnassignedPeptideIdentifications
overwrite existing IDs (and produce the corresponding OPENMS_LOG_WARN messages).
Include at least: a happy-path test where run path is empty, a mismatch test
that asserts the warning message about run-path mismatch, and a test where
featureXML already contains protein/unassigned peptide IDs to assert overwrite
warnings and resulting IDs equal the provided protein_ids and peptide_ids.
- Around line 950-960: You overwrite map-level unassigned peptide IDs but leave
feature-level peptide IDs inconsistent; after calling
fm.setUnassignedPeptideIdentifications(peptide_ids) iterate all features in fm
(use FeatureMap fm) and for each Feature f use f.getPeptideIdentifications() and
call PeptideIdentification::setIdentifier to normalize/replace the feature-level
identifier with the corresponding map-level identifier from peptide_ids (use
fm.getUnassignedPeptideIdentifications() or the peptide_ids variable to find the
matching identifier by map index or clear it if no match). Ensure you use
Feature::getPeptideIdentifications and PeptideIdentification::setIdentifier so
downstream reference cleanup/inference sees the same IDs.
- Around line 1364-1370: Replace the incorrect Exception::FileNotFound uses with
Exception::InvalidParameter for the two validation blocks that reject
unsupported combinations of quantification_method and output options (the throws
that reference OPENMS_PRETTY_FUNCTION and messages about "MSstats export for
spectral counting data not supported..." and "Triqler export for spectral
counting data not supported..."); locate the throw sites by searching for
Exception::FileNotFound in ProteomicsLFQ.cpp around the checks that use
out_triqler and the quantification_method logic and change them to throw
Exception::InvalidParameter with the same arguments and message.

---

Nitpick comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 874-903: The code always calls
centroidAndCorrectPrecursors_(mz_file, ms_centroided) even when precomputed
features are used; change the control flow so centroidAndCorrectPrecursors_ is
only invoked when ms_centroided is actually needed (e.g., when
getStringOption_("mass_recalibration") == "true", when
SpectrumMetaDataLookup::addMissingFAIMSToPeptideIDs requires raw spectra, or
when DDAWorkflowCommons::estimateMedianChromatographicFWHM must run as a
fallback), otherwise skip it to avoid the full mzML centroid/correction cost;
move the centroidAndCorrectPrecursors_ call (and creation of ms_centroided) into
the conditional branches that call DDAWorkflowCommons::recalibrateMS1,
SpectrumMetaDataLookup::addMissingFAIMSToPeptideIDs, or
DDAWorkflowCommons::estimateMedianChromatographicFWHM, and ensure ms_centroided
is present only when those functions will be executed.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40ebfe5 and 1013a07.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp

Comment on lines +923 to +961
if (!in_feat_list.empty())
{
OPENMS_LOG_INFO << "Adding offset peptides as quant. decoys." << std::endl;
ffi_param.setValue("add_mass_offset_peptides", 10.005); // create mass offset peptides (aka quant. decoys). Uses same value as SAGE.
}
OPENMS_LOG_INFO << "Bypassing FeatureFinderIdentification. Loading pre-computed features...\n";

ffi.setParameters(ffi_param);
writeDebug_("Parameters passed to FeatureFinderIdentification algorithm", ffi_param, 3);
auto it = std::find(in_list.begin(), in_list.end(), mz_file);
if (it == in_list.end())
{
throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Current mzML file not found in the -in list.");
}
Size file_idx = static_cast<Size>(std::distance(in_list.begin(), it));

FeatureMap fm;
FileHandler().loadFeatures(in_feat_list[file_idx], fm, {FileTypes::FEATUREXML}, log_type_);

{
// These containers must be empty because we may be using
// seeds. The variables are not used by this code but
// required by the `run` call.
vector<ProteinIdentification> ext_protein_ids;
PeptideIdentificationList ext_peptide_ids;

ffi.run(peptide_ids,
protein_ids,
ext_peptide_ids,
ext_protein_ids,
fm, // fills fm
seeds,
mz_file);
}
StringList run_paths;
fm.getPrimaryMSRunPath(run_paths);
if (run_paths.empty())
{
fm.setPrimaryMSRunPath({mz_file});
}
else if (FileHandler::stripExtension(File::basename(run_paths[0])) !=
FileHandler::stripExtension(File::basename(mz_file)))
{
OPENMS_LOG_WARN << "Primary MS run path in featureXML (" << run_paths[0]
<< ") does not match the mzML at the same position (" << mz_file
<< "). Keeping featureXML annotation.\n";
}

if (!fm.getProteinIdentifications().empty())
{
OPENMS_LOG_WARN << "Warning: Loaded featureXML already contains protein identifications. They will be overwritten.\n";
}
fm.setProteinIdentifications(protein_ids);

if (filter_by_quant_scores)
if (!fm.getUnassignedPeptideIdentifications().empty())
{
OPENMS_LOG_WARN << "Warning: Loaded featureXML already contains unassigned peptide identifications. They will be overwritten.\n";
}
fm.setUnassignedPeptideIdentifications(peptide_ids);
}

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.

⚠️ Potential issue | 🟠 Major

Please add integration coverage for the new -in_feat execution path.

This branch now owns critical behavior (external feature loading, run-path handling, ID overwrite/warnings), but it needs dedicated integration assertions to prevent regressions.

I can draft a minimal TOPP integration test matrix for this branch (happy-path + mismatch/warning cases) if you want.
As per coding guidelines, “Always run and extend tests when making code changes; do not skip tests.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 923 - 961, The new -in_feat branch
(the in_feat_list handling in ProteomicsLFQ.cpp) lacks integration tests to
cover external feature loading and its behaviors; add TOPP integration tests
that exercise FeatureFinderIdentification bypass using in_feat_list and verify:
FileHandler().loadFeatures loads the correct featureXML for the given mz_file
(matching via std::find on in_list), fm.getPrimaryMSRunPath is set when empty
and preserved (or logs a warning) when run path basename mismatches mz_file, and
that fm.setProteinIdentifications and fm.setUnassignedPeptideIdentifications
overwrite existing IDs (and produce the corresponding OPENMS_LOG_WARN messages).
Include at least: a happy-path test where run path is empty, a mismatch test
that asserts the warning message about run-path mismatch, and a test where
featureXML already contains protein/unassigned peptide IDs to assert overwrite
warnings and resulting IDs equal the provided protein_ids and peptide_ids.

Comment thread src/topp/ProteomicsLFQ.cpp Resolved
Comment thread src/topp/ProteomicsLFQ.cpp Resolved

@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

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

923-987: ⚠️ Potential issue | 🟠 Major

Please add integration tests for the new -in_feat execution path before merge.

This branch now owns critical behavior (featureXML mapping, run-path handling, ID overwrite warnings, feature-level identifier normalization), and it should be covered in TOPP integration tests.

As per coding guidelines, “Always run and extend tests when making code changes; do not skip tests.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 923 - 987, Add TOPP integration
tests exercising the new -in_feat path in ProteomicsLFQ: create a test that runs
the ProteomicsLFQ executable with -in and -in_feat inputs and asserts that
FileHandler().loadFeatures correctly loads the featureXML into FeatureMap fm,
that fm.getPrimaryMSRunPath is set or preserved according to the mzML basename
logic, that setProteinIdentifications and setUnassignedPeptideIdentifications
actually replace existing IDs, and that the feature-level peptide identifier
normalization loop (use expected_identifier and updated_feature_pid_ids) updates
identifiers when they differ; include assertions for the OPENMS_LOG_WARN
messages about mismatched run paths and overwritten IDs and for the updated
count so test covers all branches.
🧹 Nitpick comments (1)
src/topp/ProteomicsLFQ.cpp (1)

826-843: Prefer OpenMS logging macros over std::cout/std::endl in this TOPP source.

This helper still writes directly to stdout; switch to OpenMS logging (OPENMS_LOG_INFO / writeDebug_) for consistent tool logging behavior.

As per coding guidelines, “Use OpenMS logging macros and OpenMS::LogStream instead of std::cout and std::cerr directly.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 826 - 843, Replace direct stdout
usage in the loop that prints keys and tmp entries (currently using std::cout
and std::endl) with OpenMS logging macros: use OPENMS_LOG_INFO (or writeDebug_
if meant to be verbose debug output) to emit the header and each row; for values
retrieved via f.getMetaValue(k) and the OffsetPeptide check
(f.metaValueExists("OffsetPeptide")), format the string first and pass it to
OPENMS_LOG_INFO (or writeDebug_) instead of printing with std::cout/std::endl,
and remove any remaining std::endl usages to ensure consistent OpenMS logging
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 816-821: The function printMetaValues accesses tmp[0] without
checking for an empty FeatureMap, which can cause an out-of-bounds crash; update
printMetaValues to first guard against an empty tmp (e.g., return early if
tmp.empty()) before calling tmp[0], then proceed to extract keys and the
OffsetPeptide check as before so all subsequent uses (tmp[0], getKeys, find) are
safe.
- Around line 885-902: The code currently forces MS
loading/centroiding/recalibration whenever
getStringOption_("mass_recalibration") == "true" even when quantitation features
are supplied via in_feat_list, causing unnecessary memory/CPU use; change the
requires_ms_data condition so MS processing (the block calling
centroidAndCorrectPrecursors_,
SpectrumMetaDataLookup::addMissingFAIMSToPeptideIDs,
DDAWorkflowCommons::recalibrateMS1 and estimateMedianChromatographicFWHM) runs
only if in_feat_list is empty OR some other true dependency requires MS data,
i.e. skip MS loading/recalibration when in_feat_list is non-empty even if
mass_recalibration is true; update the same logic in the similar block around
DDAWorkflowCommons usage (lines noted) so both places reference in_feat_list and
getStringOption_("mass_recalibration") consistently.

---

Duplicate comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 923-987: Add TOPP integration tests exercising the new -in_feat
path in ProteomicsLFQ: create a test that runs the ProteomicsLFQ executable with
-in and -in_feat inputs and asserts that FileHandler().loadFeatures correctly
loads the featureXML into FeatureMap fm, that fm.getPrimaryMSRunPath is set or
preserved according to the mzML basename logic, that setProteinIdentifications
and setUnassignedPeptideIdentifications actually replace existing IDs, and that
the feature-level peptide identifier normalization loop (use expected_identifier
and updated_feature_pid_ids) updates identifiers when they differ; include
assertions for the OPENMS_LOG_WARN messages about mismatched run paths and
overwritten IDs and for the updated count so test covers all branches.

---

Nitpick comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 826-843: Replace direct stdout usage in the loop that prints keys
and tmp entries (currently using std::cout and std::endl) with OpenMS logging
macros: use OPENMS_LOG_INFO (or writeDebug_ if meant to be verbose debug output)
to emit the header and each row; for values retrieved via f.getMetaValue(k) and
the OffsetPeptide check (f.metaValueExists("OffsetPeptide")), format the string
first and pass it to OPENMS_LOG_INFO (or writeDebug_) instead of printing with
std::cout/std::endl, and remove any remaining std::endl usages to ensure
consistent OpenMS logging behavior.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1013a07 and 17d0848.

📒 Files selected for processing (1)
  • src/topp/ProteomicsLFQ.cpp

Comment thread src/topp/ProteomicsLFQ.cpp Resolved
Comment thread src/topp/ProteomicsLFQ.cpp Resolved

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

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

816-821: ⚠️ Potential issue | 🟠 Major

Guard printMetaValues against empty FeatureMap.

tmp[0] is still accessed without an empty() check, which can crash on empty input.

💡 Proposed fix
 void printMetaValues(const FeatureMap& tmp)
 {
+  if (tmp.empty())
+  {
+    OPENMS_LOG_WARN << "printMetaValues called with empty FeatureMap.\n";
+    return;
+  }
   // extract meta value keys from the first element (which might be a normal or OffsetPeptide -> extract only the common ones)
   std::vector<String> keys;
   tmp[0].getKeys(keys);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 816 - 821, The function
printMetaValues accesses tmp[0] without checking for an empty FeatureMap, which
can crash; add an early guard in printMetaValues that checks if tmp.empty() (or
tmp.size() == 0) and returns (or handles the empty case) before any access to
tmp[0], and keep the subsequent logic (key extraction, OffsetPeptide handling)
unchanged so it only runs for non-empty tmp.

885-901: ⚠️ Potential issue | 🟠 Major

-in_feat + mass_recalibration=true still performs expensive mzML processing with no impact on precomputed features.

In this branch, mzML loading/centroiding/recalibration is triggered despite bypassing internal feature finding, which adds significant runtime/memory cost. Please reject this combination or skip recalibration when in_feat is used.

♻️ Proposed fix
-      MSExperiment ms_centroided;
-      bool requires_ms_data = in_feat_list.empty() || (getStringOption_("mass_recalibration") == "true");
+      MSExperiment ms_centroided;
+      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 requires_ms_data = in_feat_list.empty();
@@
-        if (getStringOption_("mass_recalibration") == "true")
+        if (mass_recalibration)
         {
           String debug_output_basename = (debug_level_ > 666) ? id_file_abs_path : "";
           DDAWorkflowCommons::recalibrateMS1(ms_centroided, peptide_ids, debug_output_basename);
         }
Based on learnings: "Be mindful of memory usage when processing large datasets."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 885 - 901, The code currently forces
mzML loading/centroiding/recalibration when requires_ms_data is true even if
precomputed features are provided (in_feat_list non-empty) and
mass_recalibration is enabled; change behavior to either (A) reject the
unsupported combination by validating at start of run and returning a clear
error when in_feat_list is non-empty and getStringOption_("mass_recalibration")
== "true", or (B) skip MS processing and only run
centroidAndCorrectPrecursors_/DDAWorkflowCommons::recalibrateMS1 when
peptide-level MS data is required—i.e., update the logic around
requires_ms_data, centroidAndCorrectPrecursors_, and the block that calls
DDAWorkflowCommons::recalibrateMS1 to avoid doing expensive mzML work when
in_feat_list is provided (choose one policy and implement the check+early return
or conditionally bypass recalibration).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/tests/topp/CMakeLists.txt`:
- Around line 2948-2953: Add a negative test that exercises the new guard by
calling ProteomicsLFQ with mismatched counts of -in vs -in_feat (e.g., one
-in_feat but multiple -in) and assert it fails: create a new add_test named
"TOPP_ProteomicsLFQ_in_feat_mismatch" that runs ${TOPP_BIN_PATH}/ProteomicsLFQ
with the same inputs used in "TOPP_ProteomicsLFQ_in_feat" but deliberately
mismatched -in/-in_feat cardinality, then set the test property WILL_FAIL TRUE
(or mark it to expect a non-zero exit) so the CTest will catch regressions if
the mismatch stops producing an error; also optionally add DEPENDS to ensure
ordering if needed.

In `@src/tests/topp/ProteomicsLFQ_in_feat_1.featureXML`:
- Line 3: The UserParam entry for spectra_data contains a hardcoded absolute
local path; update the UserParam with name="spectra_data" to use a test-stable
reference (e.g., a relative path, basename-only filename, or a fixture variable)
instead of the full /Users/... path so the fixture is portable and does not leak
local environment details; locate the UserParam element in
ProteomicsLFQ_in_feat_1.featureXML (the spectra_data value attribute) and
replace the absolute path with the project test fixture path or just the
filename used by tests.

In `@src/tests/topp/ProteomicsLFQ_in_feat_out.mzTab`:
- Line 34: The committed test artifact contains a machine-specific absolute path
in the mzTab metadata key "MTD	ms_run[1]-location"; remove the local user path
and replace it with a repo-stable reference (e.g., a relative repo path like
"file://share/OpenMS/examples/FRACTIONS/BSA1_F1.mzML", a basename
"file://BSA1_F1.mzML", or a test-data placeholder such as
"file://{TEST_DATA_DIR}/BSA1_F1.mzML") so the fixture is portable across dev
machines and CI.

---

Duplicate comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 816-821: The function printMetaValues accesses tmp[0] without
checking for an empty FeatureMap, which can crash; add an early guard in
printMetaValues that checks if tmp.empty() (or tmp.size() == 0) and returns (or
handles the empty case) before any access to tmp[0], and keep the subsequent
logic (key extraction, OffsetPeptide handling) unchanged so it only runs for
non-empty tmp.
- Around line 885-901: The code currently forces mzML
loading/centroiding/recalibration when requires_ms_data is true even if
precomputed features are provided (in_feat_list non-empty) and
mass_recalibration is enabled; change behavior to either (A) reject the
unsupported combination by validating at start of run and returning a clear
error when in_feat_list is non-empty and getStringOption_("mass_recalibration")
== "true", or (B) skip MS processing and only run
centroidAndCorrectPrecursors_/DDAWorkflowCommons::recalibrateMS1 when
peptide-level MS data is required—i.e., update the logic around
requires_ms_data, centroidAndCorrectPrecursors_, and the block that calls
DDAWorkflowCommons::recalibrateMS1 to avoid doing expensive mzML work when
in_feat_list is provided (choose one policy and implement the check+early return
or conditionally bypass recalibration).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17d0848 and b59ca17.

📒 Files selected for processing (4)
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteomicsLFQ_in_feat_1.featureXML
  • src/tests/topp/ProteomicsLFQ_in_feat_out.mzTab
  • src/topp/ProteomicsLFQ.cpp

Comment thread src/tests/topp/CMakeLists.txt Resolved

@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 the current code and only fix it if needed.

Inline comments:
In `@src/topp/ProteomicsLFQ.cpp`:
- Around line 1384-1394: The code currently allows supplying -in_feat while
using quantification_method=spectral_counting, but features are only used for
feature_intensity via quantifyFraction_, so add an explicit incompatibility
guard immediately after the existing in_feat/in size check: if in_feat is
non-empty and quantification_method equals "spectral_counting" (or the
enum/constant used for spectral counting), throw an Exception::InvalidParameter
with a message mirroring the existing guards (e.g. "Pre-computed feature files
(-in_feat) cannot be used with quantification_method=spectral_counting"); follow
the same style as the -mass_recalibration + -in_feat check already in the file
so the behavior is consistent.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b59ca17 and d007452.

📒 Files selected for processing (4)
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteomicsLFQ_in_feat_1.featureXML
  • src/tests/topp/ProteomicsLFQ_in_feat_out.mzTab
  • src/topp/ProteomicsLFQ.cpp
✅ Files skipped from review due to trivial changes (1)
  • src/tests/topp/ProteomicsLFQ_in_feat_out.mzTab
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/topp/CMakeLists.txt

Comment on lines +1384 to 1394
if (!in_feat.empty() && in_feat.size() != in.size())
{
throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Number of featureXML files (-in_feat, " + String(in_feat.size()) +
") must match number of mzML files (-in, " + String(in.size()) + ").");
}
if (in.size() != in_ids.size())
{
throw Exception::FileNotFound(__FILE__, __LINE__,
OPENMS_PRETTY_FUNCTION, "Number of spectra file (" + String(in.size()) + ") must match number of ID files (" + String(in_ids.size()) + ").");
throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Number of spectra files (" + String(in.size()) + ") must match number of ID files (" + String(in_ids.size()) + ").");
}

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.

⚠️ Potential issue | 🟠 Major

-in_feat is silently ignored when quantification_method=spectral_counting.

The count-mismatch guard at lines 1384–1389 fires regardless of quantification method, but the in_feat list is only consumed inside quantifyFraction_, which is only called in the feature_intensity branch (line 1534). A user who passes both -in_feat and quantification_method=spectral_counting gets no error or warning; the pre-computed features are silently discarded.

Add an explicit incompatibility check immediately after the existing size-mismatch guard, consistent with the -mass_recalibration + -in_feat guard pattern already used at lines 888–892:

🐛 Proposed fix
     if (!in_feat.empty() && in_feat.size() != in.size())
     {
       throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
         "Number of featureXML files (-in_feat, " + String(in_feat.size()) +
         ") must match number of mzML files (-in, " + String(in.size()) + ").");
     }
+    if (!in_feat.empty() && getStringOption_("quantification_method") == "spectral_counting")
+    {
+      throw Exception::InvalidParameter(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
+        "Option '-in_feat' is not supported with 'spectral_counting' quantification because "
+        "pre-computed features are not used in that path.");
+    }
     if (in.size() != in_ids.size())
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/topp/ProteomicsLFQ.cpp` around lines 1384 - 1394, The code currently
allows supplying -in_feat while using quantification_method=spectral_counting,
but features are only used for feature_intensity via quantifyFraction_, so add
an explicit incompatibility guard immediately after the existing in_feat/in size
check: if in_feat is non-empty and quantification_method equals
"spectral_counting" (or the enum/constant used for spectral counting), throw an
Exception::InvalidParameter with a message mirroring the existing guards (e.g.
"Pre-computed feature files (-in_feat) cannot be used with
quantification_method=spectral_counting"); follow the same style as the
-mass_recalibration + -in_feat check already in the file so the behavior is
consistent.

@satyam102006

Copy link
Copy Markdown
Contributor Author

@jpfeuffer can you check ?

@jpfeuffer

Copy link
Copy Markdown
Contributor

Yes. Let's also await CI.

First thing I noticed: The test is nice but could you extend it to two input files please? Otherwise the coverage of internal code is limited.

@satyam102006

Copy link
Copy Markdown
Contributor Author

sure

@satyam102006

Copy link
Copy Markdown
Contributor Author

@jpfeuffer i commit the changes

@satyam102006

Copy link
Copy Markdown
Contributor Author

@jpfeuffer can please rerun the job [build-and-test (windows-2025, cl.exe, 14.44)]

@satyam102006

Copy link
Copy Markdown
Contributor Author

@jpfeuffer do you have any other issues you'd recommend for me to look into?

@jpfeuffer

Copy link
Copy Markdown
Contributor

Personally I'm looking forward to #8748 but it is advanced with additional dependencies and some rewquired mass spec knowledge. Although a prototype might already be interesting.

Some other PRs that are stale and could be finished #7969 #8671

@timosachsenberg
timosachsenberg merged commit 9036141 into OpenMS:develop Mar 2, 2026
11 checks passed
@FreezB11

FreezB11 commented Jun 2, 2026

Copy link
Copy Markdown

Personally I'm looking forward to #8748 but it is advanced with additional dependencies and some rewquired mass spec knowledge. Although a prototype might already be interesting.

Some other PRs that are stale and could be finished #7969 #8671

#7969 I worked on it, u can check the code please let me, I also requested for some assistance on the discord but I didn't get any

timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 7, 2026
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 added a commit that referenced this pull request Aug 8, 2026
* [FIX,TEST] ProteomicsLFQ -in_feat: stop duplicating every feature-attached PSM (#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

* [FEATURE,TEST] ProteomicsLFQ: add -out_feat to split feature detection 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

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

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
(#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 (#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 #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

---------

Co-authored-by: Claude Opus 5 (1M context) <[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.

4 participants