Samad14 commited on
Commit
e86be3a
Β·
1 Parent(s): a6857c7

fix: check obabel availability early with clear error message, use OBABEL_CMD variable

Browse files
bioai-platform/backend/app/tools/docking.py CHANGED
@@ -16,6 +16,7 @@ logger = logging.getLogger(__name__)
16
 
17
  PDB_DOWNLOAD = "https://files.rcsb.org/download/{pdb_id}.pdb"
18
  VINA_CMD = shutil.which("vina") or "/usr/local/bin/vina"
 
19
 
20
  # ── interaction cutoffs ──────────────────────────────────────────────────
21
  HBOND_DIST = 3.5 # donor–acceptor heavy-atom distance (Γ…)
@@ -465,6 +466,9 @@ class DockingTool(BaseTool):
465
  if not smiles:
466
  return {"error": "smiles is required"}
467
 
 
 
 
468
  tmpdir = tempfile.mkdtemp(prefix="docking_")
469
  try:
470
  # 1. Fetch PDB
@@ -489,7 +493,7 @@ class DockingTool(BaseTool):
489
  # 3. Convert protein to PDBQT via obabel
490
  protein_pdbqt = os.path.join(tmpdir, "protein.pdbqt")
491
  proc = await asyncio.create_subprocess_exec(
492
- "obabel", clean_path, "-O", protein_pdbqt, "-xr",
493
  stdout=asyncio.subprocess.PIPE,
494
  stderr=asyncio.subprocess.PIPE,
495
  )
 
16
 
17
  PDB_DOWNLOAD = "https://files.rcsb.org/download/{pdb_id}.pdb"
18
  VINA_CMD = shutil.which("vina") or "/usr/local/bin/vina"
19
+ OBABEL_CMD = shutil.which("obabel")
20
 
21
  # ── interaction cutoffs ──────────────────────────────────────────────────
22
  HBOND_DIST = 3.5 # donor–acceptor heavy-atom distance (Γ…)
 
466
  if not smiles:
467
  return {"error": "smiles is required"}
468
 
469
+ if not OBABEL_CMD:
470
+ return {"error": "Dependencies missing: Open Babel (obabel) is not installed on the server. Please install it via `apt install obabel` or `conda install -c conda-forge openbabel`."}
471
+
472
  tmpdir = tempfile.mkdtemp(prefix="docking_")
473
  try:
474
  # 1. Fetch PDB
 
493
  # 3. Convert protein to PDBQT via obabel
494
  protein_pdbqt = os.path.join(tmpdir, "protein.pdbqt")
495
  proc = await asyncio.create_subprocess_exec(
496
+ OBABEL_CMD, clean_path, "-O", protein_pdbqt, "-xr",
497
  stdout=asyncio.subprocess.PIPE,
498
  stderr=asyncio.subprocess.PIPE,
499
  )