Skip to content

predict_pairs: add skip_unsupported option so one unsupported allele doesn't fail the whole batch #263

Description

@iskandr

BaseCommandlinePredictor.predict_pairs (added in #262) raises UnsupportedAllele for the whole batch if any allele in the input is unsupported — _resolve_supported_allele_cli_names collects the unsupported ones and raises (base_commandline_predictor.py:415).

For row-wise paired scoring where the alleles come from a fixed dataset, that's often too strict. A single allele the tool doesn't cover — e.g. NetMHCstabpan-1.0 (2016) against an allele deposited since — fails the entire call and discards every score for the alleles it does support. Callers then fall back to the exact per-allele try/except loop that predict_pairs was meant to replace:

scores = {}
for allele, rows in df.groupby("allele"):
    try:
        pred = NetMHCstabpan(alleles=[allele]).predict_peptides_dataframe(rows.peptide.unique())
    except UnsupportedAllele:
        continue   # score what the tool covers, skip the rest
    ...

Request

Add skip_unsupported=False to predict_pairs / predict_pairs_dataframe. When True, drop pairs whose allele is unsupported (omit them from the result, or return NaN for those rows) instead of raising, and surface which alleles were skipped — return them, or log at WARNING. This mirrors the graceful per-allele handling callers already do by hand, and lets predict_pairs replace the loop without changing "score what the tool can, skip the rest" into "fail the whole batch on one gap."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions