Skip to content

Instantly share code, notes, and snippets.

@chapmanb
Created January 31, 2014 13:25
Show Gist options
  • Save chapmanb/8732049 to your computer and use it in GitHub Desktop.
Save chapmanb/8732049 to your computer and use it in GitHub Desktop.
Bash wrapper script for snpeff
#!/bin/bash
# snpEff executable shell script
# http://snpeff.sourceforge.net/
# Extracts memory and system property Java arguments from the list of provided arguments
# (ie -Xms 1g -Xmx 2g)
jardir="$(cd "$(dirname "$0")" && pwd -P)"
java=java
if [ -e "$JAVA_HOME/bin/java" ]
then
java="$JAVA_HOME/bin/java"
fi
default_jvm_mem_opts="-Xms512m -Xmx1g"
jvm_mem_opts=""
jvm_prop_opts=""
pass_args=""
for arg in "$@"; do
case $arg in
'-D'*)
jvm_prop_opts="$jvm_prop_opts $arg"
;;
'-Xm'*)
jvm_mem_opts="$jvm_mem_opts $arg"
;;
*)
pass_args="$pass_args $arg"
;;
esac
done
if [ "$jvm_mem_opts" == "" ]; then
jvm_mem_opts="$default_jvm_mem_opts"
fi
if [[ "$pass_args" != "" && "$pass_args" != *-c* ]]; then
pass_args="$pass_args -c ${jardir}/snpEff.config"
fi
exec java $jvm_mem_opts $jvm_prop_opts -jar ${jardir}/snpEff.jar $pass_args
exit
@ryanrichholt
Copy link

@chapmanb I came across this gist because it's included as the launcher for latest SnpEff releases. It's a good model for building jar file launcher scripts. Seeing that it's a few years old now, I'm wondering if there's anything you would change today? The bare exit call at the bottom looks odd to me, whats the purpose?

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