Skip to content

Instantly share code, notes, and snippets.

@pjbriggs
Created May 2, 2013 11:26
Show Gist options
  • Save pjbriggs/5501613 to your computer and use it in GitHub Desktop.
Save pjbriggs/5501613 to your computer and use it in GitHub Desktop.
Utility script to create bigWig files from phastCons wig data files. Needs the chromosome sizes which can be obtained by doing e. "fetchChromSizes mm9 > mm9chromSizes". For each .data file in the specified directory, runs wigToBigWig to generate corresponding .bw file.
#!/bin/sh
#
CHROMSIZE_FILE=$1
if [ -z "$CHROMSIZE_FILE" ] ; then
echo "Usage: $0 CHROMSIZE_FILE [ DATA_DIR ]"
exit
fi
if [ -z "$2" ] ; then
DATA_DIR=`pwd`
else
DATA_DIR=$2
fi
data_files=`ls $DATA_DIR/*.data`
for f in $data_files ; do
echo $f
bw=`basename $f`
bw=${bw%.*}.bw
if [ -f "$bw" ] ; then
echo "$bw already exists"
else
wigToBigWig -clip $f $CHROMSIZE_FILE $bw
if [ ! -f "$bw" ] ; then
echo "Failed to make $bw"
exit
fi
fi
done
##
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment