QPromaQ's picture
Reset repository and upload final project (part 30)
504d922 verified
Raw
History Blame Contribute Delete
1.14 kB
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