Skip to content

Gate gene DE methods in pairwise; centralise DE-method vocabulary#5

Open
annaquaglieri16 wants to merge 1 commit into
feature/mcp-serverfrom
gene-de-method-gating
Open

Gate gene DE methods in pairwise; centralise DE-method vocabulary#5
annaquaglieri16 wants to merge 1 commit into
feature/mcp-serverfrom
gene-de-method-gating

Conversation

@annaquaglieri16

Copy link
Copy Markdown

What

  • Adds de_method gating to run_pairwise_comparison (it had none; run_anova already gated). Invalid engine/entity combos — e.g. edgeR/DESeq2 for protein/peptide/metabolite/ptm — now fail fast in the MCP with a clear message instead of being rejected downstream by the server.
  • Centralises the edgeR/DESeq2 allowed-value vocabularies and numeric ranges into _methods.py (single source mirroring MDFlexiComparisons/.../process_r.py). anova.py now reads them instead of inline literals.

Why

pairwise.py accepted any de_method without validating against entity_type. The allowed values were also hardcoded inline in anova.py, so adding a pairwise gate naively would have created a third copy — centralising removes that drift risk.

Design note (intentional)

The two tools keep separate gating blocks and signature defaults on purpose, so anova and pairwise can validate differently or be updated in different orders. Only the vocabulary (the allowed values) is shared, in _methods.py.

Keeping in sync

The DE-method vocabulary now lives only in _methods.py — keep it aligned with process_r.py (de_method_gene, edger_norm_method, deseq2_lfc_shrinkage Literals + deseq2_alpha / apeglm_seed ranges). A drift-check script is a possible follow-up.

Testing

  • All three files parse; _methods.py imports cleanly with the expected values.
  • No inline literal sets remain in either gating block.
  • Every name anova.py/pairwise.py import from _methods exists (no typos).
  • Not run live (dev checkout has no venv); a pip install -e ".[mcp]" would allow a runtime check.

🤖 Generated with Claude Code

run_pairwise_comparison accepted any de_method without validating it
against entity_type, so an invalid combo (e.g. edgeR for protein) was
only caught downstream by the server. run_anova already gated; pairwise
did not.

- Add de_method gating to run_pairwise_comparison (engine allowed per
  entity_type + edgeR/DESeq2 companion-param validation). The bulk tool
  routes through this function, so it inherits the gate.
- Centralise the edgeR/DESeq2 allowed-value vocabularies and numeric
  ranges in _methods.py (_EDGER_NORM_METHODS, _DESEQ2_LFC_SHRINKAGE,
  _DESEQ2_ALPHA_RANGE, _APEGLM_SEED_RANGE), mirroring process_r.py.
  anova.py now reads them instead of inline literals.
- Each tool keeps its own gating block (no shared validator) so the two
  can diverge or be updated independently; only the vocabulary is shared.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@annaquaglieri16 annaquaglieri16 requested a review from infusini June 4, 2026 00:15
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