Skip to content

bugfix: MAF robustness — createinput comment lines + compute_fitness input guards - #252

Closed
johnoooh wants to merge 2 commits into
developfrom
bugfix/maf-robustness
Closed

bugfix: MAF robustness — createinput comment lines + compute_fitness input guards#252
johnoooh wants to merge 2 commits into
developfrom
bugfix/maf-robustness

Conversation

@johnoooh

Copy link
Copy Markdown
Collaborator

Two independent robustness fixes surfaced by a large production run.

Fixes

  1. phylowgs/createinput: strip leading # comment/header lines from the MAF (grep -v '^#') before create_phylowgs_inputs.py, which otherwise mis-parses a commented header.
  2. neoantigenediting/computefitness: guard the scoring loop against div-by-zero (Kd/KdWT==0) and non-standard amino-acid residues (outside ACDEFGHIKLMNPQRSTVWY, e.g. */X) which crash EpitopeDistance; zero the score components instead of raising. Guard extracted into a testable score_neoantigen() helper.

Tests

  • pytest 5/5 (non-standard residue, Kd==0, KdWT==0 → zeroed; clean input → scored).
  • nf-test: createinput 3/3 (incl. new leading-# regression case) and computefitness 2/2, --profile docker.

johnoooh added 2 commits July 22, 2026 14:00
create_phylowgs_inputs.py uses csv.DictReader on the raw MAF, so a
leading "#" header/comment line gets treated as the column header row
and breaks column-name based parsing (KeyError downstream). Strip any
"^#" lines into filtered_head.maf before passing it as the --vcf-type
input.

Adds an nf-test case (with a small local MAF fixture carrying a
leading "#" comment line) that reproduces and verifies the fix.
Neoantigen scoring computed logC/logA/quality unconditionally, which
divided by zero when Kd or KdWT was 0 and raised a KeyError from
EpitopeDistance when a peptide contained a non-standard residue (e.g.
"*", "X" from stop-gained/ambiguous calls). Extract the scoring step
into score_neoantigen() and zero out logC/logA/quality whenever Kd/KdWT
is 0 or either sequence contains residues outside the standard 20
amino acids, instead of crashing or dividing by zero.

Adds pytest coverage for the non-standard-residue guard, the Kd/KdWT
guard, and a clean-input case confirming normal scoring is unaffected.
@johnoooh
johnoooh requested review from a team, nikhil and pintoa1-mskcc as code owners July 22, 2026 20:00
@johnoooh johnoooh closed this Jul 22, 2026
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