#!/usr/bin/env bash
# TCM-stroke network-pharmacology null-model control: end-to-end reproduction.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

PY=~/joulebeat-evolve/outreach/env/bin/python
export OMP_NUM_THREADS=2

mkdir -p data figs logs

if [ ! -s data/CTD_chem_gene_ixns.tsv.gz ]; then
  curl -sS --max-time 300 -o data/CTD_chem_gene_ixns.tsv.gz \
    "https://ctdbase.org/reports/CTD_chem_gene_ixns.tsv.gz"
fi
if [ ! -s data/CTD_curated_genes_diseases.tsv.gz ]; then
  curl -sS --max-time 120 -o data/CTD_curated_genes_diseases.tsv.gz \
    "https://ctdbase.org/reports/CTD_curated_genes_diseases.tsv.gz"
fi
if [ ! -s data/protein.physical.links.v12.0.txt.gz ]; then
  curl -sS --max-time 120 -o data/protein.physical.links.v12.0.txt.gz \
    "https://stringdb-downloads.org/download/protein.physical.links.v12.0/9606.protein.physical.links.v12.0.txt.gz"
fi
if [ ! -s data/protein.info.v12.0.txt.gz ]; then
  curl -sS --max-time 120 -o data/protein.info.v12.0.txt.gz \
    "https://stringdb-downloads.org/download/protein.info.v12.0/9606.protein.info.v12.0.txt.gz"
fi

"$PY" run_experiment.py \
  --seeds 0 1 2 --thresholds 400 700 900 --primary-threshold 700 \
  --null-reps 1000 --out raw_results.json --time-budget-sec 1000

"$PY" summarize.py
"$PY" make_figures.py
