Repository navigation
[FIX] OpenSearchModificationAnalysis: name the modification nearest to the cluster mass, not the lowest within the tolerance - #10644
Merged
Conversation
…o the cluster mass, not the lowest within the tolerance mapDeltaMassesToModifications() took the entry of lowest mass within +-tolerance of a cluster (lower_bound) and the entry of highest mass (the last one <= cluster + tolerance), and named the cluster "A//B" after both, or after the one if they were the same. The entry nearest to the cluster mass was never named when it lay between others. With the Unimod table, +15.9949 Da (oxidation) was "thiocarboxylic acid//Oxidation or Hydroxylation": thiocarboxylic acid (+15.9772 Da) is the lowest mass within 0.02 Da. histogram_found recorded the same two extremes, and the later lookups took the lowest entry of their window: - the PTM meta value of the PSMs of the oxidation cluster was "thiocarboxylic acid" (first entry of histogram_found within the tolerance), - DeltaMassEntry::mapped_modification of generateDeltaMassStatistics() was "thiocarboxylic acid" (the lowest mass still wins), - a cluster at +16.9949 Da was "thiocarboxylic acid+1Da" (first entry in the window around cluster - 1 Da) instead of "Oxidation or Hydroxylation+1Da". Now a cluster is named after the entry nearest to its mass if that is within the tolerance (still capped at 0.02 Da). "A//B" is kept for genuine ambiguity: entries whose distance to the cluster exceeds that of the nearest by at most 0.0005 Da, the width of the delta mass histogram bins, are named as well (in order of mass), as a cluster mass is not known better than that. Only the entries that name the cluster go into histogram_found. The nearest entry is also used wherever histogram_found is searched (the +1 Da variant, a modification found before, the PTM annotation of the hits), by generateDeltaMassStatistics() (same naming), and for the combination of two modifications, which was looked up at or above the cluster mass only (lower_bound(cluster)), so that a combination below it, within the tolerance, was missed (a cluster of -114.043 Da was "Unknown" with a combination 0.011 Da below it). The ModificationsDB lookups by mass (searchModificationsByDiffMonoMass*, getBest...) do not fit: the table here is the Unimod search modifications, one name per mass, and is also the basis of the combinations and the +1 Da logic; the sorted-map lookup is O(log n) per cluster for histograms of 1e4-1e5 bins. Tests: OpenSearchModificationAnalysis_test maps clusters at oxidation, thiocarboxylic acid and between them, with the tolerance, in ppm mode, with PSM annotation, the +1 Da variant, the combination (against a brute force over the Unimod table) and generateDeltaMassStatistics. No reference file changes; the ModificationAnalysis tables of TOPP_ProSE_12_open_* gain one combination name for a cluster that was "Unknown" (-114.043 Da). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
Author
|
important fix |
timosachsenberg
marked this pull request as ready for review
October 19, 2026 12:57
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 19, 2026
ConsensusID.cpp, which this branch had changed to clear the score software record, is removed with the tool (#10619); ProcessingStep.h, which develop changed in a comment, stays removed with the reference graph. PercolatorAdapter is now the only tool that records itself as search engine and clears score software records (CHANGELOG and identification-data.md updated). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 19, 2026
…10563 HiGHS, #10644, #10648) ConsensusID.cpp is removed with the tool (#10619), and with it this branch's bridge for feature and consensus maps: the tool exported the identifications that a feature links to peptide identifications, combined them with ConsensusIDAlgorithm and imported the consensus as a new run. No other code of this branch used ConsensusID. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 20, 2026
…sm-prose-webapp Brings in develop (with #10578 + #10602 as squash 2ef8693 and #10644 as 8528cf2) through the updated #10564 branch. This branch had carried a pre-squash version of #10578/#10602 (claude/prose-merged-in-library) and a cherry-pick of #10644. Resolution: every library path is develop's version plus only the library commits of this branch that develop does not have (ProSEAlgorithm:: pinEnzymeName() and modMatchTolerance() public, ML::PEPTDEEP_DEFAULT_BATCH_SIZE, the joined reader thread, peptdeep:batch_size 128 in WebAssembly, the PeptDeepRescoring NCE fix, ONNXPredictorBase without the memory pattern, the ONNX environment changes for WebAssembly threads). - ProSEAlgorithm.h, ProSEAlgorithm_test.cpp, src/tests/topp/CMakeLists.txt (conflicts) and ProSEAlgorithm.cpp (auto-merged, but with rescoreWithPercolator(), applyDeferredPsmFDR() and applyPsmFDR_() twice, since the squash moved them): develop's version with those commits on top. - src/tests/topp/ProSE_13_prepare.cmake: removed; develop's Test 13 copies its inputs with add_test(... -E copy) instead. - CHANGELOG: develop's text with this branch's entries. - #10644 (7abcb28): identical to develop's, no difference left. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
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
OpenSearchModificationAnalysis::mapDeltaMassesToModifications()mapped a delta mass cluster to the Unimod entries within +-effective_tol(at most 0.02 Da) by taking the entry of lowest mass in the window (lower_bound(cluster - tol)) and the entry of highest mass (the last one <=cluster + tol), and naming the cluster "A//B" after both (or after the one, if they are the same). The entry nearest to the cluster mass was never named when it lay between others, andhistogram_foundrecorded the same two extremes.Example: a cluster at +15.9949 Da (oxidation, +15.994915 Da). Thiocarboxylic acid (+15.977156 Da) is the lowest mass within 0.02 Da, and nothing is higher but oxidation itself:
_OutputTable.tsvthiocarboxylic acid//Oxidation or HydroxylationOxidation or HydroxylationPTMmeta value of the PSMs (first entry ofhistogram_foundin the window)thiocarboxylic acidOxidation or HydroxylationDeltaMassEntry::mapped_modification(generateDeltaMassStatistics, "the lowest mass still wins")thiocarboxylic acidOxidation or Hydroxylationthiocarboxylic acid+1DaOxidation or Hydroxylation+1DaThe new rule
MAX_MOD_MAPPING_TOL_= 0.02 Da). Other entries in the window are not named.MOD_MAPPING_AMBIGUITY_TOL_= 0.0005 Da are named as well, in order of mass. That is the width of the delta mass histogram bins (analyzeDeltaMassPatternsrounds to 0.0005 Da), so a cluster mass is not known better than that. The precursor tolerance is not used for this, since in an open search it is capped at 0.02 Da and would make every window ambiguous again. For the midpoint between oxidation and thiocarboxylic acid the cluster is still "thiocarboxylic acid//Oxidation or Hydroxylation".histogram_foundrecords only the entries that name the cluster (the nearest one, or the equally close ones).histogram_foundis searched: the +1 Da variant, the modification that explains a later cluster, and the PTM annotation of the PSMs.generateDeltaMassStatisticsnames the mapped modification with the same rule.lower_bound(cluster - eps), i.e. only combinations at or above the cluster mass (and the lowest of them), so a combination below the cluster, within the tolerance, was missed. This is the same kind of defect, in the same function, and is a separate hunk (easy to drop if you prefer it in another PR). Effect on data below.I looked at the
ModificationsDBlookups by mass (searchModificationsByDiffMonoMass[Sorted],getBestModificationByDiffMonoMass). They do not fit: they scan all modifications per call and include non-Unimod entries and substitutions, whereas this class works on one table (Unimod search modifications without substitutions, one name per mass) that is also the basis of the combinations and the +1 Da logic. The nearest lookup on the sorted map is O(log n) per cluster, which matters for histograms of 1e4 to 1e5 bins.Tests
OpenSearchModificationAnalysis_test(new sectionmapDeltaMassesToModifications, extendedgenerateDeltaMassStatistics): a cluster at 15.9949 maps to oxidation and not to the lowest entry of the window; a cluster next to thiocarboxylic acid maps to it; the midpoint (and +-0.0001 Da around it) is "A//B", +-0.001 Da is the nearer one; tolerance of 0.005 Da; ppm mode; PSM annotation of two neighbouring clusters; the +1 Da variant picks oxidation and not thiocarboxylic acid; the combination is the nearest sum, checked against a brute force over the Unimod table (a cluster whose nearest combination lies below it); unknown clusters. Run against the unfixed code the new checks fail (19 failed checks: 17 in the new section and 2 ingenerateDeltaMassStatistics, e.g.got "thiocarboxylic acid//Oxidation or Hydroxylation", expected "Oxidation or Hydroxylation"), with the fix they pass.WITH_GUI/THERMO_RAW/OPENTIMS=OFF, Release):ctest -R "ProSE|OpenSearchModificationAnalysis"77 of 77 passed (allTOPP_ProSE_*,ProSEAlgorithm_test, the class test), before and after the change;-R Sage4 of 4 (1 skipped: the sage binary is not available)._ModificationAnalysis_OutputTable.tsvthatTOPP_ProSE_12_open_*write (it is compared between thepinandnopinruns, there is no committed reference): the cluster at -114.043 Da wasUnknown-114.0and is nowLoss of arginine due to transpeptidation++tri-Methylation(-114.054 Da, 0.011 Da below the cluster; the combination lookup now sees combinations below the cluster). TheDeltaMassStatsandPTMStatstables are identical.Notes
Checklist
🤖 Generated with Claude Code