Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hmftools-peach 2.0.0 #51150

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions recipes/hmftools-peach/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

TGT="$PREFIX/share/$PKG_NAME-$PKG_VERSION-$PKG_BUILDNUM"
[ -d "$TGT" ] || mkdir -p "$TGT"
[ -d "${PREFIX}/bin" ] || mkdir -p "${PREFIX}/bin"

cd "${SRC_DIR}"
mv peach*.jar $TGT/peach.jar
martin-g marked this conversation as resolved.
Show resolved Hide resolved

cp $RECIPE_DIR/peach.sh $TGT/peach
ln -s $TGT/peach $PREFIX/bin
chmod 0755 "${PREFIX}/bin/peach"
30 changes: 30 additions & 0 deletions recipes/hmftools-peach/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% set version = "2.0.0" %}
{% set sha256 = "52ffd5dc9bd6018adc5854cbe10cdb2cc364e99099af2f9c8dbc7fdd80fab83e" %}

package:
name: hmftools-peach
version: '{{ version }}'

source:
url: https://github.com/hartwigmedical/hmftools/releases/download/peach-v{{ version }}/peach_v{{ version }}.jar
sha256: '{{ sha256 }}'

build:
noarch: generic
number: 0
run_exports:
- {{ pin_subpackage("hmftools-peach", max_pin="x.x") }}

requirements:
run:
- openjdk >=8

test:
commands:
- 'peach -version | grep Peach'

about:
home: https://github.com/hartwigmedical/hmftools/blob/master/peach/README.md
license: GPL-3.0-only
license_family: GPL3
summary: Infer haplotypes for interpretation in a pharmacogenomic context
69 changes: 69 additions & 0 deletions recipes/hmftools-peach/peach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
# hmftools PEACH executable shell script
# https://github.com/hartwigmedical/hmftools/tree/master/peach
set -eu -o pipefail

export LC_ALL=en_US.UTF-8

# Find original directory of bash script, resolving 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
ENV_PREFIX="$(dirname $(dirname $DIR))"
# Use Java installed with Anaconda to ensure correct version
java="$ENV_PREFIX/bin/java"

# if JAVA_HOME is set (non-empty), use it. Otherwise keep "java"
if [ -n "${JAVA_HOME:=}" ]; then
if [ -e "$JAVA_HOME/bin/java" ]; then
java="$JAVA_HOME/bin/java"
fi
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"
;;
*)
if [[ ${pass_args} == '' ]] #needed to avoid preceeding space on first arg e.g. ' MarkDuplicates'
then
pass_args="$arg"
else
pass_args="$pass_args \"$arg\"" #quotes later arguments to avoid problem with ()s in MarkDuplicates regex arg
fi
;;
esac
done

if [ "$jvm_mem_opts" == "" ]; then
jvm_mem_opts="$default_jvm_mem_opts"
fi

pass_arr=($pass_args)
if [[ ${pass_arr[0]:=} == org* ]]
Comment on lines +62 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Improve array creation to prevent word splitting

The current method of creating the pass_arr array could lead to word splitting or unexpected globbing. Let's improve it for better reliability:

Replace these lines:

-pass_arr=($pass_args)
-if [[ ${pass_arr[0]:=} == org* ]]
+if [[ $pass_args == org* ]]

This change eliminates the need for the array and directly checks the $pass_args string, which is safer and avoids potential issues with word splitting or globbing.

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 Shellcheck

[warning] 62-62: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.

(SC2206)

then
eval "$java" $jvm_mem_opts $jvm_prop_opts -cp "$JAR_DIR/peach.jar" $pass_args
else
eval "$java" $jvm_mem_opts $jvm_prop_opts -jar "$JAR_DIR/peach.jar" $pass_args
fi
exit