Include modification C/S counts in library-wide isotope envelopes - #145
Merged
Merged
Conversation
This was referenced Sep 12, 2026
Apex-finder bench
Sensitivity + timing across canonical scenarioscommit 37aec05 |
jspaezp
commented
Sep 13, 2026
| /// Owned by its reference library; callers cannot install a plan from another library. | ||
| #[derive(Debug, Clone, Serialize)] | ||
| pub struct ScoringPlan { | ||
| isotopes: crate::fragment_mass::isotope_plan::IsotopePlan, |
There was a problem hiding this comment.
🟡 Changes recommended
Reject negative or NaN neutral masses before accepting isotope envelopes.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Centralizes library-wide isotope-envelope calculation with modification-aware C/S contributions, cached row envelopes, and shared scoring, CLI, viewer, and Parquet integration.
Changes:
- Adds composition- and mass-estimated isotope planning.
- Removes production sequence-reparsing fallback.
- Adds metadata, validation, and cross-reader coverage.
- Requires validation of negative or NaN neutral masses.
File summaries
| File | Summary |
|---|---|
rust/timsseek/src/scoring/plan.rs |
Integrates isotope planning into scoring. |
rust/timsseek/src/scoring/parquet_writer.rs |
Verifies isotope metadata serialization. |
rust/timsseek/src/models/sequence.rs |
Restricts sequence parsing to test helpers. |
rust/timsseek/src/fragment_mass/mod.rs |
Exposes the isotope-plan module. |
rust/timsseek/src/fragment_mass/isotope_plan.rs |
Resolves and caches isotope envelopes. |
rust/timsseek/src/fragment_mass/elution_group_converter.rs |
Retains fast C/S counting. |
rust/timsseek/src/fragment_mass/averagine.rs |
Supports mass-based C/S estimation. |
rust/timsseek/src/data_sources/reference_library.rs |
Uses finalized library envelopes. |
rust/timsseek_cli/src/predicted_library.rs |
Covers prediction/reload equivalence. |
rust/timsquery/src/models/target_columns.rs |
Adds row-addressed sidecars. |
rust/timsquery/src/models/capabilities.rs |
Documents isotope capability semantics. |
rust/timsquery/src/chemistry/analyte.rs |
Documents isotope chemistry behavior. |
rust/timsquery/src/chemistry.rs |
Updates chemistry documentation. |
rust/timsquery_viewer/src/file_loader.rs |
Aligns viewer isotope behavior. |
docs/development.md |
Documents isotope-plan policy. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+111
to
+113
| let z = f64::from(geom.charge(row)); | ||
| let envelope = isotope_dist_from_mass(geom.precursor_mz(row) * z - z * PROTON_MASS); | ||
| if !envelope.iter().all(|v| v.is_finite()) { |
jspaezp
commented
Sep 13, 2026
| Ok(counts) | ||
| } | ||
|
|
||
| fn valid_counts(cs: Counts) -> Resolution { |
Collaborator
Author
There was a problem hiding this comment.
super over-engineered ...
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.
Precursor isotope envelopes now include modification C/S contributions and use one calculation method across the entire library. Previously, scoring counted stripped residues and selected an averagine fallback independently for each entry.
For example,
PEPTC[UNIMOD:4]IDEKpreviously used C43/S1, ignoring carbamidomethyl. It now uses C45/S1. DIA-NNC(UniMod:4)and mzSpecLibC[U:Carbamidomethyl]produce the same envelope. If one entry instead has a mass-only modification, every stored target and shipped decoy uses mass-estimated C/S.ReferenceLibraryfinalization and caches three intensities per stored row. Synthetic mass-shift decoys reuse the parent's envelope, including its unshifted mass in mass-estimated mode.RowValuessidecars retain opaque stored-row addressing.The access path is now
ReferenceLibrary → ScoringPlan → IsotopePlan → cached row envelope → RefQuery → existing extraction/scoring. Score-macro feature declarations do not change.Validation: library/scoring/CLI/macro tests and doctests; actual DIA-NN/mzSpecLib and prediction/reload equivalence; target/shipped-decoy/generated-variant cases; formula-only inputs, signed/terminal modifications, unresolved and labelled chemistry, model limits; viewer tests and Parquet metadata. Formatting and workspace Clippy (including dashboard) pass. No real-data performance or FDR benchmark was run.
Closes #108. Slice 3 of #97; sequence-free scoring remains the next slice.