Created
March 30, 2011 14:59
-
-
Save brentp/894555 to your computer and use it in GitHub Desktop.
liftOver shell script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage ./lift.sh input input.version output.version "FLAGS" | |
# | |
# e.g: lift.sh Homo_sapiens.GRCh37.61.gtf hg19 hg18 -gff | |
# will map hg19 features to hg18 coordinates. | |
if [ -z $3 ] | |
then | |
echo "usage: lift Homo_sapiens.GRCh37.61.gtf hg19 hg18 -gff" | |
exit 1 | |
fi | |
DIR=~/.lift/ | |
mkdir -p $DIR | |
INPUT=$1 | |
FROM_VERSION=$2 | |
TO_VERSION=$3 | |
FLAGS=$4 | |
TO_CAPS=`echo $TO_VERSION | sed 's/\<./\u&/'` | |
if [[ ! -f $DIR/liftOver ]] | |
then | |
wget -O $DIR/liftOver http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/liftOver | |
chmod +x $DIR/liftOver | |
fi | |
CHAINF=${FROM_VERSION}To${TO_CAPS}.over.chain | |
if [[ ! -f $DIR/$CHAINF ]] | |
then | |
wget -O $DIR/$CHAINF.gz http://hgdownload.cse.ucsc.edu/goldenPath/${FROM_VERSION}/liftOver/${CHAINF}.gz | |
gunzip $DIR/${CHAINF}.gz | |
fi | |
OUTPUT=$INPUT.$TO_VERSION | |
$DIR/liftOver $FLAGS -minMatch=0.8 $INPUT $DIR/$CHAINF $OUTPUT $OUTPUT.unmapped | |
wc -l $OUTPUT | |
wc -l $OUTPUT.unmapped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is amazing - thank you!