Add pepsickle proteasomal cleavage predictor - #181
Merged
Conversation
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
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.
Summary
BasePredictorsubclass producingKind.proteasome_cleavagepredictionspredict(peptides)returns C-terminal cleavage probability per peptidepredict_proteins()runs pepsickle on full protein sequences (proper flanking context) then extracts per-peptide C-terminal cleavage scorespredict_cleavage_sites()exposes raw per-position cleavage profilesepitope(default),in-vitro(gradient-boosted),in-vitro-2(neural net), with configurable proteasome type (C/I) and human-only modepip install mhctools[pepsickle]Test plan
tests/test_pepsickle.py(14 pass, 1 xfail for sklearn version compat with in-vitro GB model)test_pred.pysuite passes (23 tests)