Make alleles optional in command-line predictors (default None) - #265
Merged
Conversation
A predictor built only to score explicit (peptide, allele) pairs via predict_pairs() still had to be given a placeholder allele at construction -- and for predictors that validate against the tool's -listMHC list, a *valid* one, since the constructor resolves alleles eagerly and raises on an unsupported name. That forced awkward calls like NetMHCstabpan(alleles=[]). Default alleles=None (normalized to []) across the command-line predictors and their factories, so NetMHCpan() / NetMHCstabpan() construct and predict_pairs() works with no constructor alleles. The classic predict()/predict_peptides() path scores against self.alleles, and _allele_groups returns [] on empty, so it would silently return nothing; a fail-loud guard now raises there instead, preserving the old loud failure for the forgot-the-alleles mistake. NetMHCIIpanBase and BaseCommandlinePredictor stay required: they are internal bases that always receive alleles by keyword from their subclasses/factories. Claude-Session: https://claude.ai/code/session_01SZZUQruWNznzAJSN4FpDGs
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.
Motivation
A predictor built only to score explicit
(peptide, allele)pairs viapredict_pairs()still had to be handed a placeholder allele at construction — and for predictors that validate against the tool's-listMHClist, a valid one, because the constructor resolves alleles eagerly and raisesUnsupportedAllele. In practice that forced awkward calls likeNetMHCstabpan(alleles=[]).Change
Default
alleles=None(normalized to[]) across the command-line predictors and their factories (NetMHCpan,NetMHC,NetMHCIIpan), so:both work with no constructor alleles. Passing alleles still works unchanged.
The classic
predict()/predict_peptides()path scores againstself.alleles, and_allele_groupsreturns[]on empty — so with no alleles it would silently return nothing. A fail-loud_require_alleles()guard now raises there instead, preserving the loud failure the old required-argument gave for the forgot-the-alleles mistake:NetMHCIIpanBaseandBaseCommandlinePredictorstay required — they are internal bases that always receiveallelesby keyword from their subclasses/factories, and each has a required positional (parse_output_fn) afteralleles.Scope is the command-line (
BaseCommandlinePredictor) predictors, where the eager-listMHCvalidation makes the placeholder especially painful.BasePredictorgains theNone → []normalization (shared) butBigMHC/PRIME/MixMHC*signatures are left required for now — they take a different predict path without the shared guard.Tests
New CI-safe cases (stub predictor, no binary):
BasePredictornormalizesNone/omitted/str alleles;predict_pairsworks with empty constructor alleles;predict/predict_peptidesraiseValueError(not silent-empty) with none. Full suite: 672 passed, 51 skipped, 2 xfailed. Also verified against the real binaries here (NetMHCstabpan()/NetMHCpan()construct, pair-score, and guard).https://claude.ai/code/session_01SZZUQruWNznzAJSN4FpDGs