Skip to content

Add pepsickle proteasomal cleavage predictor - #181

Merged
iskandr merged 6 commits into
masterfrom
add-pepsickle-support
Apr 8, 2026
Merged

Add pepsickle proteasomal cleavage predictor#181
iskandr merged 6 commits into
masterfrom
add-pepsickle-support

Conversation

@iskandr

@iskandr iskandr commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wraps the pepsickle library as a BasePredictor subclass producing Kind.proteasome_cleavage predictions
  • predict(peptides) returns C-terminal cleavage probability per peptide
  • predict_proteins() runs pepsickle on full protein sequences (proper flanking context) then extracts per-peptide C-terminal cleavage scores
  • predict_cleavage_sites() exposes raw per-position cleavage profiles
  • Supports all three pepsickle model types: epitope (default), in-vitro (gradient-boosted), in-vitro-2 (neural net), with configurable proteasome type (C/I) and human-only mode
  • Added as optional dependency: pip install mhctools[pepsickle]

Test plan

  • 15 tests in tests/test_pepsickle.py (14 pass, 1 xfail for sklearn version compat with in-vitro GB model)
  • Existing test_pred.py suite passes (23 tests)
  • Verify on CI

iskandr added 6 commits April 8, 2026 13:36
Wrap the pepsickle library as an mhctools BasePredictor subclass with
Kind.proteasome_cleavage predictions. Supports epitope, in-vitro, and
in-vitro-2 model types with configurable proteasome type (C/I).

predict() returns C-terminal cleavage probability per peptide.
predict_proteins() runs pepsickle on full proteins for proper flanking
context, then extracts per-peptide C-terminal scores.
predict_cleavage_sites() exposes raw per-position cleavage profiles.

pepsickle is an optional dependency (pip install mhctools[pepsickle]).
Introduce ProcessingPredictor, an allele-free base class for antigen
processing predictors. Subclasses implement cleavage_probs(sequence)
and get shared scoring aggregation (geometric mean of C-terminal,
N-terminal, and anti-internal cleavage components) with six configurable
scoring methods.

Refactor Pepsickle and NetChop to extend ProcessingPredictor:
- Neither accepts alleles (processing is allele-independent)
- Both produce Kind.antigen_processing predictions
- predict_proteins() runs on full proteins for proper flanking context
- predict_cleavage_sites() exposes raw per-position probabilities
…nk support

ProcessingPredictor now exposes:
- Static component helpers: c_term_prob, n_term_prob, internal_probs,
  max_internal_prob, mean_internal_prob
- Scoring as a callable (c_term, n_term, internal) -> float with six
  built-in scoring functions exported from the package
- Flanking-sequence support: predict(peptides, n_flanks=, c_flanks=)
  concatenates flanks before running the model; predict_proteins(
  flank_length=) records flanks from the protein context

New ProteasomePredictor intermediate class defaults scoring to
c_term * (1 - max_internal) and emits Kind.proteasome_cleavage.

Hierarchy: ProcessingPredictor → ProteasomePredictor → {Pepsickle, NetChop}
134 tests covering ProcessingPredictor, ProteasomePredictor, all six
scoring functions, component helpers, flanking support, and edge cases:

- _geomean: identity, zero propagation, associativity
- Init: defaults, int coercion, callable validation, repr/str
- Component helpers: c_term/n_term/internal at various offsets, length-1
- Scoring functions: all 6 formulas, empty internal, None n_term, zeros,
  perfect scores
- Monotonicity: higher c_term → higher score, higher internal → lower
- _peptide_score: parametrized across all scoring fns at offset 0 and 2
- predict: no flanks, both flanks, n-only, c-only, empty list, spy
  verifying n_term availability with flanks
- predict_proteins: peptide strings, offsets, scores match manual,
  multiple proteins, multiple lengths, flank_length cosmetic-only
- Integration: flanked predict() matches predict_proteins() at every
  offset; all scoring fns produce finite results
scoring parameter now accepts string mode names ("cterm",
"nterm_cterm", "cterm_max_internal", "cterm_mean_internal",
"nterm_cterm_max_internal", "nterm_cterm_mean_internal") in addition
to callables. Adds SCORING_MODES dict and resolve_scoring() helper.

Usage:
  Pepsickle(scoring="cterm_max_internal")
  Pepsickle(scoring=my_custom_fn)
- Fix ruff E731 (lambda assignments) in test_processing_predictor.py
- Add test_pred, test_processing_predictor, test_pepsickle to CI
  quality job's pytest invocation
- Install pepsickle optional dep in CI quality job
@iskandr
iskandr merged commit abdebc3 into master Apr 8, 2026
4 checks passed
@iskandr
iskandr deleted the add-pepsickle-support branch April 8, 2026 18:38
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