Skip to content

Instantly share code, notes, and snippets.

@astatham
Last active September 9, 2015 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astatham/d3e45ba60cc19a1adc18 to your computer and use it in GitHub Desktop.
Save astatham/d3e45ba60cc19a1adc18 to your computer and use it in GitHub Desktop.
Convert a hg19 vcf to a b37d5 vcf - only handles chr1-22, X, Y & M
#!/bin/bash -e
if [[ ! -f "${1}" ]] ; then
echo "File $1 does not exist, aborting."
exit 1
fi
# Replace double digit chromosomes first
cmd="sed"
for i in `seq 10 22` `seq 1 9` X Y; do
cmd="$cmd -e 's/chr$i/$i/g'"
done
# chrM to chrMT
cmd="$cmd -e 's/chrM/MT/g'"
# Add input and output
cmd="$cmd $1 > ${1%.vcf}.b37d5.vcf"
# Execute
echo $cmd
eval $cmd
@drmjc
Copy link

drmjc commented Jul 23, 2015

cheers. shouldn't that be
's/chrM/MT/g'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment