File size: 1,139 Bytes
504d922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

from pathlib import Path
from typing import Optional


def pdb_to_pdbqt_placeholder(pdb_path: str | Path, out_path: str | Path) -> Path:
    """Placeholder conversion hook. Copies source content for adapter-level wiring tests."""
    source = Path(pdb_path)
    target = Path(out_path)
    target.parent.mkdir(parents=True, exist_ok=True)
    target.write_text(source.read_text(encoding="utf-8"), encoding="utf-8")
    return target


def smiles_to_sdf_placeholder(smiles: str, ligand_id: str, out_path: str | Path) -> Path:
    """Write minimal placeholder SDF-like file used when backend preprocessing is unavailable."""
    target = Path(out_path)
    target.parent.mkdir(parents=True, exist_ok=True)
    payload = f"{ligand_id}\n  generated\n\n0  0  0  0  0  0            999 V2000\nM  END\n>  <SMILES>\n{smiles}\n\n$$$$\n"
    target.write_text(payload, encoding="utf-8")
    return target


def maybe_float(value: object, default: Optional[float] = None) -> Optional[float]:
    try:
        return float(value)  # type: ignore[arg-type]
    except (TypeError, ValueError):
        return default