Docking_project / libs /docking /constraints.py
QPromaQ's picture
Upload folder using huggingface_hub
c289d87 verified
Raw
History Blame Contribute Delete
2.17 kB
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