1#!/usr/local/bin/bash
2
3#---------------------------------------------------------------------------------------------------
4#
5# Wrapper for HomeBrew-science project
6#
7# snpSift executable shell script
8# https://pcingola.github.io/SnpEff/
9# Extracts memory and system property Java arguments from the list of provided arguments
10# (ie -Xms 1g -Xmx 4g)
11#
12# Source https://gist.github.com/chapmanb/8732049
13# Created by: Brad Chapman
14#---------------------------------------------------------------------------------------------------
15
16jardir=%%JAVAJARDIR%%/snpeff
17JAVA_HOME=%%JAVA_HOME%%
18
19if [ -e "$JAVA_HOME/bin/java" ]
20then
21	java="$JAVA_HOME/bin/java"
22fi
23
24default_jvm_mem_opts="-Xms1g -Xmx4g"
25jvm_mem_opts=""
26jvm_prop_opts=""
27pass_args=""
28for arg in "$@"; do
29    case $arg in
30        '-D'*)
31            jvm_prop_opts="$jvm_prop_opts $arg"
32            ;;
33         '-Xm'*)
34            jvm_mem_opts="$jvm_mem_opts $arg"
35            ;;
36         *)
37            pass_args="$pass_args $arg"
38            ;;
39    esac
40done
41
42if [ "$jvm_mem_opts" == "" ]; then
43    jvm_mem_opts="$default_jvm_mem_opts"
44fi
45
46exec $java $jvm_mem_opts $jvm_prop_opts -jar ${jardir}/SnpSift.jar $pass_args
47