#!/usr/bin/env bash
# One-command reproduction. Streams 10 FinnGen R13 GWAS summary-stat files
# (curl|zcat|mawk, nothing landed as a full local copy) and runs the full
# analysis. The fetch phase is chunked into SINGLE_SHOT=1 sub-invocations
# (one new download per invocation, resumable via .done marker files) so
# a single run never holds one long-lived process across many downloads;
# each sub-invocation naturally exits once it has done one fetch.
set -euo pipefail
cd "$(dirname "$0")"
export OMP_NUM_THREADS=2
mkdir -p logs figs data
PY=~/joulebeat-evolve/outreach/env/bin/python

for i in $(seq 1 12); do
  SINGLE_SHOT=1 "$PY" run_experiment.py || true
done

# By now all 10 fetches are marked .done (or failed after retries, in which
# case this final call will error loudly) -> this call runs clumping,
# null/bootstrap stats, figures and results.json.
SINGLE_SHOT=0 "$PY" run_experiment.py
