#!/bin/bash
#
# This script creates a self-contained Python environment, installs all necessary
# dependencies, and runs the standalone analysis suite to reproduce the
# cross-model analysis report.

# Exit immediately if a command exits with a non-zero status.
set -e

echo "--- Setting up Python virtual environment ---"
python3 -m venv venv
source venv/bin/activate

echo "--- Installing required dependencies ---"
pip install pandas numpy matplotlib seaborn statsmodels lifelines Jinja2

echo "--- Running the standalone analysis suite ---"
# Create a timestamped directory for the report to avoid overwriting.
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
OUTPUT_DIR="./analysis_report_${TIMESTAMP}"

# The script is at the root level, and the analysis script is in 'scripts/'.
# The suite directory is the current folder ('.').
python scripts/analyze_standalone.py \
    --suite_directory ./ \
    --output_directory "${OUTPUT_DIR}" \
    --survival-prob-range 0.4 1.0

echo "--- Analysis complete. Report generated in ${OUTPUT_DIR} ---"
deactivate
