Skip to content

feat: toxicity penalty tests — Phase 2 benchmark honesty - #10

Closed
cschanhniem wants to merge 1 commit into
mainfrom
feat/toxicity-penalty-tests
Closed

cschanhniem wants to merge 1 commit into
mainfrom
feat/toxicity-penalty-tests

Conversation

@cschanhniem

Copy link
Copy Markdown
Collaborator

Summary

Implements Phase 2: Toxicity penalty from AGENTS.md:

"Predicted hemolytic/toxic candidates are down-ranked."

Safety scorer penalty signals tested

Signal Threshold Penalty
Hydrophobic fraction > 0.65 (hydro - 0.65) × 1.8
Charge density > 0.55 (charge - 0.55) × 1.2
Sequence length > 35 aa +0.25
Cysteine fraction > 0.25 +0.20
Longest repeat run ≥ 6 +0.15

These are computational proxies only. No biological safety claim is made.

What the tests prove

Test Result
Poly-L (hydrophobic_fraction=1.0) safety < 0.6 ✅
Poly-K (charge_density=1.0) safety < 0.6 ✅
Poly-C (cysteine_fraction=1.0) safety < 0.9 ✅
Sequence > 35 aa is penalized ✅
Long repeat run (≥6) is penalized ✅
All balanced AMPs > all poly-hydrophobic on safety ✅
All balanced AMPs > all poly-cationic on safety ✅
Monotonic safety reduction with excess hydrophobicity ✅
Poly-K double penalty (charge + repeat) → safety < 0.4 ✅
Mean AMP ensemble > mean high-risk ensemble (full pipeline) ✅
All AMPs outrank ALL high-risk candidates ✅
Toxicity propagates to safety field in pipeline output ✅
Strict safety filter excludes high-risk candidates ✅

Test plan

  • make test — 50 tests pass
  • ruff check src tests — clean

Phase 2: Toxicity penalty — predicted hemolytic/toxic candidates are down-ranked.

- Add test_toxicity_penalty.py: 13 tests covering the full toxicity penalty mechanism:
  Safety scorer penalty signals:
  - Hydrophobic fraction > 0.65 → hemolysis proxy penalty
  - Charge density > 0.55 → toxicity proxy penalty
  - Length > 35 aa → stability and synthesis penalty
  - Cysteine fraction > 0.25 → disulfide complexity penalty
  - Longest repeat run ≥ 6 → degenerate composition penalty

  Tests verify:
  - Extreme hydrophobicity reduces safety score (<0.6)
  - Extreme charge density reduces safety score (<0.6)
  - High cysteine fraction reduces safety (<0.9)
  - Very long sequences penalized
  - Long repeat runs penalized
  - All balanced AMP candidates score higher safety than poly-hydrophobic sequences
  - All balanced AMP candidates score higher safety than poly-cationic sequences
  - Monotonic safety reduction with increasing excess hydrophobicity
  - Double penalty (charge + repeat run) on poly-K
  - Mean AMP ensemble > mean high-risk ensemble in full pipeline
  - All AMPs outrank all high-risk candidates
  - Toxicity penalty propagates correctly through pipeline safety field
  - High-risk candidates excluded with strict max_safety_risk filter
- Fix ruff F401 unused imports (pipeline.py, test_cli.py, test_pipeline_filters.py)
- 50 tests passing, ruff clean
@cschanhniem

Copy link
Copy Markdown
Collaborator Author

Superseded by PR #11 (feat/integrate-all-phases), which merges all Phase 2 + Phase 3 work into a single consolidation PR with 251 tests passing.

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