"""Project initialization helpers."""

from __future__ import annotations

from pathlib import Path

from babappa.config import write_default_config


def init_project(path: str | Path) -> Path:
    root = Path(path)
    root.mkdir(parents=True, exist_ok=True)
    for rel in ["data/alignments", "data/trees", "results", "logs"]:
        (root / rel).mkdir(parents=True, exist_ok=True)

    write_default_config(root / "babappa_config.yaml")

    commands = """# Example BABAPPA commands
babappa validate --alignment data/alignments/geneA.fasta --tree data/trees/tree.nwk --outdir results/validate
babappa fit-null --alignment data/alignments/geneA.fasta --tree data/trees/tree.nwk --outdir results/fit_null --seed 7
babappa score --alignment data/alignments/geneA.fasta --tree data/trees/tree.nwk --bundle results/fit_null/null_bundle.json --outdir results/score --seed 7
babappa adjust --scores results/score/scores.tsv --outdir results/adjust
babappa report --scores results/adjust/scores_adjusted.tsv --outdir results/report
"""
    (root / "example_commands.sh").write_text(commands, encoding="utf-8")
    return root
