Add unified prediction model (Pred, PeptidePreds, MultiSample) - #177
Merged
Conversation
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.
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
Pred(frozen, self-contained),PeptidePreds(best_* helpers),Kindenum, andMultiSample(multi-patient wrapper)predict()→list[PeptidePreds],predict_proteins()→{name: list[PeptidePreds]}, both with_dataframevariantsparse_netmhcpan_to_preds()returnsPredobjects natively; NetMHCpan 4.1 emits both affinity and presentation per rowBindingPrediction,predict_peptides(),predict_subsequences()unchanged, withto_pred()/from_pred()bridgeTest plan