a87327b5ef28209e7a809728fb3bc8fb476dfdb8
angie
  Fri Jun 15 15:17:01 2018 -0700
Adding liftOverBigWig for lifting from one assembly to another, and liftOverBigWigToPatches for lifting main chromosome scores to patch sequences and concatenating the results onto the original annotations.  refs #18853

diff --git src/hg/utils/liftOverBigWigToPatches src/hg/utils/liftOverBigWigToPatches
new file mode 100755
index 0000000..1305ce8
--- /dev/null
+++ src/hg/utils/liftOverBigWigToPatches
@@ -0,0 +1,40 @@
+#!/bin/env tcsh
+
+# Convert bigWig to bedGraph, liftOver the bedGraph from regular chroms to patches,
+# clean up and concatenate the results and regenerate bigWig.
+
+set bigWigIn = $1
+set liftOverFile = $2
+set chromSizes = $3
+set bigWigOut = $4
+
+if ($bigWigOut == "" || $5 != "") then
+  echo "usage:"
+  echo "$0 input.bw mainToPatches.over.chain.gz chrom.sizes output.bw"
+  echo ""
+  echo "Convert input.bw to bedGraph, liftOver from main chromosomes to patches,"
+  echo "clean up and concatenate the results and convert to output.destDb.bw"
+  exit 1
+endif
+
+set tmpFile1 = `mktemp --tmpdir liftOverBigWig.XXXXXX`
+set tmpFile2 = `mktemp --tmpdir liftOverBigWig.XXXXXX`
+set tmpFile3 = `mktemp --tmpdir liftOverBigWig.XXXXXX`
+if ($status) exit
+
+bigWigToBedGraph $bigWigIn $tmpFile1
+if ($status) exit
+
+liftOver -multiple -noSerial $tmpFile1 $liftOverFile stdout /dev/null \
+| sort -k1,1 -k2n,2n \
+| bedRemoveOverlap stdin stdout \
+| bedGraphPack stdin $tmpFile2
+if ($status) exit
+
+sort -k1,1 -k2n,2n $tmpFile1 $tmpFile2 > $tmpFile3
+if ($status) exit
+
+bedGraphToBigWig $tmpFile3 $chromSizes $bigWigOut
+if ($status) exit
+
+rm $tmpFile1 $tmpFile2 $tmpFile3