Repository navigation
[FEATURE,FIX] Every PeptideIdentification needs its ProteinIdentification run - #10475
Conversation
…tion run
Enforce the contract that a peptide identification's identifier names an
existing protein identification run (the search run, which may have no
protein hits or database). ProteinRunReferences::check() throws
Exception::InvalidParameter ("Peptide identification has no matching protein
run: '<id>'. ...") and is used by all writers before the file is opened
(idXML/featureXML/consensusXML no longer silently omit such identifications;
pepXML, mzIdentML, xQuest, mzTab, OMS and the Parquet formats check, too) and
by the loaders, which refuse dangling references (featureXML/consensusXML
identification_run_ref, featureparquet, idparquet/consensusparquet shell runs,
mzIdentML lists without a SpectrumIdentification).
Producers fixed at the root: OPXLHelper::removeBetaPeptideHits and the
mzIdentML XL-MS loader lost run identifiers; FeatureMapArrowIO did not rename
subordinate identifications; OpenSwathWorkflow's featureXML output had no run
(MRMFeatureFinderScoring::addProteinIdentificationRun); FeatureFinderIdentification
stored candidates before setting runs and kept pseudo IDs once they carry a run;
FeatureFinderAlgorithmMetaboIdent (FAIMS), ConsensusMap::split, IDMerger -add_to,
ProteomicsLFQ and the FileHandler OMSSA loader.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
…ropped FeatureFinderIdentification_5_candidates and the OpenSwathWorkflow featureXML outputs gain their protein identification run and the peptide identifications of the features, which featureXML storing silently omitted before (no run). Additions only; the feature ids differ (whitelisted) since the new run takes unique ids. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
The writers looked protein references up with operator[], so a peptide evidence whose protein is no protein hit of the peptide identification's run was written as "PH_0": a file that cannot be read back, or that names another protein. ProteinRunReferences::checkProteinAccessions() throws Exception::ElementNotFound before the file is opened (the handlers throw, too), as idXML does. Found by it: OpenSwathWorkflow kept only the first batch's proteins in its run (the proteins of each batch's transitions are added now), and the IDConflictResolver_3 input referenced a protein of another run in two runs (the expected output named VIMSS14219 instead of VIMSS15048). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
…ther run The loaders resolved protein_refs file-wide, so a peptide hit could reference a protein hit of another run (e.g. 'PH_0' written by the former fallback for unknown accessions) and silently get that protein. Such a reference is now a parse error. Test and example data with such references are fixed: the referenced protein is added to (or, if present, taken from) the peptide identification's own run (ProteinResolver_1, Epifany_2, IDMerger_6, MzTabExporter_5 and TextExporter_5 inputs, examples/FRACTIONS/BSA_linked.consensusXML). Test outputs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
timosachsenberg
left a comment
There was a problem hiding this comment.
Review of head afaee72 (83 files vs. merge-base ea2175b). I read every code hunk plus the enclosing functions, and traced the callers of the changed writers/loaders, scorePeakgroups/pickExperiment, QPXFile::importFromArrow, and the idXML/featureXML/consensusXML handlers.
The strict run-scoped protein references are a sound direction. Inline comments, most severe first:
- IdXMLFile: writer still resolves
protein_refsfile-wide while the new loader rejects cross-run refs, so this version can write a file it cannot read. - IDMerger -add_to: a "not found … Skipping" accession keeps the peptide, which now makes store throw or emit a cross-run ref.
- MRMFeatureFinderScoring::addProteinIdentificationRun: early return drops proteins of every batch after the first; documented pyOpenMS usage then fails in
FeatureXMLFile::store. - FeatureFinderIdentificationAlgorithm: the pseudo-ID placeholder run is never removed and has a fixed identifier.
- OpenSwathWorkflow: protein hit order is non-deterministic with
-threads > 1.
6–9. Minor: accession set rebuilt per batch inside the critical section; size-diff dangling-run detection duplicated across Arrow importers; redundant XL-MS identifier assignment; double up-front traversal in featureXML/consensusXML store; no ConsensusMap test forcheckProteinAccessions.
Checked and not flagged: fatalError throws so the run->second dereferences after it are safe; the XML handlers set the run identifier before the ProteinHit elements, so proteinid_to_run_ is consistent; ConsensusXMLHandler is constructed per load so its new map needs no clear; mzIdentML parses SpectrumIdentification before protocols so runOfList_ is populated when first used; ProteomicsLFQ already enforces one run per ID file so its new throw is correct; offset peptides carry SeedFeatureID so isEmptyPseudoID_ removes both kinds.
Generated by Claude Code
…th runs Fixes from the review of #10475: - IdXMLFile::store wrote a reference to the protein hit of an earlier run for an accession missing from the peptide identification's run, which the strict loader rejects; the lookup is per run now (ElementNotFound). The run check moved out of the function-try-block that notes a partial file (storeFile_()). - FeatureFinderIdentification: pseudo IDs of seeds and offset peptides rejected by the PSM score cutoff (or as decoys) are not reported as unassigned identifications (they had no run); re-scoring candidates removes pseudo IDs. - IDMerger -add_to: protein accessions are tracked per run, not per file. - MRMFeatureFinderScoring::addProteinIdentificationRun (static) merges the proteins into an existing run. OpenSwathWorkflow adds the run once per performExtraction, from the full transition list (no per-batch runs: deterministic protein order, no cost in .osw mode); OpenSwathAnalyzer adds one run for all SWATH files. - OPXLHelper::removeBetaPeptideHits groups the hits by run and spectrum. - MzIdentMLDOMHandler: look up the run once per new protein hit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
…l idXML file TOPP_FeatureFinderIdentification_6 stores offset peptides rejected by the PSM score cutoff; _7 checks that the candidates keep the pseudo IDs while the output and the output re-scored from the candidates have none. IdXMLFile_test removes the partial file a failed store() leaves (it does not validate). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
… check From the review threads on #10475: - FeatureFinderIdentification removes the run it adds for the pseudo IDs of seeds and offset peptides (without other runs) together with them; it was left in the output as an empty run with a fixed identifier. - IDMerger -add_to: a peptide whose protein is missing from its run is an error (ElementNotFound) instead of a logged "Skipping" that kept a peptide that cannot be written. - ProteinRunReferences::checkProteinAccessions also reports a peptide identification without its run (InvalidParameter), so featureXML/consensusXML storing checks both in one pass. - MzIdentMLDOMHandler: no second run assignment in the XL-MS branch. - Tests: ConsensusMap overload of checkProteinAccessions (feature, unassigned, missing run); pyOpenMS: seeds without runs leave no placeholder run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
…oined key The writers keyed the protein hit ids by run identifier and accession joined with '_', so (run 'A', accession 'B_C') and (run 'A_B', accession 'C') shared the key 'A_B_C': a peptide hit of one run was written with a reference to the other run's protein, which the loaders now refuse. The ids are now kept per run (run identifier -> accession -> id). Round-trip regression in the FeatureXMLFile and ConsensusXMLFile class tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C
|
Yeah makes sense. Cant think of anything where you would NOT need one. |
|
@jpfeuffer Thanks. The rule only goes one way, so that case stays valid: a protein identification run without any peptide identification is not checked or rejected anywhere.
A merged run next to the original per-file runs, which keep their subsets of proteins and no peptide identifications, is written and loaded as before. The same holds for a run whose PSMs were all filtered out. The featureXML/consensusXML class tests cover a round trip with such a run: run Generated by Claude Code |
Brings in develop up to dac9590 (89 commits since #10446). Conflicts and ports: - #10517 (modification-aware RNA digestion): RNaseDigestion keeps the run digest of this branch next to develop's coordinate-bearing digest, getFragmentPositions, inferCleavageSensitiveMods and digestWithCleavageSensitiveMods. The candidate and evidence merge of the run digest is RNaseDigestion::DigestedOligo::addEvidence, which NucleicAcidSearchEngine also uses: it applies internal fixed modifications before the cleavage and places cleavage-sensitive variable modifications during the digestion, on the database sequences of its run (evidence refers to the unmodified database sequence). A digest input (-digest) uses only the enzyme it records (rna_enzyme) to classify cleavage-sensitive modifications. The m2,2G digestion check and NASEDigestion_test use the owning model and a native digest bundle instead of .oms; bindings keep the run digest and add develop's API. - #10515 (RNA adduct mass): the mzTab export of oligonucleotide matches without a calculated m/z includes the adduct, computed as NucleicAcidSearchEngine does (AdductInfo::getMZ; the adduct of a match is that of the ion). The regression test uses the owning model with the adduct NucleicAcidSearchEngine stores and develop's formula as the expected value. - #10475 (every peptide identification needs its run): the Arrow writers check both the native links and the protein runs; the consensus Parquet loader checks both as well. The adapter reports a missing run with ProteinRunReferences' message. The converter keeps this branch's implementation, which enforces the run contract on import. - FileHandler: imaging includes from #10439; CHANGELOG: both sides. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
Summary: why a strict rule helps
A peptide identification is only meaningful together with the search run that produced it. The run (
ProteinIdentification) holds the search engine, database, modifications, score settings and the proteins the peptide hits may point to. OpenMS let a peptide identification name a run that does not exist, and each file format and tool handled that differently, mostly by losing or bending data without telling anyone.This PR makes it one simple rule: every peptide identification names an existing run. The run may be empty, i.e. without protein hits or a database, as in peptidomics or de novo. A violation now fails at once, with one clear message, where the data is created or written.
Cases this prevents (all found in this PR, in code or test data):
PH_0). The expected output of one TOPP test (IDConflictResolver_3) named the wrong protein without anyone noticing.std::out_of_range; the OMS conversion threw it as well. Some writers produced files OpenMS itself could not read back.For users: data that already follows the rule is read and written as before. Data that breaks it now fails with a clear message instead of being changed silently. The test and example files that broke it were fixed.
Description
Enforces on develop the contract the IdentificationData stack (#10423) relies on: every
PeptideIdentificationnames an existingProteinIdentificationrun (the search run, which may have no protein hits or database, e.g. peptidomics or de novo). Data and code conform before the stack lands; the error wording matches the IdentificationData import.Central check
ProteinRunReferences(new,METADATA/, bound in pyOpenMS) throwsException::InvalidParameter:Writers: check before the file is opened
std::out_of_range(mzTab after truncating the file)Loaders: refuse dangling references (strict)
identification_run_ref(was a warning, kept with an empty identifier).Protein references
protein_refs="PH_0"(another protein) for an accession that is no protein hit of the run, so the file could not be read back or named the wrong protein.ProteinRunReferences::checkProteinAccessions()now throwsElementNotFoundbefore the file is opened, in the same single pass as the run check._. RunAwith accessionB_Cand runA_Bwith accessionCshared a key, so a peptide hit referenced the other run's protein. The ids are now kept per run.ElementNotFoundas for an unknown accession.protein_refsfile-wide. A reference to another run's protein hit is now a parse error.Producers fixed at the root
OPXLHelper::removeBetaPeptideHitsdropped the run identifier, and only the last cross-link match of a spectrum got one. Every XL-MS identification loaded from mzIdentML was then silently dropped by the idXML writer. Hits are now grouped by run and spectrum.scorePeakgroups()never adds it. The new staticMRMFeatureFinderScoring::addProteinIdentificationRun()(pyOpenMS too) adds the run with the transition list's proteins, or merges them into an existing run.performExtraction()calls it once, from the full transition list: no per-batch runs, deterministic order, no cost in.oswmode.-candidates_outwas written before the runs were set. With the old file,-candidates_inre-scoring found 0 features; it now finds 69.SeedFeatureIDmarker, also when re-scoring candidates.-add_to: kept a peptide without its run, tracked accessions per file instead of per run, and kept a peptide whose protein is missing from its run (now an error).Test data and expected outputs (investigated one by one, additions only)
FeatureFinderIdentification_5_candidates.featureXMLnow contain the run and the identifications the writer used to drop.IDConflictResolver_3_output.consensusXMLnow names VIMSS15048, the protein its input references, instead of VIMSS14219 (PH_0).IDConflictResolver_3,ProteinResolver_1,Epifany_2,IDMerger_6,MzTabExporter_5,TextExporter_5andexamples/FRACTIONS/BSA_linked.consensusXML. These leave all other test outputs unchanged.Tests
ProteinRunReferences_test;A/B_Cvs.A_B/Cround trip in featureXML and consensusXML;FeatureFinderIdentification_6and_7(placeholder identifications) andIDMerger_7;test_protein_run_references.py, including FeatureFinderIdentification with seeds and no runs.test_restored_call_forms.py::_identified_run.Locally on head
79252bc, merged with developd5709a1(Ubuntu 24.04 system packages, Arrow 25.0.1,OPENMS_USE_VCPKG=OFF, Thermo RAW off, THIRDPARTY engines on PATH):Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Pxi3mzoptivbseUeJHjy2C