Skip to content

Commit

Permalink
Make output must-exist false
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarousseau committed Mar 29, 2024
1 parent bfcad51 commit 91ff72a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/samtools/idxstats/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ argument_groups:
type: file
description: File containing samtools stats output in tab-delimited format.
required: true
must_exist: false
example: output.idxstats

resources:
Expand Down
4 changes: 1 addition & 3 deletions src/samtools/idxstats/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ set -e

output_file="$par_output"

samtools idxstats \
"$par_bam" \
> "$output_file"
samtools idxstats "$par_bam" > "$output_file"
31 changes: 17 additions & 14 deletions src/samtools/idxstats/test.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
#!/bin/bash

test_dir="${meta_resources_dir}test_data"
echo ">>> Testing $meta_functionality_name"

"$meta_executable" \
--bam "$meta_resources_dir/test_data/a.sorted.bam" \
--bai "$meta_resources_dir/test_data/a.sorted.bam.bai" \
--output "$meta_resources_dir/test_data/a.sorted.idxstats"
--bam "$test_dir/a.sorted.bam" \
--bai "$test_dir/a.sorted.bam.bai" \
--output "$test_dir/a.sorted.idxstats"

echo "$test_dir/a.sorted.idxstats"

echo ">>> Checking whether output exists"
[ ! -f "$meta_resources_dir/test_data/a.sorted.idxstats" ] && echo "File 'a.sorted.idxstats' does not exist!" && exit 1
[ ! -f "$test_dir/a.sorted.idxstats" ] && echo "File 'a.sorted.idxstats' does not exist!" && exit 1

echo ">>> Checking whether output is non-empty"
[ ! -s "$meta_resources_dir/test_data/a.sorted.idxstats" ] && echo "File 'a.sorted.idxstats' is empty!" && exit 1
[ ! -s "$test_dir/a.sorted.idxstats" ] && echo "File 'a.sorted.idxstats' is empty!" && exit 1

echo ">>> Checking whether output is correct"
diff "$meta_resources_dir/test_data/a.sorted.idxstats" "$meta_resources_dir/test_data/a_ref.sorted.idxstats" || \
diff "$test_dir/a.sorted.idxstats" "$test_dir/a_ref.sorted.idxstats" || \
(echo "Output file a.sorted.idxstats does not match expected output" && exit 1)

rm "$meta_resources_dir/test_data/a.sorted.idxstats"
rm "$test_dir/a.sorted.idxstats"

############################################################################################

echo ">>> Testing $meta_functionality_name with singletons in the input"

"$meta_executable" \
--bam "$meta_resources_dir/test_data/test.paired_end.sorted.bam" \
--bai "$meta_resources_dir/test_data/test.paired_end.sorted.bam.bai" \
--output "$meta_resources_dir/test_data/test.paired_end.sorted.idxstats"
--bam "$test_dir/test.paired_end.sorted.bam" \
--bai "$test_dir/test.paired_end.sorted.bam.bai" \
--output "$test_dir/test.paired_end.sorted.idxstats"

echo ">>> Checking whether output exists"
[ ! -f "$meta_resources_dir/test_data/test.paired_end.sorted.flagidxstatsstat" ] && echo "File 'test.paired_end.sorted.idxstats' does not exist!" && exit 1
[ ! -f "$test_dir/test.paired_end.sorted.idxstats" ] && echo "File 'test.paired_end.sorted.idxstats' does not exist!" && exit 1

echo ">>> Checking whether output is non-empty"
[ ! -s "$meta_resources_dir/test_data/test.paired_end.sorted.idxstats" ] && echo "File 'test.paired_end.sorted.idxstats' is empty!" && exit 1
[ ! -s "$test_dir/test.paired_end.sorted.idxstats" ] && echo "File 'test.paired_end.sorted.idxstats' is empty!" && exit 1

echo ">>> Checking whether output is correct"
diff "$meta_resources_dir/test_data/test.paired_end.sorted.idxstats" "$meta_resources_dir/test_data/test_ref.paired_end.sorted.idxstats" || \
diff "$test_dir/test.paired_end.sorted.idxstats" "$test_dir/test_ref.paired_end.sorted.idxstats" || \
(echo "Output file test.paired_end.sorted.idxstats does not match expected output" && exit 1)

rm "$meta_resources_dir/test_data/test.paired_end.sorted.idxstats"
rm "$test_dir/test.paired_end.sorted.idxstats"


echo "All tests succeeded!"
Expand Down

0 comments on commit 91ff72a

Please sign in to comment.