Repository navigation
feat(PeptideDataBaseSearchFI): multi-file search with shared fragment index - #9109
Conversation
… index Allow PeptideDataBaseSearchFI to process multiple mzML files against the same FASTA in one invocation, building the FragmentIndex once and reusing it across all input files. Per-file output is written as either idXML or QPX PSM parquet, auto-detected from each -out entry's extension; mixed formats within one run are allowed. Algorithm: - New SearchContext (decoy-augmented db + built FragmentIndex) and prepareContext() extracted from the existing search() body. - New search(spectra, ctx, ...) overload reusing a pre-built context. - New MultiFileSearchResult and two file-list searchWithModificationAnalysis overloads producing per-file SearchResults plus an aggregate analysis on pooled PSMs. Single-file fast-path skips the redundant aggregate. - Existing single-file search() and file-based searchWithModificationAnalysis refactored into thin wrappers; behavior preserved (all 10 pre-existing tests pass byte-identically). Tool: - -in/-out are now lists; per-file extension dispatch to idXML or parquet. - New advanced -out_mod_analysis_dir writes per-file (basename-stemmed) and aggregate modification-analysis TSVs. Tests: - Class test: prepareContext + context-search equivalence to single-shot search; multi-file overload validation (length mismatch, empty list). - TOPP_PeptideDataBaseSearchFI_3_multi: two mzML inputs with idXML + parquet outputs (idXML diffed against existing _1 reference, parquet smoke-tested via cmake -E sha256sum). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Reviewer feedback on commit 9d83fb5: Algorithm: - searchWithModificationAnalysis (multi-file): when all per-file runs fail, propagate the first non-OK per-file exit code into aggregate.exit_code instead of unconditionally setting UNEXPECTED_RESULT (which has a specific PeptideIndexing-failure meaning). - Single-file fast path: skip the wasted aggregate deep-copy (per_file[0] was being copied into aggregate just so the single-file file-based wrapper could discard it). Aggregate is now left almost-empty (is_open_search + exit_code only) when the input list has one entry; callers should use per_file[0]. Documented on MultiFileSearchResult. - Demote per-scan top-hit log line in postProcessHits_ from INFO to DEBUG (multi-file mode would otherwise emit one line per scan per input). TOPP tool: - -out_mod_analysis_dir now uses registerOutputDir_ + getOutputDirOption (was registerOutputPrefix_): the parameter is semantically a directory and getOutputDirOption auto-creates it. Pattern: ProteomicsLFQ.cpp:196. - Pre-flight validate every -out file extension before starting the search (registerOutputFileList_ does NOT validate per-entry formats at the CLI layer). - Detect basename collisions in -out_mod_analysis_dir: refuse to run when two -in files share a File::stemName, or when an input collides with the reserved aggregate stem. Aggregate stem changed from "aggregate" to "_aggregate_across_files" to make accidental collisions extremely unlikely. - Warn explicitly when -out_mod_analysis_dir is set in closed-search mode (precursor tolerance <= 1 Da / 1000 ppm). The algorithm already logs a per-file skip notice; the tool now also tells the user up front. - Replace any_failure bool with failed_count and emit a final summary log line ("N file(s) failing out of M") before returning INTERNAL_ERROR, so batch failures are visible at a glance. All 13 PeptideDataBaseSearchFI / PeptideSearchEngineFIAlgorithm tests still pass byte-identically. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds multi-file batch search support to PeptideSearchEngineFIAlgorithm: introduces a SearchContext to cache decoy-augmented FASTA and a prebuilt FragmentIndex, new multi-file searchWithModificationAnalysis overloads that produce per-file and pooled aggregate modification analysis, and updates the TOPP tool for multi-input/multi-output handling and parquet output. Changes
Sequence DiagramsequenceDiagram
rect rgba(220,230,241,0.5)
participant Tool as TOPP<br/>PeptideDataBaseSearchFI
participant SE as PeptideSearchEngineFIAlgorithm
participant Ctx as SearchContext
participant FI as FragmentIndex
participant ModA as ModificationAnalysis
end
Tool->>SE: prepareContext(fasta_db)
activate SE
SE->>SE: generate decoys (if enabled)
SE->>FI: build FragmentIndex
FI-->>SE: index
SE-->>Ctx: return SearchContext{db, index}
deactivate SE
loop for each spectrum file
Tool->>SE: search(spectra_i, Ctx, ...)
activate SE
SE->>FI: reuse FragmentIndex
SE-->>Tool: per-file SearchResult_i
deactivate SE
end
Tool->>SE: pool PSMs from successful runs
activate SE
SE->>ModA: run aggregate modification analysis on pooled PSMs
ModA-->>SE: aggregate modification results
SE-->>Tool: MultiFileSearchResult{per_file[], aggregate}
deactivate SE
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
🧹 Nitpick comments (1)
src/tests/topp/CMakeLists.txt (1)
2926-2932: Assert parquet semantics here, not just path existence.
cmake -E sha256sumonly proves that something was written to the.parquetpath. A regression in the new per-file format dispatch could still write the wrong payload there and this test would pass, especially since both-inentries use the same mzML. Please replace this with a semantic check (for example, parquet magic bytes or a read-back step) so the mixed-output path is actually covered.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/topp/CMakeLists.txt` around lines 2926 - 2932, Replace the current content-only existence check for the parquet output ("TOPP_PeptideDataBaseSearchFI_3_multi_parquet_out" which currently invokes ${CMAKE_COMMAND} -E sha256sum on ${TESTS_TEMP_DIR}/PeptideDataBaseSearchFI_3_multi_b.tmp.parquet) with a semantic validation: read the file and assert parquet magic bytes (\"PAR1\" header/footer) or perform a minimal read-back (e.g., call a small parquet-inspection tool or a TOPP utility that can open parquet) and verify expected schema/column names or row count; update the test command to run that validation and keep the DEPENDS property intact for "TOPP_PeptideDataBaseSearchFI_3_multi".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/tests/topp/CMakeLists.txt`:
- Around line 2926-2932: Replace the current content-only existence check for
the parquet output ("TOPP_PeptideDataBaseSearchFI_3_multi_parquet_out" which
currently invokes ${CMAKE_COMMAND} -E sha256sum on
${TESTS_TEMP_DIR}/PeptideDataBaseSearchFI_3_multi_b.tmp.parquet) with a semantic
validation: read the file and assert parquet magic bytes (\"PAR1\"
header/footer) or perform a minimal read-back (e.g., call a small
parquet-inspection tool or a TOPP utility that can open parquet) and verify
expected schema/column names or row count; update the test command to run that
validation and keep the DEPENDS property intact for
"TOPP_PeptideDataBaseSearchFI_3_multi".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 962cc4f9-fa13-4800-abf5-25822908a904
📒 Files selected for processing (5)
src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.hsrc/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cppsrc/tests/class_tests/openms/source/PeptideSearchEngineFIAlgorithm_test.cppsrc/tests/topp/CMakeLists.txtsrc/topp/PeptideDataBaseSearchFI.cpp
…nd .d are supported Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add missing entries for three features merged after last changelog sync: - PeptideDataBaseSearchFI multi-file search with shared fragment index (#9109) - Semi-tryptic and non-specific digestion in PeptideDataBaseSearchFI and SimpleSearchEngine via new peptide:enzyme_specificity parameter (#9112) - New PSM annotation options (num_matched_peaks, matched_b_ions, matched_y_ions, longest_peptide_ion_sequence, fragment_annotation) in PeptideDataBaseSearchFI and SimpleSearchEngine, with parquet export (#9117) Co-authored-by: Copilot <[email protected]>
Add missing entries for three features merged after last changelog sync: - PeptideDataBaseSearchFI multi-file search with shared fragment index (#9109) - Semi-tryptic and non-specific digestion in PeptideDataBaseSearchFI and SimpleSearchEngine via new peptide:enzyme_specificity parameter (#9112) - New PSM annotation options (num_matched_peaks, matched_b_ions, matched_y_ions, longest_peptide_ion_sequence, fragment_annotation) in PeptideDataBaseSearchFI and SimpleSearchEngine, with parquet export (#9117) Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
- Updated ProSE multi-file search entry (#9109) to remove now-inaccurate reference to -out accepting file lists - Added BREAKING entry for ProSE output parameter overhaul (#9146): -out replaced by -out_idxml, -out_qpx, -out_parquet with per-file and merged QPX/internal Parquet output Co-authored-by: Copilot <[email protected]>
- Updated ProSE multi-file search entry (#9109) to remove now-inaccurate reference to -out accepting file lists - Added BREAKING entry for ProSE output parameter overhaul (#9146): -out replaced by -out_idxml, -out_qpx, -out_parquet with per-file and merged QPX/internal Parquet output Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
PeptideDataBaseSearchFIcan now process multiple spectrum files (mzML or Bruker .d) against the same FASTA in one invocation. TheFragmentIndexis built once via a newprepareContext()step and reused across every input file, eliminating the redundant per-file index-build cost (peptide generation → fragment generation → sorting → bucketing) when batching searches.Per-file output is written as either idXML or QPX PSM parquet, auto-detected from each
-outentry's extension. Mixed formats within a single run are allowed.Closes the FragmentIndex-reuse / multi-file batch use-case for this tool.
Algorithm changes (
PeptideSearchEngineFIAlgorithm)SearchContextstruct (decoy-augmenteddb+ builtFragmentIndex).prepareContext(fasta_db)extracted from the existingsearch()body.search(PeakMap&, SearchContext&, ...)overload reusing a pre-built context.MultiFileSearchResultstruct (per-file SearchResults + aggregate).searchWithModificationAnalysis(...)overloads (in-memory FASTA and FASTA file path) — build the index once, loop per file with per-file modification analysis, then run a single aggregate analysis on the pooled PSMs.search(PeakMap&, fasta_db, ...)and file-basedsearchWithModificationAnalysis(in_spectra, in_db, ...)refactored into thin wrappers — no behavior change for existing callers (verified by 10 byte-identical regression tests).TOPP tool changes (
PeptideDataBaseSearchFI)-inand-outare now lists;-databasestays a single FASTA..idXML→FileHandler::storeIdentifications;.parquet→QPXFile::exportToParquet.-out_mod_analysis_dir <dir>writes per-file (basename-stemmed) and aggregate modification-analysis TSVs in open-search mode. UsesregisterOutputDir_/getOutputDirOptionso the directory is auto-created. When set, per-file tables use each input file's basename (works for both mzML and .d inputs).-in/-outlist lengths, recognised output extensions, basename-collision detection (refuses to overwrite when two inputs share a stem or collide with the reserved aggregate name).-out_mod_analysis_diris set in closed-search mode (precursor tolerance ≤ 1 Da / ≤ 1000 ppm).INTERNAL_ERRORexit code if any file failed.Tests
prepareContext+ context-basedsearch()produces the same PSMs as the single-shotsearch()and that the same context can be reused for a second search; (b) the multi-file overload's input-validation paths (Exception::InvalidParameteron length mismatch,INPUT_FILE_EMPTYon empty list).TOPP_PeptideDataBaseSearchFI_3_multiruns the tool with two mzML inputs (the existingSimpleSearchEngine_1.mzMLtwice for simplicity) and one idXML + one parquet output. The idXML is diffed against the existing_1reference (same input → same output, proving the multi-file path is equivalent to single-file). The parquet output is smoke-tested withcmake -E sha256sum(fails if missing)._1,_2,_DDA,_FalseDiscoveryRate_DDA, write-INI, write-CTD, class test, plus the 3 new ones → 13/13).Test plan
cmake --build OpenMS-build -j$(nproc)— cleanctest --test-dir OpenMS-build -R 'PeptideDataBaseSearchFI|PeptideSearchEngineFIAlgorithm'— 13/13 pass_3_multitest produces matching idXML for the first input and a non-empty parquet for the secondNotes / follow-ups (not in this PR)
SearchContext/MultiFileSearchResult/prepareContext/ multi-filesearchWithModificationAnalysisoverloads (legacy single-file paths still bound).TOPPBase::fileParamValidityCheck_to add anOUTPUT_FILE_LISTbranch (currently onlyINPUT_FILE_LISTis checked, so per-entrysetValidFormats_validation is silently skipped for output lists). This tool's local pre-flight loop covers the gap for now; affects 4 other tools (FileMerger,OpenSwathDIAPreScoring,QualityControl,SpectraSTSearchAdapter).decoys=trueto also exercise the decoy-generation path insideprepareContext.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests