File size: 2,169 Bytes
c289d87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

from pathlib import Path


def write_receptor_prm(
    receptor_mol2: str | Path,
    reference_ligand_sdf: str | Path,
    out_path: str | Path,
    radius: float = 6.0,
) -> Path:
    """Write receptor parameter file required by rbcavity/rbdock."""
    receptor_path = Path(receptor_mol2).resolve()
    reference_path = Path(reference_ligand_sdf).resolve()

    payload = (
        "RBT_PARAMETER_FILE_V1.00\n"
        "TITLE rdock_receptor\n"
        f"RECEPTOR_FILE {receptor_path}\n"
        "\n"
        "SECTION MAPPER\n"
        "    SITE_MAPPER RbtLigandSiteMapper\n"
        f"    REF_MOL {reference_path}\n"
        f"    RADIUS {radius:.1f}\n"
        "    SMALL_SPHERE 1.5\n"
        "END_SECTION\n"
        "\n"
        "SECTION CAVITY\n"
        "    SCORING_FUNCTION RbtCavityGridSF\n"
        "END_SECTION\n"
    )

    target = Path(out_path)
    target.parent.mkdir(parents=True, exist_ok=True)
    target.write_text(payload, encoding="utf-8")
    return target


def write_receptor_prm_sphere(
    receptor_mol2: str | Path,
    center: tuple[float, float, float],
    radius: float,
    out_path: str | Path,
) -> Path:
    """Write receptor prm using a fixed sphere mapper (stable pocket definition)."""
    receptor_path = Path(receptor_mol2).resolve()
    cx, cy, cz = float(center[0]), float(center[1]), float(center[2])
    rad = float(radius)

    payload = (
        "RBT_PARAMETER_FILE_V1.00\n"
        "TITLE rdock_receptor_fixed_pocket\n"
        f"RECEPTOR_FILE {receptor_path}\n"
        "\n"
        "SECTION MAPPER\n"
        "    SITE_MAPPER RbtSphereSiteMapper\n"
        f"    CENTER ({cx:.4f},{cy:.4f},{cz:.4f})\n"
        f"    RADIUS {rad:.3f}\n"
        "    SMALL_SPHERE 1.5\n"
        "    MIN_VOLUME 100\n"
        "    MAX_CAVITIES 1\n"
        "    VOL_INCR 0.0\n"
        "    GRIDSTEP 0.5\n"
        "END_SECTION\n"
        "\n"
        "SECTION CAVITY\n"
        "    SCORING_FUNCTION RbtCavityGridSF\n"
        "END_SECTION\n"
    )

    target = Path(out_path)
    target.parent.mkdir(parents=True, exist_ok=True)
    target.write_text(payload, encoding="utf-8")
    return target