"""Optional comparator adapters (PAML/HyPhy)."""

from __future__ import annotations

import shutil
from pathlib import Path


def detect_comparators() -> dict[str, bool]:
    return {
        "codeml": shutil.which("codeml") is not None,
        "hyphy": shutil.which("hyphy") is not None,
    }


def write_comparator_note(outdir: str | Path) -> Path:
    out = Path(outdir)
    out.mkdir(parents=True, exist_ok=True)
    avail = detect_comparators()
    lines = [
        "Comparator adapters are optional and not required for BABAPPA core functionality.",
        f"codeml available: {avail['codeml']}",
        f"hyphy available: {avail['hyphy']}",
        "If available, users can run codeml/HyPhy externally and merge summaries into benchmark interpretation.",
    ]
    note = out / "comparator_status.txt"
    note.write_text("\n".join(lines) + "\n", encoding="utf-8")
    return note
