Skip to content

UniProt XML: proteoform provenance (stacked on #149) - #152

Merged
ypriverol merged 12 commits into
mainfrom
feat/uniprot-proteoform-provenance
Oct 15, 2026
Merged

ypriverol merged 12 commits into
mainfrom
feat/uniprot-proteoform-provenance

Conversation

@ypriverol

@ypriverol ypriverol commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Based on main (after #149 was merged). The last commit is the same fix as #160 (annotation: None on seven test proteins added by #151), so the branch's tests compile until #160 is merged.

What it adds

Entry origin. Every protein from a UniProt XML database carries a kind (Reference / Isoform / Variant / Chain), a family accession and a feature id. Variants also carry the mass change of their substitution. Decoys keep their target's origin. --refine Pass-2 mini-proteins, and their decoys, keep the origin of the entry their backbone came from.

Six PIN columns, appended after DeltaRTNorm, before Peptide. They are Percolator features.

Column Meaning
IsVariant, IsIsoform, IsChain 1 when any protein of the peptide is such an entry.
RefCompetitor 1 when a canonical candidate with a different peptidoform was scored for the spectrum.
DeltaRefScore For flagged rows: this row's score minus that best canonical candidate's.
IsotopeMimic 1 when the precursor fits better if the row's isotope-like deltas (deamidation, or an N→D / Q→E substitution) are read as isotope steps. The rule moved from refinement into search::isotope_mimic.

Three TSV columns: ProteinFamily, EntryKind and FeatureIds for the named protein.

Two guards:

  • a startup WARN when artefact mods (deamidation, oxidation, carbamylation, methylation) are restricted to annotated sites while --uniprot-variants is on;
  • --decoy-strategy shuffle is refused when the database holds isoform or mature-chain entries.

Target/decoy symmetry

The first design counted a peptide shared with the canonical entry as canonical. Review found that rule asymmetric:

  • shuffled decoys don't keep the peptides a target isoform shares with its canonical entry;
  • pseudo-reversed chain decoys don't either.

The flags were therefore set on decoys more often than on targets, and Percolator would learn the label. The flags now mean "any protein of this kind". Specific evidence for an alternative sequence is a row whose Proteins names no canonical entry. DeltaRefScore is computed against canonical candidates of a different peptidoform, so a shared peptide doesn't compete with its own canonical copy.

Unchanged

  • The PIN stays one file.
  • On a FASTA search every existing column is byte-identical and every new column is 0.
  • The glyco PIN leaves the six columns out.
  • Chimeric co-isolation rows get RefCompetitor = DeltaRefScore = 0.
  • QPX gets the six values as PSM metavalues; its protein_accession schema is unchanged.

Verification

  • Golden files, regenerated after the rebase onto main: out-of-core slices, the E. coli digests, and the precursor-cal PIN/TSV. For every case, the new output with the new columns removed equals the previous golden exactly, and every new value is 0.
  • cargo clippy --workspace --all-targets -D warnings: clean.
  • cargo test --release --workspace with CI's skip list: 1,548 passed, 0 failed (after the rebase onto main).
    • With --include-ignored, the out-of-core goldens also pass.
    • Three ignored tests in onnx-infer and model-train fail on that run because they need exported ONNX models; this PR doesn't touch either crate.

Variant forms that a searched mod makes canonical (177ecea)

A variant entry could emit a form that weighs the same, residue by residue, as a searchable form of the canonical peptide. For example, N→D reads D, and D is what the canonical N weighs after deamidation. Variant entries now record each single-residue substitution (position, original residue), and decoys map these through their permutation. SpanSites, the per-position filter every expansion path uses, rejects a substituted residue whose form weighs the same as a searchable form of the residue it replaced.

One Astral file (HYE, reviewed UniProt XML, Percolator 3.7.1)

Arm PSMs @1% canonical isoform-specific (FDR) variant (FDR) chain (FDR)
XML 46,690 46,690
+ variants, isoforms, chains 46,927 46,561 183 (4.4%) 98 (2.0%) 83 (0%)
same + deamidation, before 177ecea 48,927 48,490 191 (6.3%) 159 (2.5%) 85 (0%)
same + deamidation, with 177ecea 48,788 48,402 191 (6.3%) 107 (3.7%) 86 (1.2%)

The class FDR in brackets is that class's decoys divided by its targets above the global 1% cutoff.

  • Flag symmetry: targets and decoys get the provenance flags at the same rates, for example IsIsoform 41.3% vs 41.3%. Percolator's weights for the six columns are all below 0.1, so the columns don't leak the label.
  • Single global FDR: applied to everything, it lets the isoform-specific class through at 4–6%.
  • 177ecea removes every N→D and Q→E variant call when deamidation is searched. What is left of the deamidation-like calls is D→N and E→Q. Those are canonical D/E peptides whose precursor was matched one isotope off; IsotopeMimic flags them, but no searched mod can make them canonical.

Rejected: counting a peptide shared by several entries as one fragment-index candidate lowered Astral PSMs by 0.4–0.8% and did not reduce the churn isoforms cause. It was not committed. Why isoforms cost about 0.9% of canonical PSMs is still unknown.

Not done

Validation on real data. The plan is genotype truth on PXD001406, using 1000 Genomes lymphoblastoid lines with open genotypes. Report:

  • canonical PSMs at 1%, with and without variants;
  • variant FDP measured against the genotypes, with pooled FDR and with FDR split by class.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0116eadf-d51a-440e-a226-af723e432616
📥 Commits

Reviewing files that changed from the base of the PR and between feee65b and 706e685.

⛔ Files ignored due to path filters: 3
  • test-fixtures/goldens/chimeric_slice.pin.gz is excluded by !**/*.gz
  • test-fixtures/goldens/refine_slice.pin.gz is excluded by !**/*.gz
  • test-fixtures/parity/goldens/precursor_cal_off.tsv is excluded by !**/*.tsv
📒 Files selected for processing: 26
  • DOCS.md
  • crates/andes/src/bin/andes/search.rs
  • crates/andes/tests/out_of_core_pin_goldens.rs
  • crates/andes/tests/pin_constant_columns.rs
  • crates/andes/tests/precursor_cal_bit_identical.rs
  • crates/andes/tests/uniprot_database.rs
  • crates/input/src/uniprot.rs
  • crates/model/src/lib.rs
  • crates/model/src/protein.rs
  • crates/output/src/glyco_pin.rs
  • crates/output/src/lib.rs
  • crates/output/src/pin.rs
  • crates/output/src/provenance.rs
  • crates/output/src/tsv.rs
  • crates/search/src/candidate_gen.rs
  • crates/search/src/coisolation.rs
  • crates/search/src/decoy.rs
  • crates/search/src/isotope_mimic.rs
  • crates/search/src/lib.rs
  • crates/search/src/match_engine.rs
  • crates/search/src/psm.rs
  • crates/search/src/refinement.rs
  • crates/search/src/search_index.rs
  • crates/search/tests/path_parity.rs
  • crates/search/tests/uniprot_annotation.rs
  • test-fixtures/parity/goldens/precursor_cal_off.pin
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ypriverol
ypriverol added this pull request to stack #153 October 14, 2026 12:54
@ypriverol
ypriverol marked this pull request as ready for review October 14, 2026 12:54
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@ypriverol ypriverol closed this Oct 14, 2026
@ypriverol
ypriverol force-pushed the feat/uniprot-proteoform-provenance branch from df3078e to 52105ae Compare October 14, 2026 12:55
@ypriverol ypriverol changed the title UniProt XML: fix #149 review findings; proteoform provenance (stacked on #149) UniProt XML: proteoform provenance (stacked on #149) Oct 14, 2026
@ypriverol ypriverol reopened this Oct 14, 2026
@ypriverol
ypriverol marked this pull request as draft October 14, 2026 16:02
@ypriverol
ypriverol marked this pull request as ready for review October 15, 2026 05:36
Base automatically changed from claude/uniprot-openms-reference-kun7zu to main October 15, 2026 05:42
…e origins

- IsVariant/IsIsoform/IsChain are set when ANY protein of the peptide is of
  that kind. Counting a peptide shared with the canonical entry as canonical
  was not target/decoy symmetric: shuffled decoys and pseudo-reversed chain
  decoys do not keep the peptides their targets share, so the flags were set
  on decoys more often than on targets.
- DeltaRefScore compares a row with the best canonical candidate of another
  peptidoform (RefTracker keeps best and second-best by peptidoform key), so
  a shared peptide does not compete with its own canonical copy.
- --decoy-strategy shuffle is refused when the database holds isoform or
  mature-chain entries.
- Canonical UniProt entries carry an origin (Reference, family = accession),
  so every entry of a family reports the same ProteinFamily.
- --refine Pass-2 mini-proteins and their decoys keep the origin of the entry
  their backbone came from.
A variant entry with a single-residue substitution could emit a form that
weighs the same, residue by residue, as a searchable form of the canonical
peptide: N10D reads D where the canonical N10 deamidated weighs the same, and
D18N deamidated is the canonical D18. On one Astral file, adding deamidation
as a variable mod raised accepted variant PSMs from 98 to 159, almost all of
them deamidation-like substitutions.

The reader now records each equal-length substitution (position, original
residue); decoys map the positions through their permutation. SpanSites, the
per-position filter every expansion path uses, rejects a form at a
substituted position whose residue+mod mass equals a searchable form of the
original residue (within SITE_MASS_TOLERANCE). A multi-residue substitution
loses such a form even when another of its positions still differs.
Rebased onto main after #149. For every out-of-core golden case and the
precursor-cal PIN/TSV, the new output with the six provenance columns
(three TSV columns) removed equals main's golden exactly; every new value
is 0.
#151 and #149 were merged one after the other. #151 added test proteins
in coisolation.rs and match_engine.rs without the `annotation` field that
#149 introduced, so the search crate's tests no longer compile on main.
@ypriverol
ypriverol force-pushed the feat/uniprot-proteoform-provenance branch from 177ecea to 706e685 Compare October 15, 2026 10:40
@ypriverol
ypriverol merged commit bb583dc into main Oct 15, 2026
5 checks passed
@ypriverol
ypriverol deleted the feat/uniprot-proteoform-provenance branch October 15, 2026 16:05
ypriverol added a commit that referenced this pull request Oct 15, 2026
Variant substitutions are judged against the forms the replaced residue
takes in the same terminal context; the stacked form tables and the
single-copy Met walk are kept. Goldens regenerated: with the six provenance
columns removed they equal the previous ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant