#!/usr/bin/env bash # Build bcftools + gtc2vcf plugins (MIT) under refs/tools and generate oracle GTC files from the P0 GSA demo IDATs. # Usage: bash scripts/make_oracle_gtcs.sh [chip-folder ...] (default: every chip in the demo set) set -euo pipefail cd "$(dirname "$0")/.." V=1.22 T=refs/tools B=$T/bcftools-$V if [[ ! -x $B/bcftools || ! -f $B/plugins/idat2gtc.so ]]; then [[ -d refs/gtc2vcf ]] || bash scripts/bootstrap_refs.sh mkdir -p $T [[ -f $T/bcftools.tar.bz2 ]] || curl -sL -o $T/bcftools.tar.bz2 \ "https://github.com/samtools/bcftools/releases/download/$V/bcftools-$V.tar.bz2" tar -xjf $T/bcftools.tar.bz2 -C $T rm -f $B/plugins/{idat2gtc,gtc2vcf,affy2vcf}.{c,h} cp refs/gtc2vcf/{idat2gtc,gtc2vcf,affy2vcf}.c refs/gtc2vcf/*.h $B/plugins/ (cd $B/htslib-$V && ./configure --disable-libcurl --disable-bz2 --disable-lzma --disable-ref-cache >/dev/null) (cd $B && ./configure --without-gsl >/dev/null && make -j"$(nproc)" >/dev/null) fi export BCFTOOLS_PLUGINS=$B/plugins D=data/p0/gsa_v4_pgx IDATS=$D/idats_Demo_36/idats_Demo_36 OUT=data/p0/oracle/gsa_gtc_gtc2vcf mkdir -p "$OUT" chips=("$@") [[ ${#chips[@]} -eq 0 ]] && mapfile -t chips < <(find "$IDATS" -mindepth 1 -maxdepth 1 -type d | sort) for chip in "${chips[@]}"; do $B/bcftools +idat2gtc \ --bpm $D/GSA-PGx-48v4-0_20079540_E2_bpm/GSA-PGx-48v4-0_20079540_E2.bpm \ --egt $D/GSA-PGx-48v4-0_20079540_E2_ClusterFile/GSA-PGx-48v4-0_20079540_E2_ClusterFile.egt \ --idats "$chip" --output "$OUT" 2>&1 | grep -E "^(Call rate|Gender|Writing)" || true done $B/bcftools +idat2gtc --version 2>&1 | head -2 || true echo "oracle GTCs in $OUT: $(ls "$OUT"/*.gtc | wc -l)"