#!/usr/bin/env bash # 24-html-report.sh — Generate a self-contained HTML report of all pipeline results # Usage: ./scripts/24-html-report.sh # # Reads every step's output once into ${SAMPLE}/summary.json (og summary # collect, run by bin/render_report.py) and renders the HTML report from it. # generate-report.sh renders the text report from the same summary when # nothing has changed since, so the two reports show the same values. A result from an # earlier run whose step was skipped or failed in the latest run-all.sh run is # marked stale with its date. No internet connection is needed to view it. # ${SAMPLE}_search_index.json lists every gene and rsID the results mention # (bin/results_index.py), for the report's closing list and the live search. set -euo pipefail SAMPLE=${1:?Usage: $0 } GENOME_DIR=${GENOME_DIR:?Set GENOME_DIR to your data directory} # shellcheck source=lib/common.sh . "$(dirname "$0")/lib/common.sh" validate_sample "$SAMPLE" SAMPLE_DIR="${GENOME_DIR}/${SAMPLE}" OUTPUT="${SAMPLE_DIR}/${SAMPLE}_report.html" if [ ! -d "$SAMPLE_DIR" ]; then echo "ERROR: Sample directory not found: ${SAMPLE_DIR}" >&2 exit 1 fi echo "============================================" echo " Step 24: HTML Report Generator" echo " Sample: ${SAMPLE}" echo " Output: ${OUTPUT}" echo "============================================" echo "" # What produced these outputs: run-all.sh writes the manifest when a run # starts; a sample without one gets it now. if [ ! -f "${SAMPLE_DIR}/run_manifest.tsv" ]; then GENOME_DIR="$GENOME_DIR" bash "${PGP_ROOT}/bin/write_manifest.sh" "$SAMPLE" 24-html-report.sh fi echo "Reading pipeline outputs and writing the report..." rm -f "$OUTPUT" "${SAMPLE_DIR}/${SAMPLE}_search_index.json" "${SAMPLE_DIR}/${SAMPLE}_charts.json" # assets/: the ACMG SF rules (acmg_sf.tsv) and the carrier list (carrier_genes.tsv). run_in -v "${PGP_ROOT}/bin:/pgp-bin:ro" -v "${PGP_ROOT}/assets:/pgp-assets:ro" "${PYTHON_IMAGE}" \ python3 /pgp-bin/render_report.py \ --assets /pgp-assets \ --sample "$SAMPLE" \ --sample-dir "/genome/${SAMPLE}" \ --json "/genome/${SAMPLE}/summary.json" \ -o "/genome/${SAMPLE}/${SAMPLE}_report.html" \ --search-index "/genome/${SAMPLE}/${SAMPLE}_search_index.json" \ --charts-json "/genome/${SAMPLE}/${SAMPLE}_charts.json" if [ ! -f "$OUTPUT" ]; then echo "ERROR: the report was not written: ${OUTPUT}" >&2 exit 1 fi REPORT_KB=$(( $(wc -c < "$OUTPUT") / 1024 )) echo "" echo "============================================" echo " HTML report generated: ${OUTPUT}" echo " Summary: ${SAMPLE_DIR}/summary.json" echo " Search index: ${SAMPLE_DIR}/${SAMPLE}_search_index.json" echo " Charts: ${SAMPLE_DIR}/${SAMPLE}_charts.json" echo " Size: ${REPORT_KB} KB" echo "============================================" echo "" echo "Open in your browser:" echo " open ${OUTPUT} # macOS" echo " xdg-open ${OUTPUT} # Linux" echo " start ${OUTPUT} # Windows (WSL)"