Repository navigation
fix(ProSE): per-file output isolation + dangling decoy refs (#9197 items 1a/1b) - #9205
Conversation
Fixes 'Invalid protein reference DECOY_...' crash when merged path runs applyPickedProteinFDR (deletes decoy ProteinHits) and target+decoy PSMs remain (kept by removeDecoyHits's exact-match check on target_decoy=='decoy'). Refs OpenMS#9197 item 1b. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…catch Fixes data loss on merged-write failure: previously a merged-write exception aborted main_ and discarded per-file outputs even when per-file PSMs were already complete in memory. Per-file writes now complete first and the merged write is wrapped in try/catch so its failure becomes a logged error rather than a terminal exception. Refs OpenMS#9197 item 1a.
Don't claim per-file outputs were 'written successfully' — input_failed may be true for one or more files. Direct user to check per-file errors above.
📝 WalkthroughWalkthroughCHANGELOG is updated with two ProSE output fixes. ProSE.cpp is refactored to wrap merged-IDXML writing in exception handling and reorder operations to ensure per-file outputs are written before merged output, plus add a cleanup pass to remove dangling protein references after decoy/protein cleanup. Changes
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/topp/ProSE.cpp (1)
665-667: Use\nfor new log messages.These new log statements use
endl, which flushes unnecessarily.♻️ Proposed cleanup
- << user_protein_fdr * 100 << "% FDR" << endl; + << user_protein_fdr * 100 << "% FDR\n"; ... - OPENMS_LOG_WARN << "-out_merged is only useful with multiple -in files. Skipping merged output." << endl; + OPENMS_LOG_WARN << "-out_merged is only useful with multiple -in files. Skipping merged output.\n";As per coding guidelines,
**/*.{cpp,cxx,cc}: Avoidstd::endlfor performance; prefer\n.Also applies to: 696-698
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/ProSE.cpp` around lines 665 - 667, Replace usages of std::endl in the ProSE logging lines with '\n' to avoid unnecessary flushes: update the OPENMS_LOG_INFO statements that print merged protein/FDR messages (e.g., the line building "[ProSE] Merged protein inference + FDR: " using merged_protein_ids[0].getHits().size() and user_protein_fdr) and the similar logging block at the later occurrence (around the other OPENMS_LOG_INFO that spans lines ~696-698) to use '\n' instead of endl.
🤖 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/ProSE.cpp`:
- Around line 686-694: Detect and record the merged idXML write failure by
setting a boolean failure flag (e.g., bool merged_write_failed = true) inside
the catch block that handles Exception::BaseException for
FileHandler().storeIdentifications(out_merged, ...), and ensure the routine that
computes the final exit status checks this flag so it returns INTERNAL_ERROR
instead of EXECUTION_OK when merged_write_failed is true; also update the final
merged-output message logic to reflect that the merged file was not created when
the flag is set.
---
Nitpick comments:
In `@src/topp/ProSE.cpp`:
- Around line 665-667: Replace usages of std::endl in the ProSE logging lines
with '\n' to avoid unnecessary flushes: update the OPENMS_LOG_INFO statements
that print merged protein/FDR messages (e.g., the line building "[ProSE] Merged
protein inference + FDR: " using merged_protein_ids[0].getHits().size() and
user_protein_fdr) and the similar logging block at the later occurrence (around
the other OPENMS_LOG_INFO that spans lines ~696-698) to use '\n' instead of
endl.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e30f28c8-04bb-4dba-9af4-3094b07ac402
📒 Files selected for processing (2)
CHANGELOGsrc/topp/ProSE.cpp
| FileHandler().storeIdentifications(out_merged, merged_protein_ids, merged_peptides, {FileTypes::IDXML}); | ||
| } | ||
| catch (const Exception::BaseException& e) | ||
| { | ||
| OPENMS_LOG_ERROR << "Failed to write merged idXML output -> " << out_merged | ||
| << ": " << e.what() | ||
| << ". Per-file outputs were written (check above for any per-file errors)." << endl; | ||
| // Do NOT propagate; per-file outputs are already on disk. | ||
| } |
There was a problem hiding this comment.
Mark merged idXML failure in the final exit status.
The catch preserves per-file outputs, but it also lets ProSE return EXECUTION_OK when the requested -out_merged file was not generated. Set a failure flag here and let the existing final status handling return INTERNAL_ERROR.
🐛 Proposed fix
- FileHandler().storeIdentifications(out_merged, merged_protein_ids, merged_peptides, {FileTypes::IDXML});
+ FileHandler().storeIdentifications(out_merged, merged_protein_ids, merged_peptides, {FileTypes::IDXML});
}
catch (const Exception::BaseException& e)
{
- OPENMS_LOG_ERROR << "Failed to write merged idXML output -> " << out_merged
+ merged_ok = false;
+ OPENMS_LOG_ERROR << "Failed to generate/write merged idXML output -> " << out_merged
<< ": " << e.what()
- << ". Per-file outputs were written (check above for any per-file errors)." << endl;
+ << ". Per-file output attempts have already completed; check above for any per-file errors.\n";
// Do NOT propagate; per-file outputs are already on disk.
}Also update the final merged-output message:
- OPENMS_LOG_ERROR << "ProSE failed to write one or more merged Parquet files." << endl;
+ OPENMS_LOG_ERROR << "ProSE failed to write one or more merged output files.\n";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/topp/ProSE.cpp` around lines 686 - 694, Detect and record the merged
idXML write failure by setting a boolean failure flag (e.g., bool
merged_write_failed = true) inside the catch block that handles
Exception::BaseException for FileHandler().storeIdentifications(out_merged,
...), and ensure the routine that computes the final exit status checks this
flag so it returns INTERNAL_ERROR instead of EXECUTION_OK when
merged_write_failed is true; also update the final merged-output message logic
to reflect that the merged file was not created when the flag is set.
|
@jpfeuffer can you take a quick look at 1b |
|
Yes. Same as always. You could filter pre merging then you have 50% less to merge. |
|
Ah but not if you do FDR on the merge |
Restore ProSE/FragmentIndex/File entries dropped by the FeatureFinderCentroided reorganization commit (#9159) and add new entries for commits merged after the last sync: - #9188: ProSE BREAKING: default isotope error range changed to [0,+2] - #9191: ProSE SNES mother-peptide indexing for non-specific searches - #9195: ProSE fix: defer PSM FDR when Percolator enabled; valid .pin output - #9203: FragmentIndex: fixed bucket_size 4096 for tighter candidate lists - #9204: ProSE: resolve PercolatorAdapter via findSiblingTOPPExecutable - #9205: ProSE: per-file output isolation + dangling decoy ref crash fix - #9207: File::rename: cross-device fallback (copy+remove on EXDEV) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Fixes items 1a and 1b of #9197. Items 3 + 4 (FDR:PSM deferral, valid .pin) were already handled by #9195.
Summary
-out_mergedwrite failure no longer discards per-file outputs. Per-file-out_idxml/-out_pin/-out_qpx/-out_parquetwrites complete first; the merged write moved AFTER the per-file loop and is wrapped intry/catchso its failure becomes a logged error (with a reference to the per-file output errors logged above) rather than a terminal exception.PeptideEvidence: merged idXML write no longer crashes withInvalid protein reference 'DECOY_...'whentarget+decoyshared peptides are present andFDR:protein > 0. Root cause:applyPickedProteinFDRdeletes decoyProteinHits whileremoveDecoyHitskeepstarget+decoyPSMs (whosetarget_decoymeta istarget+decoy, notdecoy). Those kept PSMs retainPeptideEvidenceentries pointing at deleted decoy proteins. Fix: one call toIDFilter::removeDanglingProteinReferencesafter the existing decoy/protein cleanup.Test Plan
TOPP_ProSE_*topp tests pass on the rebased branch (no fixture exercisestarget+decoy + FDR:protein > 0, so existing tests are no-op for the new code paths)FDR:protein > 0, decoys present, sharedtarget+decoypeptides — verify (a) per-file outputs land on disk regardless of merged-write outcome and (b) merged write succeeds (no dangling-ref crash)Notes
This PR supersedes #9201 (closed). #9201 originally bundled a 4-item fix including FDR:PSM deferral and an
-out_pinBREAKING change; #9195 has since merged with a different (better) approach for those, leaving only items 1a + 1b in scope here.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes