diff --git a/src/snpeff/script.sh b/src/snpeff/script.sh index d7c1ae97..9c6d94f5 100644 --- a/src/snpeff/script.sh +++ b/src/snpeff/script.sh @@ -74,7 +74,7 @@ snpEff \ ${par_stats:+-stats} \ ${par_noStats:+-noStats} \ ${par_fi:+-fi "$par_fi"} \ - ${par_no_downstream :+-no-downstream } \ + ${par_no_downstream:+-no-downstream} \ ${par_no_intergenic:+-no-intergenic} \ ${par_no_intron:+-no-intron} \ ${par_no_upstream:+-no-upstream} \ @@ -103,7 +103,7 @@ snpEff \ ${par_noLog:+-noLog} \ ${par_quiet:+-quiet} \ ${par_verbose:+-verbose} \ - ${par_canon :+-canon} \ + ${par_canon:+-canon} \ ${par_canonList:+-canonList "$par_canonList"} \ ${par_tag:+-tag "$par_tag"} \ ${par_notag:+-notag} \ @@ -129,4 +129,14 @@ snpEff \ ${par_ud:+-ud "$par_ud"} \ "$par_genome_version" \ "$par_input" \ - > "$par_output" \ No newline at end of file + > "$par_output" + +# Path of the output file (par_output) +absolute_path=$(realpath "$par_output") +directory_path=$(dirname "$absolute_path") + +# Move the automatically generated outputs to the pwd +if [ -z "$par_noStats" ]; then + mv -f snpEff_genes.txt snpEff_summary.html "$directory_path" +fi +# mv -f snpEff_genes.txt "$directory_path" \ No newline at end of file diff --git a/src/snpeff/test.sh b/src/snpeff/test.sh new file mode 100644 index 00000000..9f3fc057 --- /dev/null +++ b/src/snpeff/test.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +set -eo pipefail + +## VIASH START +meta_executable="$PWD/target/executable/snpeff/snpeff" +meta_resources_dir="$PWD/src/snpeff" +## VIASH END + +########################################################################### + +# Test 1: Run SnpEff with only required parameters + +mkdir test1 +pushd test1 > /dev/null # cd test1 (stack) + +echo "> Run Test 1: required parameters" +"$meta_executable" \ + -genome_version GRCh37.75 \ + -input "$meta_resources_dir/test_data/cancer.vcf" \ + -output out.vcf + +# Check if output files are generated +output_files=("out.vcf" "snpEff_genes.txt" "snpEff_summary.html") + +# Check if any of the files do not exist +for file in "${output_files[@]}"; do + if [ ! -e "$file" ]; then + echo "File $file does not exist." + fi +done + +# Check if files are empty +for file in "${output_files[@]}"; do + if [ ! -s "$file" ]; then + echo "File $file is empty." + fi +done + +popd > /dev/null # Remove directory from stack (LIFO) + +echo "Test 1 succeeded." + +########################################################################### + +# Test 2: Run SnpEff with a different input + options + +# mkdir test2 +# pushd test2 > /dev/null + +# echo "> Run Test 2: different input + options" +# "$meta_executable" \ +# -genome_version GRCh37.66 \ +# -input "$meta_resources_dir/test_data/test.vcf" \ +# -interval "$meta_resources_dir/test_data/my_annotations.bed" \ +# -noStats \ +# -output output.vcf + +# # Check if out.vcf exists +# if [ ! -e "output.vcf" ]; then +# echo "File out.vcf does not exist." +# fi + +# # These files should not exist +# files=("snpEff_genes.txt" "snpEff_summary.html") +# for file in "${files[@]}"; do +# if [ -e "$file" ]; then +# echo "Error: File $file exists." +# fi +# done + +# # Check if output.vcf is empty +# if [ ! -s "output.vcf" ]; then +# echo "File output.vcf is empty." +# fi + +# popd > /dev/null + +# echo "Test 2 succeeded." + +########################################################################### + +echo "All tests successfully completed!" \ No newline at end of file diff --git a/src/snpeff/test_data/cancer.vcf b/src/snpeff/test_data/cancer.vcf new file mode 100644 index 00000000..f37ad8c3 --- /dev/null +++ b/src/snpeff/test_data/cancer.vcf @@ -0,0 +1,2 @@ +#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Patient_01_Germline Patient_01_Somatic +1 69091 . A C,G . PASS AC=1 GT 1/0 2/1 diff --git a/src/snpeff/test_data/my_annotations.bed b/src/snpeff/test_data/my_annotations.bed new file mode 100644 index 00000000..a5247f97 --- /dev/null +++ b/src/snpeff/test_data/my_annotations.bed @@ -0,0 +1 @@ +1 10000 20000 MY_ANNOTATION diff --git a/src/snpeff/test_data/script.sh b/src/snpeff/test_data/script.sh index 7ad31ac3..a47ec136 100644 --- a/src/snpeff/test_data/script.sh +++ b/src/snpeff/test_data/script.sh @@ -1,7 +1,15 @@ -# clone repo -if [ ! -d /tmp/snakemake-wrappers ]; then - git clone --depth 1 --single-branch --branch master https://github.com/snakemake/snakemake-wrappers /tmp/snakemake-wrappers +# Test files from SnpEff examples +if [ ! -f snpEff_latest_core.zip ]; then + wget https://snpeff.blob.core.windows.net/versions/snpEff_latest_core.zip fi -# copy test data -cp -r /tmp/snakemake-wrappers/bio/snpeff/annotate/test/*.vcf src/snpeff/test_data/test.vcf \ No newline at end of file +if [ ! -d snpEff ]; then + unzip snpEff_latest_core.zip +fi + +mv snpEff/examples/test.vcf src/snpeff/test_data/ +mv snpEff/examples/cancer.vcf src/snpeff/test_data/ +mv snpEff/examples/my_annotations.bed src/snpeff/test_data/ + +rm -rf snpEff_latest_core.zip +rm -rf snpEff \ No newline at end of file diff --git a/src/snpeff/test_data/test.vcf b/src/snpeff/test_data/test.vcf index 64c949d0..d552ef18 100644 --- a/src/snpeff/test_data/test.vcf +++ b/src/snpeff/test_data/test.vcf @@ -1,8 +1 @@ -##fileformat=VCFv4.1 -##FORMAT= -##contig= -##reference=http://www.ncbi.nlm.nih.gov/nuccore/KJ660346.1 -#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT fake_KJ660346 -KJ660346 3116 . C T . . . GT 1 -KJ660346 10743 . T G . . . GT 1 -KJ660346 15660 . C A . . . GT 1 +1 10469 . C G 365.78 PASS AC=30;AF=0.0732