From c1043613a0d58195c78044cc8fa05cbbfe0a8a81 Mon Sep 17 00:00:00 2001 From: Hendrik Cannoodt Date: Fri, 26 Jan 2024 10:48:50 +0100 Subject: [PATCH] improve implementation of regular script and test script --- src/bgzip/config.vsh.yaml | 48 +++++++++++++++++++------- src/bgzip/test_data/README.md | 13 +++++++ src/bgzip/{test => test_data}/test.vcf | 0 3 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 src/bgzip/test_data/README.md rename src/bgzip/{test => test_data}/test.vcf (100%) diff --git a/src/bgzip/config.vsh.yaml b/src/bgzip/config.vsh.yaml index a4fe18e3..bae1eb20 100644 --- a/src/bgzip/config.vsh.yaml +++ b/src/bgzip/config.vsh.yaml @@ -20,26 +20,48 @@ functionality: direction: output description: compressed or decompressed output required: true - - name: --extra - type: string - description: extra arguments to pass to bgzip - required: false - - name: --threads - type: integer - description: number of threads to use - required: false - default: 1 + - name: --decompress + alternatives: -d + type: boolean_true + description: decompress the input file resources: - type: bash_script text: | - bgzip -c "$par_extra" --threads "$par_threads" "$par_input" > "$par_output" + [[ "$par_decompress" == "false" ]] && unset par_decompress + bgzip -c \ + ${meta_cpus:+--threads "${meta_cpus}"} \ + ${par_decompress:+-d} \ + "$par_input" > "$par_output" test_resources: - type: bash_script text: | - "$meta_executable" --input "$meta_resources_dir/test/test.vcf" --output "$meta_resources_dir/test.vcf.gz" + set -e + + "$meta_executable" --input "$meta_resources_dir/test_data/test.vcf" --output "test.vcf.gz" + + echo ">> Checking output of compressing" + [ ! -f "test.vcf.gz" ] && echo "Output file test.vcf.gz does not exist" && exit 1 + + "$meta_executable" --input "test.vcf.gz" --output "test.vcf" --decompress + + echo ">> Checking output of decompressing" + [ ! -f "test.vcf" ] && echo "Output file test.vcf does not exist" && exit 1 + + echo ">> Checking original and decompressed files are the same" + set +e + cmp --silent -- "$meta_resources_dir/test_data/test.vcf" "test.vcf" + [ $? -ne 0 ] && echo "files are different" && exit 1 + set -e + + echo "> Test successful" - type: file - path: test + path: test_data platforms: - type: docker - image: quay.io/biocontainers/htslib:1.19--h81da01d_0 \ No newline at end of file + image: quay.io/biocontainers/htslib:1.19--h81da01d_0 + setup: + - type: docker + run: | + bgzip -h | grep 'Version:' 2>&1 | sed 's/Version:\s\(.*\)/arriba: "\1"/' > /var/software_versions.txt + - type: nextflow \ No newline at end of file diff --git a/src/bgzip/test_data/README.md b/src/bgzip/test_data/README.md new file mode 100644 index 00000000..ce46295a --- /dev/null +++ b/src/bgzip/test_data/README.md @@ -0,0 +1,13 @@ +# arriba test data + +Test data was obtained from https://github.com/snakemake/snakemake-wrappers/tree/master/bio/bgzip/test. + +__author__ = "William Rowell" +__copyright__ = "Copyright 2020, William Rowell" +__email__ = "wrowell@pacb.com" +__license__ = "MIT" + +```bash +git clone --depth 1 --single-branch --branch master https://github.com/snakemake/snakemake-wrappers /tmp/snakemake-wrappers +cp -r /tmp/snakemake-wrappers/bio/bgzip/test/* src/bgzip/test_data +``` \ No newline at end of file diff --git a/src/bgzip/test/test.vcf b/src/bgzip/test_data/test.vcf similarity index 100% rename from src/bgzip/test/test.vcf rename to src/bgzip/test_data/test.vcf