Repository navigation
[API,FEATURE,FORMAT,GUI] Add fragment m/z errors to peak annotations - #9822
Draft
timosachsenberg wants to merge 2 commits into
Draft
timosachsenberg wants to merge 2 commits into
timosachsenberg wants to merge 2 commits into
Conversation
Store an optional theoretical m/z on peak annotations and derive signed errors in Th and ppm. Persist the value through idXML, mzIdentML, and OMS, expose it in TOPPView and pyOpenMS, and populate it in annotation producers. Fixes OpenMS#4414
timosachsenberg
commented
Oct 17, 2026
timosachsenberg
left a comment
Contributor
Author
There was a problem hiding this comment.
Reviewed optional theoretical m/z propagation, missing-versus-zero handling, idXML/OMS persistence, mzIdentML array parsing/writing and GUI annotation conversion at b1e7c3c. No additional substantive runtime defect found in those paths. The build/test workflow is still red: the GCC job reports PeptideHit_test (line 330) and TOPP_SageAdapter_1_out1 failing; the Sage comparison still expects four-field annotations while output now includes theoretical m/z. Those test expectations need reconciliation before the checks can pass. Wheel CI passed. I inspected the existing test logs rather than rebuilding OpenMS locally.
This was referenced Nov 9, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4414.
Peak annotations previously retained only the observed peak position. That made fragment errors unavailable after annotations had been persisted or loaded.
This PR adds one canonical optional value,
PeakAnnotation::theoretical_mz, and derives both signed error representations from it:getMZError(): observed minus theoretical m/z in ThgetMZErrorPPM(): the same error normalized by theoretical m/zUnknown theoretical positions remain distinguishable from a real zero error. Ppm error is undefined when the theoretical m/z is zero.
Changes
PeptideHit::PeakAnnotation: newstd::optional<double> theoretical_mz,getMZError(),getMZErrorPPM(); comparison and hashing include the new fieldfragment_annotationrecords (four-field records still load)Measure_error, unit m/z); annotations with and without a theoretical m/z go to separateIonTypes so the parallel arrays stay aligned and a missing error is never written as 0Measurereferences are resolved through their CV terms, and error arrays in m/z or ppm are converted to theoretical m/z; arrays that do not match theIonTypeindex raise aParseErrorMzIdentMLDOMHandleron developpeak_theoretical_mzcolumn; schema version 7 (version 6 is already taken on develop by the processing actions); older files load without the valuePROSE/ProSEHits.cpp; with fragment recalibration the error is relative to the reported, uncorrected m/z), MetaboliteSpectralMatching (hyperscore and MVH, i.e. also NucleicAcidSearchEngine), MSP import (/deltaand/deltappm), Sage import (fragment_mz_calculated), mzPAFtoPeakAnnotation()MzPAFDeltaUnit::MZnames the default unitless delta (an m/z delta, per the mzPAF spec);DALTONstays as an aliastheoretical_mz(None when unknown),getMZError(),getMZErrorPPM(),MzPAFDeltaUnit.MZid:annotationsdocumentation mentions the optional fifth fieldfragment:mass_toleranceinstead of a defaultSpectrumAlignmentwith a fixed 0.3 Da window, as ProSE already does. The new errors made this visible: with a 10 ppm search tolerance, ab3++1157 ppm away was annotated.User impact
API users and downstream tools can read both absolute (Th) and ppm fragment errors without storing two redundant values that could become inconsistent. The value survives idXML, mzIdentML and OMS round-trips.
Compatibility: idXML files that carry the fifth field cannot be read by OpenMS releases before this change (their reader requires exactly four fields per annotation). OMS files written with schema version 7 are not readable by older versions either.
SimpleSearchEngine: identifications and scores are unchanged, but PSMs carry fewer fragment annotations (only those within the fragment tolerance), and their median fragment error, matched ion current and longest ion run change accordingly. OpenNuXL's autotune (on by default) runs SimpleSearchEngine and sets its fragment tolerance from these median errors, which now only include fragments within the initial tolerance; on real data the tuned tolerance will usually be tighter. Autotune only applies with more than 100 PSMs at 1% FDR, so the OpenNuXL tests are not affected.
Tests
PeptideHit,IdXMLFile,MzIdentMLFile(regular and cross-link round trips, ppm input, custom Measure IDs, legacyMeasure_ref, misaligned arrays),OMSFile(round trip and a legacy v3 file),MzPAF,MSPFile,SpectrumAnnotator,OPXLHelper,ProSEAlgorithm,MetaboliteSpectralMatchingtest_peak_annotation.pyTHIRDPARTY/SageAdapter_1_out.idXML: theoretical m/z values as reported by Sage, taken from a CI run of this branch (identical on all five platforms)OpenPepXL_output.mzid(realMeasure_errorarrays),OpenPepXL_output.idXMLandNucleicAcidSearchEngine_11_out.idXML: the changed lines were taken from the tool output of a CI run of this branch (identical on Linux x86 g++ and clang++, Linux ARM and macOS). Only the fragment annotation lines change; the existing fields of every annotation are unchanged. All errors are within the tool's fragment tolerance.SimpleSearchEngine_1_out.idXML(0.1 Da) andSimpleSearchEngine_2_out.idXML(10 ppm): taken from a CI run with the annotation tolerance fix (identical within the comparison tolerance on all five platforms). Besides the theoretical m/z, annotations outside the search tolerance are gone (largest error now 0.091 Th and 9.3 ppm), and the median fragment error, matched ion current and one longest ion run change accordingly.SimpleSearchEngine_3(FASTA alias) produces the same output asSimpleSearchEngine_1.fragment_annotationorMeasure_errorwhitelists are added.Validation
PeptideHit_test(expected string did not match how doubles are written),TOPP_SageAdapter_1_out1(new fifth field) andTOPP_SimpleSearchEngine_3_fasta_alias_out(new test on develop). All three are fixed.Follow-ups
theoretical_mz.AI disclosure
Co-authored-by:trailers. The human author has to review, understand and test the change before it is merged.https://claude.ai/code/session_0149aXmbE4Uu2whvKADHjd7e
Generated by Claude Code