forked from bioconda/bioconda-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChromHMM.sh
60 lines (54 loc) · 1.66 KB
/
ChromHMM.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Wraps ChromHMM.jar
#
# This is copied from https://github.com/chapmanb/gatk
#
set -o pipefail
# Find original directory of bash script, resovling symlinks
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/246128#246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $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
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
JAR_DIR=$DIR
java=java
if [ -e "$JAVA_HOME/bin/java" ]
then
java="$JAVA_HOME/bin/java"
fi
# extract memory and system property Java arguments from the list of provided arguments
# http://java.dzone.com/articles/better-java-shell-script
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"
;;
'-XX'*)
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
pass_arr=($pass_args)
if [[ ${pass_arr[0]} == org* ]]
then
eval "$java" $jvm_mem_opts $jvm_prop_opts -cp "$JAR_DIR/ChromHMM.jar" $pass_args
else
eval "$java" $jvm_mem_opts $jvm_prop_opts -jar "$JAR_DIR/ChromHMM.jar" $pass_args
fi
exit