Skip to content

[FIX] ProSE: preserve input-occurrence indices when merging and splitting duplicate paths #10751

Closed

Description

@jpfeuffer

Details About Your Environment

Operating System and Hardware

macOS; the indexing issue is platform-independent. Hardware: N/A.

OpenMS Version

Source inspected on develop at cfdc95a6163f41145d619e412d9742d5557afe8b and PR #10745 at 0b485609213cf290213560205ac0e5ad4e571440. Runtime merger reproduction used installed OpenMS 3.7.0-pre-disabled-20261021 (Oct 21, 2026).

Installation Method

Other: source inspection plus an existing local OpenMS installation. No full build or end-to-end execution of the PR was performed.

Describe the Bug

Bug Description

ProSE must assign merge indices by input occurrence, not by path. Supplying the same -in path twice is supported: TOPP_ProSE_7_merged explicitly searches the same mzML twice and requests two per-file outputs plus a merged output. Rejecting duplicate inputs is therefore not a compatible fix.

This was identified while reviewing #10745 and is tracked separately because the underlying pooling/indexing defect is outside that PR's changed lines. The PR's new splitMergedPsms() exposes the defect in the per-file outputs when pooled protein FDR is applied.

Cause and impact

  1. IDMergerAlgorithm deduplicates primary MS run paths via file_origin_to_idx_.emplace(...), and assigns each peptide identification's id_merge_index by looking up its path. Two occurrences of the same path consequently receive the same index.
  2. ProSE's poolSearchedFiles_() assumes those indices enumerate pooled input occurrences. Its correction for skipped/failed inputs does not recover occurrence identity after path deduplication. Replacing the merged run's paths with the full input list does not repair the peptide indices.
  3. In [FIX] ProSE: FDR:protein switches between final results and intermediates; outputs agree; full parameter names; run-view counts; c/z test #10745, splitMergedPsms() trusts id_merge_index as a position in result.per_file. With two identical inputs, every surviving pooled PSM is moved to entry 0; entry 1 receives no PSMs. The indices are valid integers, so validation succeeds rather than taking the fallback. The TOPP caller invokes this split after -out_merged when merged.protein_fdr_applied is true.

For [A, A], the expected merged indices include both 0 and 1, each identifying its own input occurrence. Currently all are 0. For [A, A, B], subsequent distinct inputs can also be associated with the wrong occurrence.

Validated reproduction of the indexing defect

From the repository root, using an existing IDMerger executable:

IDMerger \
  -in src/tests/topp/newIDMergerTest1.idXML src/tests/topp/newIDMergerTest1.idXML \
  -out /tmp/duplicate-input-merged.idXML \
  -merge_proteins_add_PSMs -test

Observed using the installed executable:

Input peptide IDs per occurrence: 2
Merged peptide IDs: 4
Merge indices: [0, 0, 0, 0]
Split counts by input position: [4, 0]; expected [2, 2]
FAIL: duplicate input occurrences collapse to index 0

The final split counts above are computed from the actual merged indices using the PR splitter's routing rule; they are not output from an end-to-end ProSE run of the PR. The PR's splitter and caller were checked directly in source.

Relevant source

Expected resolution / regression coverage

  • Preserve input-occurrence identity throughout ProSE pooling, merged output, and splitting; retain the real paths, including duplicates, in their original order.
  • Cover both the prebuilt aggregate and direct-pooling paths (build_pooled_aggregate enabled/disabled).
  • Add regression coverage for [A, A] and [A, A, B], including skipped/failed input positions. Verify exact indices and that each occurrence receives only its own surviving PSMs after splitting.
  • Extend the existing duplicate-input TOPP test to inspect both per-file outputs as well as the merged output.
  • Avoid changing IDMerger's general path-deduplication contract without assessing other callers; the necessary behavior is occurrence-based indexing for ProSE.

Severity: Major — incorrect provenance in merged results and incorrect/empty per-file outputs in the PR's pooled-protein-FDR split workflow.

Activity

  1. coderabbitai commented on Oct 27, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #10745 - [FIX] ProSE: outputs agree with -out_merged; full parameter names in refusals; run-view spectrum counts; c/z annotation test [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. jpfeuffer commented on Oct 27, 2026

    @jpfeuffer
    ContributorAuthor

    Policy clarification following maintainer discussion: prefer rejecting duplicate input files rather than introducing occurrence-based merge semantics solely to support accidental repeated inputs. This supersedes the original report’s assertion that duplicates must remain supported: TOPP_ProSE_7_merged uses a duplicate as a test convenience, not proof of an intended public contract.

    Proposed scope:

    • ProSE: reject the same physical input file appearing more than once, before searching, with an actionable error naming both input positions. Account for relative/absolute paths and symlink aliases through an existing filesystem-equivalence utility where available. Do not compare file contents or reject distinct fixture files merely because their contents match.
    • IDMerger CLI: likewise reject the same identification input file supplied twice, rather than silently duplicating its PSMs. Assess the optional add_to input when defining duplicate detection across input roles.
    • Adapt TOPP_ProSE_7_merged to use two distinct fixture files and add explicit rejection tests for repeated files and path aliases.

    Important distinction for IDMergerAlgorithm: two DISTINCT identification files can legitimately reference the SAME primary MS run (for example, results from different searches of the same spectra). A shared primary MS run path is therefore not sufficient evidence of a duplicate input identification file. Preserve intentional same-run merging and its path-based provenance; do not globally forbid repeated primary MS run paths in the algorithm. It receives identification objects rather than CLI input filenames, so duplicate-file validation belongs at the file-loading boundary.

    The observed data-integrity defect remains real, but early rejection of repeated physical inputs is the preferred resolution instead of supporting them as separate occurrences.

  3. timosachsenberg commented on Oct 28, 2026

    @timosachsenberg
    Contributor

    I agree that the stronger contract is better. We should reject and adapt the tests

  4. martand-codes commented on Nov 18, 2026

    @martand-codes

    Hi @jpfeuffer and @timosachsenberg,

    I'd love to take this one on if it's still available!

    The updated scope in the thread is very clear:

    1. ProSE: Reject duplicate physical inputs before searching (resolving relative/absolute paths and symlinks via filesystem equivalence) with an actionable error.
    2. IDMerger: Apply the same CLI-level physical duplicate check, keeping IDMergerAlgorithm's internal path deduplication intact.
    3. Tests: Update TOPP_ProSE_7_merged to use two distinct fixtures and add explicit rejection tests.

    Let me know if I'm good to start drafting a fix on develop!

  5. timosachsenberg commented on Nov 18, 2026

    @timosachsenberg
    Contributor

    Closing: the defect reported here is fixed on develop.

    Not done, and not part of this issue any more: the alternative discussed above of rejecting a file given twice in ProSE and in the IDMerger CLI. On develop ProSE only refuses repeated input stems together with -out_qpx / -out_parquet, and IDMerger still accepts the same file twice and duplicates its PSMs. If we want that stricter contract, it should get a new issue with that scope, as title and description here describe the index defect.

    @martand-codes thanks for the offer. There is nothing left to pick up under this issue.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions