Skip to content

Support modified flanking residues (pS/pT/pY, acK) for PTM crosstalk (#565) - #572

Merged
aarmey merged 2 commits into
mainfrom
ptm-crosstalk-alphabet
Nov 14, 2026
Merged

aarmey merged 2 commits into
mainfrom
ptm-crosstalk-alphabet

Conversation

@aarmey

@aarmey aarmey commented Nov 14, 2026

Copy link
Copy Markdown
Member

Closes #565.

Summary

  • Expanded PTM Sequence Alphabet (ddmc/binomial.py):
    • Added PTM_TOKENS = ("s", "t", "y", "k") (representing flanking pS, pT, pY, and acK), PTM_AAfreq, PTM_AAlist, _PTM_AAbyteLookup, and normalize_ptm_sequences().
    • Extended fast_position_weight_matrix(), GenerateBinarySeqID(), and Binomial with include_ptms: bool = False, preserving the 20-AA AAlist default while allowing flanking PTM tokens to be scored against a position-specific flanking PTM background prior.
  • PTM-Aware PAM250 Matrix (ddmc/pam250.py):
    • Added _load_pam250_alphabet_and_matrix(include_ptms) and include_ptms: bool = False to get_pam250_scores() and PAM250, extending PAM250 with biochemical crosstalk scores for flanking s, t, y, k while preserving symmetry and the self-score row-max invariant.
  • DDMC Integration (ddmc/clustering.py):
    • Added include_ptms: bool = True to DDMC.__init__() so flanking PTM tokens are preserved by default (uppercasing only the central phosphoacceptor at position 5) while include_ptms=False reproduces the collapsed 20-AA alphabet.
    • Updated DDMC.get_pssms() to uppercase sequences when computing 20-AA PSSM central frequencies so lowercase flanking PTM tokens work seamlessly.
  • Dynamic Flanking PTM Annotation (ddmc/motifs.py):
    • Added annotate_flanking_ptms(p_signal, phospho_motifs=None, acetyl_motifs=None) to dynamically annotate flanking pS/pT/pY and acK tokens from overlapping co-measured PTM motifs.
  • Tests (ddmc/tests/test_ptm_crosstalk.py):
    • Added unit and integration tests covering PTM sequence normalization, 24-token one-hot/PWM encoding, PTM-extended PAM250 invariants, Binomial primed vs. unprimed discrimination, annotate_flanking_ptms(), and end-to-end DDMC separation of primed vs. unprimed isoforms for both Binomial and PAM250.

Verification

  • uv run ruff format --check ddmc: 32 files already formatted
  • uv run ruff check ddmc: All checks passed
  • uv run ty check ddmc: All checks passed
  • uv run pytest -v: 85 passed

@aarmey
aarmey merged commit cd5528f into main Nov 14, 2026
2 checks passed
@aarmey
aarmey deleted the ptm-crosstalk-alphabet branch November 14, 2026 18:41
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.

Support modified flanking residues (pS/pT/pY, acK) to model phospho-priming and PTM crosstalk

1 participant