From 1a66f49d15cc885d3e668c8087c4fc77db68d127 Mon Sep 17 00:00:00 2001 From: Christopher Tabone Date: Tue, 17 Feb 2026 00:34:08 +0000 Subject: [PATCH] Add scRNAseq metadata copy-forward script Shell script that copies scRNAseq metadata files from the previous release to the current one, renaming them appropriately. These files don't change between releases (until a new scRNAseq curator is hired). Reads RELEASE, PREV_RELEASE, and BUILD_DIR from GoCD environment. Intended to be wired up as a GoCD stage before other bulk report scripts. --- src/copy_scrna_metadata.sh | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 src/copy_scrna_metadata.sh diff --git a/src/copy_scrna_metadata.sh b/src/copy_scrna_metadata.sh new file mode 100755 index 0000000..0f926d1 --- /dev/null +++ b/src/copy_scrna_metadata.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# copy_scrna_metadata.sh +# +# Copies scRNAseq metadata files forward from the previous release, +# renaming them for the current release. These files don't change +# between releases (until a new scRNAseq curator is hired at Cambridge). +# +# Expects GoCD environment variables: +# RELEASE - current release (e.g., 2025_06) +# PREV_RELEASE - previous release (e.g., 2025_05) +# BUILD_DIR - build directory (e.g., /data/build-public-release) +# +# Usage: +# copy_scrna_metadata.sh +# + +set -euo pipefail + +# Validate required environment variables +for var in RELEASE PREV_RELEASE BUILD_DIR; do + if [ -z "${!var:-}" ]; then + echo "ERROR: Required environment variable $var is not set." >&2 + exit 1 + fi +done + +PREV_DIR="${BUILD_DIR}/fb_${PREV_RELEASE}_reporting/bulk_reports" +CURR_DIR="${BUILD_DIR}/fb_${RELEASE}_reporting/bulk_reports" + +FILES=( + "scRNAseq_metadata_fb_YYYY_MM_reporting.json" + "scRNAseq_metadata_schema_fb_YYYY_MM_reporting.yaml" +) + +echo "Copying scRNAseq metadata from ${PREV_RELEASE} to ${RELEASE}..." +echo " Source: ${PREV_DIR}" +echo " Dest: ${CURR_DIR}" + +# Verify source directory exists +if [ ! -d "${PREV_DIR}" ]; then + echo "ERROR: Previous release directory not found: ${PREV_DIR}" >&2 + exit 1 +fi + +# Verify destination directory exists +if [ ! -d "${CURR_DIR}" ]; then + echo "ERROR: Current release directory not found: ${CURR_DIR}" >&2 + exit 1 +fi + +for template in "${FILES[@]}"; do + src_file="${PREV_DIR}/${template//YYYY_MM/${PREV_RELEASE}}" + dst_file="${CURR_DIR}/${template//YYYY_MM/${RELEASE}}" + + if [ ! -f "${src_file}" ]; then + echo "ERROR: Source file not found: ${src_file}" >&2 + exit 1 + fi + + cp "${src_file}" "${dst_file}" + echo " OK: $(basename "${dst_file}") ($(stat -c%s "${dst_file}") bytes)" +done + +echo "Done. scRNAseq metadata files copied successfully."