2 # Picard executable shell script
3 # https://github.com/bioconda/bioconda-recipes/blob/master/recipes/picard/picard.sh
6 export LC_ALL
=en_US.UTF-8
8 # Find original directory of bash script, resolving symlinks
9 # http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/246128#246128
10 SOURCE
="${BASH_SOURCE[0]}"
11 while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
12 DIR
="$( cd -P "$
( dirname "$SOURCE" )" && pwd )"
13 SOURCE
="$(readlink "$SOURCE")"
14 [[ $SOURCE != /* ]] && SOURCE
="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
16 DIR
="$( cd -P "$
( dirname "$SOURCE" )" && pwd )"
19 ENV_PREFIX
="$(dirname $(dirname $DIR))"
20 # Use Java installed with Anaconda to ensure correct version
21 java
="$ENV_PREFIX/bin/java"
23 # if JAVA_HOME is set (non-empty), use it. Otherwise keep "java"
24 if [ -n "${JAVA_HOME:=}" ]; then
25 if [ -e "$JAVA_HOME/bin/java" ]; then
26 java
="$JAVA_HOME/bin/java"
30 # extract memory and system property Java arguments from the list of provided arguments
31 # http://java.dzone.com/articles/better-java-shell-script
32 default_jvm_mem_opts
="-Xms512m -Xmx2g"
39 jvm_prop_opts
="$jvm_prop_opts $arg"
42 jvm_prop_opts
="$jvm_prop_opts $arg"
45 jvm_mem_opts
="$jvm_mem_opts $arg"
48 if [[ ${pass_args} == '' ]] #needed to avoid preceeding space on first arg e.g. ' MarkDuplicates'
52 pass_args
="$pass_args \"$arg\"" #quotes later arguments to avoid problem with ()s in MarkDuplicates regex arg
58 if [ "$jvm_mem_opts" == "" ] && [ -z ${_JAVA_OPTIONS+x} ]; then
59 jvm_mem_opts
="$default_jvm_mem_opts"
63 if [[ ${pass_arr[0]:=} == org
* ]]
65 eval "$java" $jvm_mem_opts $jvm_prop_opts -cp "$JAR_DIR/picard.jar" $pass_args
67 eval "$java" $jvm_mem_opts $jvm_prop_opts -jar "$JAR_DIR/picard.jar" $pass_args