f665d4cc3b02924a8507b2f910eaf85eab54d433
braney
  Sat Jul 18 14:12:24 2026 -0700
hprc2X: left-shifted HPRC r2 deletion analysis and external-catalog cross-reference scripts

Deletion-only re-derivation of the HPRC Release 2 rearrangement track used to
test left-shifting indel placement and to measure how the deletions correspond
to dbSNP, DGV, ClinVar, and the previous (rel1) release. Includes the unbounded
left-normalizer, the aggregation and subsampling drivers, the stability and
cross-release carryover analyses, and the dbSNP rs cross-reference prototype.
See README.txt for the manifest; full results and cached data live in
/hive/data/genomes/hg38/bed/hprc2X.

refs #37891

diff --git src/hg/makeDb/scripts/hprc2X/buildFullXref.sh src/hg/makeDb/scripts/hprc2X/buildFullXref.sh
new file mode 100644
index 00000000000..833799d797b
--- /dev/null
+++ src/hg/makeDb/scripts/hprc2X/buildFullXref.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+set -beEu -o pipefail
+D=/hive/data/genomes/hg38/bed/hprc2X; TB=/hive/data/genomes/hg38/hg38.2bit
+BB=/gbdb/hg38/snp/dbSnp155.bb
+export PATH=$HOME/bin/x86_64:/cluster/bin/x86_64:$PATH
+SC=~/kent/src/hg/makeDb/scripts/hprc2X
+chroms=$(cut -d: -f1 $D/hprc2Del.canon.named | sort -u)   # chroms present in hprc2Del
+
+# per-chrom: extract class=del from full dbSnp155, left-normalize carrying rs -> key<TAB>rs
+one() {
+  c=$1; D=/hive/data/genomes/hg38/bed/hprc2X; TB=/hive/data/genomes/hg38/hg38.2bit
+  BB=/gbdb/hg38/snp/dbSnp155.bb; SC=~/kent/src/hg/makeDb/scripts/hprc2X
+  export PATH=$HOME/bin/x86_64:/cluster/bin/x86_64:$PATH
+  bigBedToBed $BB -chrom=$c stdout 2>/dev/null \
+    | awk -F'\t' 'BEGIN{OFS="\t"}$14=="del"{print $1,$2,$3,$4}' > $D/dbsnp155del/$c.del
+  python3 $SC/leftNormDel.py $TB $D/dbsnp155del/$c.del 4 \
+    | awk 'BEGIN{OFS="\t"}{k=$1":"$2":"$4; if(k in m)m[k]=m[k]","$5; else m[k]=$5} END{for(x in m)print x,m[x]}' \
+    | sort > $D/dbsnp155del/$c.canon.rs
+  echo "$c: $(wc -l < $D/dbsnp155del/$c.del) dels -> $(wc -l < $D/dbsnp155del/$c.canon.rs) keys"
+}
+export -f one
+echo "$chroms" | parallel -j 12 one {}
+
+# combine all chroms; merge any duplicate keys across (shouldn't cross chroms, but safe)
+sort -m $D/dbsnp155del/*.canon.rs > $D/dbSnp155.canon.rs
+echo "TOTAL full-dbSnp155 canonical del keys: $(wc -l < $D/dbSnp155.canon.rs)"
+
+# join to every hprc2Del event (left join)
+join -t $'\t' -a1 -1 1 -2 1 -o '1.2,2.2,1.1' \
+   $D/hprc2Del.canon.named $D/dbSnp155.canon.rs > $D/hprc2Del.xrefFull.tsv
+awk -F'\t' '{tot++; if($2!="")m++} END{printf "hprc2Del events with FULL-dbSnp155 rs: %d / %d = %.2f%%\n", m, tot, 100*m/tot}' \
+   $D/hprc2Del.xrefFull.tsv
+echo "DONE"