new file: pixi.toml
[GalaxyCodeBases.git] / etc / gatk-wdl / fm2gatk / bin / picard.sh
blob3f19f786f8b0f9fe272f0ecf0fcb9b7a10f292c9
1 #!/bin/bash
2 # Picard executable shell script
3 # https://github.com/bioconda/bioconda-recipes/blob/master/recipes/picard/picard.sh
4 set -eu -o pipefail
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
15 done
16 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
18 JAR_DIR=$DIR
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"
33 jvm_mem_opts=""
34 jvm_prop_opts=""
35 pass_args=""
36 for arg in "$@"; do
37 case $arg in
38 '-D'*)
39 jvm_prop_opts="$jvm_prop_opts $arg"
41 '-XX'*)
42 jvm_prop_opts="$jvm_prop_opts $arg"
44 '-Xm'*)
45 jvm_mem_opts="$jvm_mem_opts $arg"
48 if [[ ${pass_args} == '' ]] #needed to avoid preceeding space on first arg e.g. ' MarkDuplicates'
49 then
50 pass_args="$arg"
51 else
52 pass_args="$pass_args \"$arg\"" #quotes later arguments to avoid problem with ()s in MarkDuplicates regex arg
55 esac
56 done
58 if [ "$jvm_mem_opts" == "" ] && [ -z ${_JAVA_OPTIONS+x} ]; then
59 jvm_mem_opts="$default_jvm_mem_opts"
62 pass_arr=($pass_args)
63 if [[ ${pass_arr[0]:=} == org* ]]
64 then
65 eval "$java" $jvm_mem_opts $jvm_prop_opts -cp "$JAR_DIR/picard.jar" $pass_args
66 else
67 eval "$java" $jvm_mem_opts $jvm_prop_opts -jar "$JAR_DIR/picard.jar" $pass_args
69 exit