Skip to content

Commit 74b213a

Browse files
committed
fix: address code review issues on PR #51
- Add TestHelixBonusWeight with 3 numeric tests that pin the 0.03 helix bonus weight: exact delta at helix_pa=1.20, half-value at pa=1.10, and score ceiling assertion at 0.97 - Add test_proline_stacks_with_aggregation_propensity to cover combined agg+pro penalty interaction - Fix synthesis.py docstring: DKP formation is N-terminal dipeptide risk during piperidine deprotection, not exclusive to XP junction coupling - Makefile: bump test count to 1168
1 parent be740de commit 74b213a

4 files changed

Lines changed: 46 additions & 5 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lint:
2020
$(RUFF) check src tests scripts
2121

2222
ci: lint test
23-
@echo "CI passed: lint + 1164-test suite green"
23+
@echo "CI passed: lint + 1168-test suite green"
2424

2525
bench-leakage:
2626
PYTHONPATH=src $(PYTHON) -m openamp_foundry.cli bench leakage \

‎src/openamp_foundry/scoring/synthesis.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ def synthesis_feasibility_score(features: dict, valid_sequence: bool = True) ->
1414
- Aggregation propensity > 0: interior hydrophobic runs (VILMFW ≥ 4) and high
1515
beta-branched density (Val/Ile/Thr) cause on-resin aggregation and poor solubility.
1616
References: Quittot et al. (2017) Protein Sci; Wurth et al. (2006) J Mol Biol.
17-
- Proline fraction > 15%: N-methylated backbone requires extended activation; XP junctions
18-
prone to diketopiperazine (DKP) formation during Fmoc SPPS; overall coupling efficiency
19-
reduced. References: Barlos et al. (1989) Int J Peptide Protein Res; Quibell et al.
20-
(1994) J Am Chem Soc; Fischer (2003) Curr Opin Drug Discov Devel.
17+
- Proline fraction > 15%: N-methylated backbone requires extended activation (slow couplings
18+
at XP junctions); DKP formation risk at N-terminal dipeptides containing Pro during
19+
piperidine Fmoc deprotection; overall coupling efficiency reduced. References: Barlos et
20+
al. (1989) Int J Peptide Protein Res; Quibell et al. (1994) J Am Chem Soc; Fischer (2003)
21+
Curr Opin Drug Discov Devel.
2122
"""
2223
if not valid_sequence:
2324
return 0.0

‎tests/test_scoring_activity.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,37 @@ def test_dual_property_amps_score_higher_than_single_property(self):
255255
assert dual > only_amph
256256

257257

258+
class TestHelixBonusWeight:
259+
def test_helix_bonus_weight_0_03(self):
260+
# helix_pa=1.20 → clamp01((1.20-1.0)/0.20)=1.0 → bonus=1.0*0.03=0.03
261+
base = {
262+
"length": 18, "charge_density": 0.30, "hydrophobic_fraction": 0.45,
263+
"aromatic_fraction": 0.0, "hydrophobic_moment": 0.0,
264+
}
265+
s_no_helix = activity_likeness_score({**base, "helix_propensity": 1.0})
266+
s_full_helix = activity_likeness_score({**base, "helix_propensity": 1.20})
267+
assert abs((s_full_helix - s_no_helix) - 0.03) < 0.001
268+
269+
def test_helix_bonus_partial_at_pa_110(self):
270+
# helix_pa=1.10 → clamp01(0.10/0.20)=0.5 → bonus=0.5*0.03=0.015
271+
base = {
272+
"length": 18, "charge_density": 0.30, "hydrophobic_fraction": 0.45,
273+
"aromatic_fraction": 0.0, "hydrophobic_moment": 0.0,
274+
}
275+
s_no_helix = activity_likeness_score({**base, "helix_propensity": 1.0})
276+
s_half_helix = activity_likeness_score({**base, "helix_propensity": 1.10})
277+
assert abs((s_half_helix - s_no_helix) - 0.015) < 0.001
278+
279+
def test_score_ceiling_is_0_97(self):
280+
# All components at maximum: ceiling = 0.24+0.27+0.17+0.10+0.14+0.03+0.02 = 0.97
281+
all_max = {
282+
"length": 18, "charge_density": 0.50, "hydrophobic_fraction": 0.45,
283+
"aromatic_fraction": 0.20, "hydrophobic_moment": 0.80,
284+
"helix_propensity": 1.20,
285+
}
286+
assert activity_likeness_score(all_max) == 0.97
287+
288+
258289
class TestKnownAMPs:
259290
def test_magainin_like_scores_well(self):
260291
# KWKLFKKIGAVLKVL — canonical AMP-like sequence

‎tests/test_scoring_synthesis.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,12 @@ def test_proline_penalty_stacks_with_other_penalties(self):
134134
feat = {"length": 15, "longest_repeat_run": 5, "cysteine_fraction": 0.25, "proline_fraction": 0.20}
135135
score = synthesis_feasibility_score(feat)
136136
assert abs(score - 0.65) < 0.001
137+
138+
def test_proline_stacks_with_aggregation_propensity(self):
139+
# agg=0.4: min(0.4*0.25, 0.20)=0.10 penalty; pro=0.20: 0.10 penalty → 1.0-0.20=0.80
140+
feat = {
141+
"length": 15, "longest_repeat_run": 1, "cysteine_fraction": 0.0,
142+
"aggregation_propensity": 0.4, "proline_fraction": 0.20,
143+
}
144+
score = synthesis_feasibility_score(feat)
145+
assert abs(score - 0.80) < 0.001

0 commit comments

Comments
 (0)