diff --git a/src/idxstats/config.vsh.yaml b/src/idxstats/config.vsh.yaml new file mode 100644 index 00000000..2cd3a4f9 --- /dev/null +++ b/src/idxstats/config.vsh.yaml @@ -0,0 +1,50 @@ +name: samtools_idxstats +namespace: samtools +description: Reports alignment summary statistics for a BAM file +keywords: [stats, mapping, counts, chromosome, bam, sam, cram] +links: + homepage: https://www.htslib.org/ + documentation: https://www.htslib.org/doc/samtools-idxstats.html + repository: https://github.com/samtools/samtools.git +references: + doi: 10.1093/bioinformatics/btp352, 10.1093/gigascience/giab008 +license: MIT/Expat + +argument_groups: + - name: Inputs + arguments: + - name: "--bam" + type: file + description: BAM input file. + - name: "--bai" + type: file + description: BAM index file. + - name: "--fasta" + type: file + description: Reference file the CRAM was created with (optional). + - name: Outputs + arguments: + - name: "--output" + type: file + description: File containing samtools stats output in tab-delimited format. + required: true + example: output.idxstats + +resources: + - type: bash_script + path: script.sh +test_resources: + - type: bash_script + path: test.sh + - type: file + path: test_data +engines: + - type: docker + image: quay.io/biocontainers/samtools:1.3.1--h9071d68_10 + setup: + - type: docker + run: | + echo "$(samtools --version 2>&1)" > /var/software_versions.txt +runners: +- type: executable +- type: nextflow \ No newline at end of file diff --git a/src/idxstats/help.txt b/src/idxstats/help.txt new file mode 100644 index 00000000..c0fb5947 --- /dev/null +++ b/src/idxstats/help.txt @@ -0,0 +1,5 @@ +``` +samtools idxstats +``` + +Usage: samtools idxstats \ No newline at end of file diff --git a/src/idxstats/script.sh b/src/idxstats/script.sh new file mode 100644 index 00000000..f20e5956 --- /dev/null +++ b/src/idxstats/script.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +## VIASH START +## VIASH END + +set -e + +output_file="$par_output" + +samtools idxstats \ + "$par_bam" \ + > "$output_file" \ No newline at end of file diff --git a/src/idxstats/test.sh b/src/idxstats/test.sh new file mode 100644 index 00000000..b8cba6a7 --- /dev/null +++ b/src/idxstats/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +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" + +echo ">>> Checking whether output exists" +[ ! -f "$meta_resources_dir/test_data/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 + +echo ">>> Checking whether output is correct" +diff "$meta_resources_dir/test_data/a.sorted.idxstats" "$meta_resources_dir/test_data/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" + +############################################################################################ + +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" + +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 + +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 + +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" || \ + (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" + + +echo "All tests succeeded!" +exit 0 \ No newline at end of file diff --git a/src/idxstats/test_data/a.sorted.bam b/src/idxstats/test_data/a.sorted.bam new file mode 100644 index 00000000..1c81d7cd Binary files /dev/null and b/src/idxstats/test_data/a.sorted.bam differ diff --git a/src/idxstats/test_data/a.sorted.bam.bai b/src/idxstats/test_data/a.sorted.bam.bai new file mode 100644 index 00000000..4f08f5d5 Binary files /dev/null and b/src/idxstats/test_data/a.sorted.bam.bai differ diff --git a/src/idxstats/test_data/a.sorted.idxstats b/src/idxstats/test_data/a.sorted.idxstats new file mode 100644 index 00000000..27862419 --- /dev/null +++ b/src/idxstats/test_data/a.sorted.idxstats @@ -0,0 +1,2 @@ +xx 20 6 0 +* 0 0 0 diff --git a/src/idxstats/test_data/script.sh b/src/idxstats/test_data/script.sh new file mode 100755 index 00000000..0e28a4c6 --- /dev/null +++ b/src/idxstats/test_data/script.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# dowload test data from snakemake wrapper +if [ ! -d /tmp/idxstats_source ]; then + git clone --depth 1 --single-branch --branch master https://github.com/snakemake/snakemake-wrappers.git /tmp/idxstats_source +fi + +cp -r /tmp/idxstats_source/bio/samtools/idxstats/test/mapped/* src/samtools/idxstats/test_data +# samtools idxstats a.sorted.bam > a.sorted.idxstats + +# dowload test data from nf-core module +wget https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam +wget https://github.com/nf-core/test-datasets/raw/modules/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai +# samtools idxstats test.paired_end.sorted.bam > test_ref.paired_end.sorted.idxstats \ No newline at end of file diff --git a/src/idxstats/test_data/test.paired_end.sorted.bam b/src/idxstats/test_data/test.paired_end.sorted.bam new file mode 100644 index 00000000..85cccf14 Binary files /dev/null and b/src/idxstats/test_data/test.paired_end.sorted.bam differ diff --git a/src/idxstats/test_data/test.paired_end.sorted.bam.bai b/src/idxstats/test_data/test.paired_end.sorted.bam.bai new file mode 100644 index 00000000..0c6d5a96 Binary files /dev/null and b/src/idxstats/test_data/test.paired_end.sorted.bam.bai differ diff --git a/src/idxstats/test_data/test_ref.paired_end.sorted.idxstats b/src/idxstats/test_data/test_ref.paired_end.sorted.idxstats new file mode 100644 index 00000000..77bc11b8 --- /dev/null +++ b/src/idxstats/test_data/test_ref.paired_end.sorted.idxstats @@ -0,0 +1,2 @@ +MT192765.1 29829 197 3 +* 0 0 0