File size: 4,222 Bytes
5b3b0dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""Scope checks for the publicly released BioInteract code and Space."""

import json
from pathlib import Path


SPACE = Path(__file__).resolve().parent
PROJECT = SPACE.parent


def _read(path: Path) -> str:
    return path.read_text(encoding="utf-8").lower()


def test_space_retains_only_the_custom_demonstration_workflow():
    app = _read(SPACE / "app.py")

    required = (
        "binary high-affinity interaction classification",
        "model-native atom-residue attention attribution",
        "high-affinity-class classifier score (sigmoid output)",
        "512-residue",
        "1,200-residue",
        "not numerically equivalent",
        "unknown-domain representation",
        "initialised during application startup",
        "target-id-held-out",
        "not physical contacts",
    )
    for phrase in required:
        assert phrase in app

    prohibited = (
        "_fixed_cases",
        "show_case_study",
        "case studies",
        "high-affinity-class probability",
        "far from threshold",
        "near threshold",
        "confidence",
        "probability",
        "ax.axvline(0.5",
        "threshold",
        "initialises on the first request",
        "binding score",
    )
    for phrase in prohibited:
        assert phrase not in app


def test_space_warns_only_when_raw_sequence_exceeds_the_512_residue_limit():
    app = _read(SPACE / "app.py")

    assert "raw_sequence_length = len(sequence)" in app
    assert "if raw_sequence_length > max_seq_len:" in app
    assert "if len(sequence) == max_seq_len:" not in app
    assert app.index("raw_sequence_length = len(sequence)") < app.index("sequence = sequence[:max_seq_len]")


def test_readmes_disclose_supported_task_limits_and_runner_names():
    space_readme = _read(SPACE / "readme.md")
    root_readme = _read(PROJECT / "readme.md")

    required_scope = (
        "binary high-affinity interaction classification",
        "model-native atom-residue attention attribution",
        "classifier score",
        "512-residue",
        "1,200-residue",
        "not numerically equivalent",
        "unknown-domain representation",
        "target-id-held-out",
        "not physical contacts",
    )
    for document in (space_readme, root_readme):
        for phrase in required_scope:
            assert phrase in document

    assert "src.experiments.run_split_final" in root_readme
    assert "revision/run_strict_split_evaluation.py" in root_readme
    for document in (space_readme, root_readme):
        for phrase in ("case studies", "binding probability", "hotspot", "binding-pocket mapping"):
            assert phrase not in document


def test_shipped_example_is_global_statistics_only_and_claim_safe():
    payload = json.loads((SPACE / "examples" / "interpretability_report.json").read_text(encoding="utf-8"))
    assert set(payload) == {"global_stats"}
    assert payload["global_stats"]

    public_json = json.dumps(payload).lower()
    for phrase in (
        "abl1",
        "case_studies",
        "hotspot",
        "pocket",
        "resistance",
        "mutant",
        "contact",
        "probability",
    ):
        assert phrase not in public_json


def test_public_operational_sources_do_not_emit_unsupported_case_or_structure_claims():
    files = (
        PROJECT / "configs" / "default.yaml",
        PROJECT / "src" / "cli" / "interpret.py",
        PROJECT / "src" / "data" / "protein_feat.py",
        PROJECT / "src" / "data" / "split.py",
        PROJECT / "src" / "analysis" / "generate_figures.py",
    )
    public_source = "\n".join(_read(path) for path in files)

    assert "configured domain-label channel" in public_source
    assert "none" in public_source
    assert "target-id-held-out" in public_source
    for phrase in (
        "case study",
        "case_stud",
        "hotspot",
        "binding pocket",
        "binding-site",
        "pdb-validated",
        "resistance",
        "mutant",
        "predicted binding probability",
        "high-confidence prediction",
    ):
        assert phrase not in public_source