Skip to content

Add unified prediction model (Pred, PeptidePreds, MultiSample) - #177

Merged
iskandr merged 3 commits into
masterfrom
unified-prediction-model
Apr 7, 2026
Merged

Add unified prediction model (Pred, PeptidePreds, MultiSample)#177
iskandr merged 3 commits into
masterfrom
unified-prediction-model

Conversation

@iskandr

@iskandr iskandr commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New Pred (frozen, self-contained), PeptidePreds (best_* helpers), Kind enum, and MultiSample (multi-patient wrapper)
  • New predictor API: predict()list[PeptidePreds], predict_proteins(){name: list[PeptidePreds]}, both with _dataframe variants
  • Header-driven parse_netmhcpan_to_preds() returns Pred objects natively; NetMHCpan 4.1 emits both affinity and presentation per row
  • Full backward compat: BindingPrediction, predict_peptides(), predict_subsequences() unchanged, with to_pred()/from_pred() bridge
  • README rewritten with new API examples, predictor table, measurement kinds reference
  • 77 tests pass (20 new + all existing)

Test plan

  • All existing tests pass unchanged (BindingPrediction, format parsing, integration)
  • New tests for Pred, PeptidePreds, best_* helpers, preds_from_rows, MultiSample
  • Tests for predict(), predict_proteins(), predict_dataframe() via RandomBindingPredictor
  • Tests for parse_netmhcpan_to_preds (2.8, 3.0, 4.0 EL, 4.1 both kinds)
  • Compat bridge tests (to_pred, from_pred, to_preds, to_peptide_preds)

iskandr added 3 commits April 7, 2026 12:07
New data model with self-contained Pred objects, PeptidePreds grouping
with best_affinity/best_presentation/best_stability helpers, and
MultiSample for running across patients with different HLA genotypes.

New API:
- predictor.predict(peptides) -> list[PeptidePreds]
- predictor.predict_proteins(seq_dict) -> {name: list[PeptidePreds]}
- predictor.predict_dataframe() / predict_proteins_dataframe()
- MultiSample(samples={name: alleles}, predictor_class=...) wrapper

Header-driven parser (parse_netmhcpan_to_preds) returns Pred objects
natively. NetMHCpan 4.1 emits both pMHC_affinity and pMHC_presentation
per peptide-allele pair.

Full backward compatibility: BindingPrediction, predict_peptides(),
predict_subsequences() all still work. Conversion bridge via
to_pred()/from_pred()/to_peptide_preds().
Replace pylint (crashing on modern type annotations) with ruff.
Fix pre-existing issues: bare excepts, ambiguous variable names,
unused imports, None comparisons, type() comparisons.
Add NetMHCpan42/NetMHCpan42_BA/NetMHCpan42_EL classes (same output
format as 4.1). Rewrite NetMHCpan factory to parse the version string
and look up in a version map. Unknown versions >= 4.1 fall back to the
latest known class with the header-driven auto-detecting parser instead
of crashing.
@iskandr
iskandr merged commit d540c78 into master Apr 7, 2026
4 checks passed
@iskandr
iskandr deleted the unified-prediction-model branch April 7, 2026 16:35
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