Sunday, September 23, 2012

Creating unix command for Picard JAR files

Picard (http://picard.sourceforge.net/) is a nice Java-based toolkit to work with BAM and SAM files.
Usually I don't like to type "java -jar" when calling picard tools so I always wrap them in bash scripts with the script below:

#!/bin/sh
picard_jars='/data_alpha/local/bioinformatic_tools/picard-tools-1.77'
bin="$picard_jars/bin"
for i in $picard_jars/*.jar
do
command_name=`echo $i | perl -plane 's/.*\/(\S+).jar/$1/g'`
echo $command_name
echo '#!/usr/bin/env sh' > $bin/$command_name
echo 'java -jar '$i' $@' >> $bin/$command_name
chmod +x $bin/$command_name
done