-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
## VIASH START | ||
## VIASH END | ||
|
||
# Exit on error | ||
set -eo pipefail | ||
|
||
#test_data="$meta_resources_dir/test_data" | ||
|
||
############################################# | ||
# helper functions | ||
assert_file_exists() { | ||
[ -f "$1" ] || { echo "File '$1' does not exist" && exit 1; } | ||
} | ||
assert_file_not_empty() { | ||
[ -s "$1" ] || { echo "File '$1' is empty but shouldn't be" && exit 1; } | ||
} | ||
assert_file_contains() { | ||
grep -q "$2" "$1" || { echo "File '$1' does not contain '$2'" && exit 1; } | ||
} | ||
assert_identical_content() { | ||
diff -a "$2" "$1" \ | ||
|| (echo "Files are not identical!" && exit 1) | ||
} | ||
############################################# | ||
|
||
# Create directories for tests | ||
echo "Creating Test Data..." | ||
TMPDIR=$(mktemp -d "$meta_temp_dir/XXXXXX") | ||
function clean_up { | ||
[[ -d "$TMPDIR" ]] && rm -r "$TMPDIR" | ||
} | ||
trap clean_up EXIT | ||
|
||
# Create test data | ||
cat <<EOF > "$TMPDIR/example.vcf" | ||
##fileformat=VCFv4.1 | ||
##contig=<ID=1,length=249250621,assembly=b37> | ||
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SAMPLE1 | ||
1 752567 llama G C,A . . . . 1/2 | ||
1 752722 . G A,AAA . . . . ./. | ||
EOF | ||
|
||
bgzip -c $TMPDIR/example.vcf > $TMPDIR/example.vcf.gz | ||
tabix -p vcf $TMPDIR/example.vcf.gz | ||
|
||
# Test 1: Remove ID annotations | ||
mkdir "$TMPDIR/test1" && pushd "$TMPDIR/test1" > /dev/null | ||
|
||
echo "> Run bcftools_norm" | ||
"$meta_executable" \ | ||
--input "../example.vcf" \ | ||
--output "normalized.vcf" \ | ||
--atomize \ | ||
--atom_overlaps "." \ | ||
&> /dev/null | ||
|
||
# checks | ||
assert_file_exists "normalized.vcf" | ||
assert_file_not_empty "normalized.vcf" | ||
assert_file_contains "normalized.vcf" "bcftools_normCommand=norm --atomize --atom-overlaps . -o normalized.vcf ../example.vcf" | ||
echo "- test1 succeeded -" | ||
|
||
popd > /dev/null | ||
|
||
echo "---- All tests succeeded! ----" | ||
exit 0 | ||
|
||
|