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

fix: clone command in test_trtools.sh testing script #214

Merged
merged 4 commits into from
Feb 21, 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
14 changes: 8 additions & 6 deletions test/cmdline_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ if [ $# -eq 0 ]; then
# use default example location
EXDATADIR="example-files"
BEAGLEDIR="trtools/testsupport/sample_vcfs/beagle"
elif (( $# != 2 )) ; then
echo "usage: cmdline_tests.sh {example_dir} {beagle_dir}" 2>&1
echo "Expected 2 arguments but recieved $#" 2>&1
BEAGLESCRIPT="scripts/trtools_prep_beagle_vcf.sh"
elif (( $# != 3 )) ; then
echo "usage: cmdline_tests.sh {example_dir} {beagle_dir} {beagle_script}" 2>&1
echo "Expected 3 arguments but recieved $#" 2>&1
exit 1
else
EXDATADIR=$1
BEAGLEDIR=$2
BEAGLESCRIPT=$3
fi

TMPDIR=$(mktemp -d -t tmp-XXXXXXXXXX)
Expand Down Expand Up @@ -220,10 +222,10 @@ prep_beagle_out="$TMPDIR"/test_prep_beagle_vcf.vcf.gz
ref_panel="$BEAGLEDIR"/1kg_snpstr_21_first_100k_first_50_annotated.vcf.gz
imputed_vcf="$BEAGLEDIR"/1kg_snpstr_21_first_100k_second_50_STRs_imputed.vcf.gz

runcmd_fail "trtools_prep_beagle_vcf.sh hipstr nonexistent.vcf.gz $imputed_vcf $prep_beagle_out"
runcmd_fail "trtools_prep_beagle_vcf.sh hipstr $ref_panel nonexistent.vcf.gz $prep_beagle_out"
runcmd_fail "$BEAGLESCRIPT hipstr nonexistent.vcf.gz $imputed_vcf $prep_beagle_out"
runcmd_fail "$BEAGLESCRIPT hipstr $ref_panel nonexistent.vcf.gz $prep_beagle_out"

trtools_prep_beagle_vcf.sh hipstr "$ref_panel" "$imputed_vcf" "$prep_beagle_out"
$BEAGLESCRIPT hipstr "$ref_panel" "$imputed_vcf" "$prep_beagle_out"

if ! [[ -f "$prep_beagle_out" ]] ; then
echo "prep_beagle_vcf test didn't produce output file" >&2
Expand Down
10 changes: 8 additions & 2 deletions trtools/testsupport/test_trtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

# Run the tests for an installed copy of trtools
# If not already present, megabytes of test data will be downloaded before test running
# Please note that this script tests TRTools against
# test files from a published release and will miss any local changes to those files

# If TRTools was installed normally, this script can be executed by simply running
# 'test_trtools.sh' on the command line.
# Otherwise, if TRTools was installed via poetry, you should run the command
# 'poetry run trtools/testsupport/test_trtools.sh'.
echo "Running test_trtools.sh"

command -v git >/dev/null 2>&1 || { echo >&2 "git is not available, but is required for downloading the test data. Aborting."; exit 1; }
Expand All @@ -15,7 +21,7 @@ if [ ! -d "$TMP" ] ; then
echo "Downloading test data ..."
mkdir $TMP
pushd $TMP
git clone -b v$(dumpSTR --version) https://github.com/gymrek-lab/TRTools.git
git clone -b v$(dumpSTR --version) https://github.com/gymrek-lab/TRTools.git .
popd
echo "Download done"
else
Expand All @@ -41,4 +47,4 @@ cd "$loc" || exit 1
# run unit tests
python -m pytest . -p trtools.testsupport.dataloader --datadir "$TMP"/trtools/testsupport
# run command line tests
$TMP/test/cmdline_tests.sh $TMP/example-files $TMP/trtools/testsupport/sample_vcfs/beagle
$TMP/test/cmdline_tests.sh $TMP/example-files $TMP/trtools/testsupport/sample_vcfs/beagle $TMP/scripts/trtools_prep_beagle_vcf.sh
Loading