Skip to content

Consolidate predictor wrappers + BigMHC fixes + docstring cleanup - #248

Merged
iskandr merged 1 commit into
masterfrom
review-fixes-cleanup
Jul 10, 2026
Merged

Consolidate predictor wrappers + BigMHC fixes + docstring cleanup#248
iskandr merged 1 commit into
masterfrom
review-fixes-cleanup

Conversation

@iskandr

@iskandr iskandr commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Second of two PRs from the code review (follows #247). This is the structural + cosmetic half: net −129 lines in the wrapper files, no behavior change except the BigMHC fixes.

Consolidation — new mhctools/wrapper_base.py

The four standalone wrappers each re-implemented the same boilerplate. Extracted into:

  • NewModelPredictorMixinpredict_dataframe, supported_kinds, __repr__, and peptide normalization (single-string + strip/upper).
  • AlleleFreePredictor — the allele-independent kind_support shape.

Calis / DeepTAP / ERAMER now subclass AlleleFreePredictor; BigMHC uses NewModelPredictorMixin. Each keeps only its constructor, _default_pred_kind, tool-specific validation (bounds/messages genuinely differ), and scoring.

BigMHC consistency fixes (flagged in review)

  • Un-normalized output: built predictions from the raw loop variable, so "siinfekl " was scored as SIINFEKL but returned verbatim. Now builds from the normalized peptide.
  • _pred_kind_default_pred_kind: aligns BigMHC with every other wrapper so a generic consumer can call it uniformly.

(The ProcessingPredictor family keeps its own internally-consistent _pred_kind; BigMHC's _find_bigmhc_dir bad-path case is already caught by the __init__ src/bigmhc.py check, and BigMHC stays intentionally pan-length so no length validation was added.)

Minor code

  • eramer: early-return on empty input (was loading the whole PWM first); drop the unreachable score is None branch.
  • Delete the dead _predictor_name in calis/deeptap/eramer (they hardcode the literal).
  • pred: add reduce_op(kind, field), used by best_by and AnnotationSpec.direction_op (the max/min mapping was written twice).
  • mixmhc2pred: resolve %Rank_/Score_ column positions once, not per row.

Docs / LLMism cleanup

  • Trim the copy-pasted "Note on interpretation" caveats to one sentence each (calis/prime/eramer/deeptap); drop PRIME's benchmark editorializing and the marketing/hedging phrasing; remove **bold** from reST docstrings.
  • Fix stale docstrings: calis.position_weights ("leading slice"), ERAMER class docstring (add $ERAMER_PWM).
  • Trim the bloated best_direction docstring, filler class docstrings, an over-defensive annotate comment, and the verbose nettcr suppression docstring.

Tests

New tests/test_wrapper_base.py covers the shared base and asserts the wrappers inherit it (and that BigMHC standardizes on _default_pred_kind). Full public subset: 496 passed. The MixMHC2pred and DeepTAP/ERAMER e2e were re-run locally against the real tools.

Version 3.28.0 → 3.29.0.

https://claude.ai/code/session_01LZahFhBSCiehXTESCYQ7wG

… cleanup

Follow-up to the code-review correctness PR (#247). Structural + cosmetic:
net -129 lines in the wrapper files with no behavior change (except the BigMHC
fixes below).

Consolidation (new mhctools/wrapper_base.py):
- NewModelPredictorMixin holds the members that were copy-pasted across the
  standalone wrappers: predict_dataframe, supported_kinds, __repr__, and
  peptide normalization (single-string + strip/upper).
- AlleleFreePredictor adds the allele-independent kind_support shape.
- Calis / DeepTAP / ERAMER now subclass AlleleFreePredictor; BigMHC uses
  NewModelPredictorMixin. Each keeps only its constructor, _default_pred_kind,
  tool-specific validation (bounds/messages differ), and scoring.

BigMHC consistency fixes (were flagged in review):
- Build predictions from the *normalized* peptide, not the raw input, so
  "siinfekl " is no longer scored as SIINFEKL but returned verbatim.
- Rename _pred_kind -> _default_pred_kind to match every other wrapper (generic
  consumers can now call it uniformly).

Minor code:
- eramer: early-return on empty input (was loading the whole PWM first); drop
  the unreachable score-is-None branch; delete the dead _predictor_name.
- calis/deeptap: delete the dead _predictor_name.
- pred: add reduce_op(kind, field) and use it in PeptideResult.best_by and
  AnnotationSpec.direction_op (the max/min mapping was written twice).
- mixmhc2pred: resolve the %Rank_/Score_ column positions once, not per row.

Docs / LLMism cleanup:
- Trim the copy-pasted "Note on interpretation" caveats to one sentence each
  (calis/prime/eramer/deeptap); drop PRIME's benchmark editorializing and the
  marketing/hedging phrasing; remove **bold** from reST docstrings.
- Fix stale docstrings: calis position_weights ("leading slice"), eramer's
  class docstring (add $ERAMER_PWM to the resolution order).
- Trim the bloated best_direction docstring, filler class docstrings, an
  over-defensive annotate comment, and the verbose nettcr suppression docstring.

Tests: new tests/test_wrapper_base.py covers the shared base and asserts the
wrappers inherit it (and BigMHC standardizes on _default_pred_kind). Full public
subset: 496 passed.

Version 3.28.0 -> 3.29.0.

Claude-Session: https://claude.ai/code/session_01LZahFhBSCiehXTESCYQ7wG
@iskandr
iskandr merged commit 75fe20c into master Jul 10, 2026
5 checks passed
@iskandr
iskandr deleted the review-fixes-cleanup branch July 10, 2026 14:53
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