diff --git a/src/rseqc/rseqc_bamstat/config.vsh.yaml b/src/rseqc/rseqc_bamstat/config.vsh.yaml index 8a9d7585..fa186723 100644 --- a/src/rseqc/rseqc_bamstat/config.vsh.yaml +++ b/src/rseqc/rseqc_bamstat/config.vsh.yaml @@ -20,23 +20,19 @@ argument_groups: - name: "--input" type: file required: true - description: input alignment file in BAM or SAM format - + description: Input alignment file in BAM or SAM format. - name: "--map_qual" type: integer - required: false - default: 30 - description: Minimum mapping quality (phred scaled) to determine uniquely mapped reads, default=30. - min: 0 + example: 30 + description: | + Minimum mapping quality (phred scaled) to determine uniquely mapped reads. Default: '30'. - name: "Output" arguments: - name: "--output" type: file direction: output - required: false - default: $id.mapping_quality.txt - description: output file (txt) with mapping quality statistics + description: Output file (txt) with mapping quality statistics. resources: - type: bash_script @@ -44,7 +40,8 @@ resources: test_resources: - type: bash_script path: test.sh - - path: /testData/unit_test_resources/sarscov2/test.paired_end.sorted.bam + - type: file + path: test_data engines: - type: docker @@ -54,6 +51,9 @@ engines: packages: [ python3-pip ] - type: python packages: [ RSeQC ] + - type: docker + run: | + echo "RSeQC bam_stat.py: $(bam_stat.py --version | cut -d' ' -f2-)" > /var/software_versions.txt runners: - type: executable - type: nextflow diff --git a/src/rseqc/rseqc_bamstat/help.txt b/src/rseqc/rseqc_bamstat/help.txt new file mode 100644 index 00000000..b4e9c1d9 --- /dev/null +++ b/src/rseqc/rseqc_bamstat/help.txt @@ -0,0 +1,18 @@ +``` +bam_stat.py -h +``` + +Usage: bam_stat.py [options] + +Summarizing mapping statistics of a BAM or SAM file. + + + +Options: + --version show program's version number and exit + -h, --help show this help message and exit + -i INPUT_FILE, --input-file=INPUT_FILE + Alignment file in BAM or SAM format. + -q MAP_QUAL, --mapq=MAP_QUAL + Minimum mapping quality (phred scaled) to determine + "uniquely mapped" reads. default=30 \ No newline at end of file diff --git a/src/rseqc/rseqc_bamstat/script.sh b/src/rseqc/rseqc_bamstat/script.sh index dcc8bd0c..86de32e5 100644 --- a/src/rseqc/rseqc_bamstat/script.sh +++ b/src/rseqc/rseqc_bamstat/script.sh @@ -1,8 +1,9 @@ #!/bin/bash + set -eo pipefail bam_stat.py \ - --input $par_input \ - --mapq $par_map_qual \ + --input "${par_input}" \ + ${par_map_qual:+--mapq "${par_map_qual}"} \ > $par_output diff --git a/src/rseqc/rseqc_bamstat/test.sh b/src/rseqc/rseqc_bamstat/test.sh index 91be990f..f47c8717 100644 --- a/src/rseqc/rseqc_bamstat/test.sh +++ b/src/rseqc/rseqc_bamstat/test.sh @@ -9,15 +9,41 @@ output_summary="mapping_quality.txt" echo "> Running $meta_functionality_name." "$meta_executable" \ - --input "$meta_resources_dir/$input_bam" \ + --input "$meta_resources_dir/test_data/$input_bam" \ --output "$output_summary" exit_code=$? [[ $exit_code != 0 ]] && echo "Non zero exit code: $exit_code" && exit 1 -echo ">> Checking whether output can be found and has content" +echo ">> Checking whether output is present" +[ ! -f "$output_summary" ] && echo "$output_summary file missing" && exit 1 +[ ! -s "$output_summary" ] && echo "$output_summary file is empty" && exit 1 + +echo ">> Checking whether output is correct" +diff "$meta_resources_dir/test_data/ref_output.txt" "$meta_resources_dir/$output_summary" || { echo "Output is not correct"; exit 1; } + +############################################################################# +echo ">>> Test 2: Test with non-default mapping quality threshold" + +output_summary="mapping_quality_mapq_30.txt" + +# run executable and tests +echo "> Running $meta_functionality_name." + +"$meta_executable" \ + --input "$meta_resources_dir/test_data/$input_bam" \ + --output "$output_summary" \ + --map_qual 50 + +exit_code=$? +[[ $exit_code != 0 ]] && echo "Non zero exit code: $exit_code" && exit 1 + +echo ">> Checking whether output is present" [ ! -f "$output_summary" ] && echo "$output_summary file missing" && exit 1 [ ! -s "$output_summary" ] && echo "$output_summary file is empty" && exit 1 +echo ">> Checking whether output is correct" +diff "$meta_resources_dir/test_data/ref_output_mapq.txt" "$meta_resources_dir/$output_summary" || { echo "Output is not correct"; exit 1; } + exit 0 \ No newline at end of file diff --git a/src/rseqc/rseqc_bamstat/test_data/ref_output.txt b/src/rseqc/rseqc_bamstat/test_data/ref_output.txt new file mode 100644 index 00000000..ced4cc13 --- /dev/null +++ b/src/rseqc/rseqc_bamstat/test_data/ref_output.txt @@ -0,0 +1,22 @@ + +#================================================== +#All numbers are READ count +#================================================== + +Total records: 200 + +QC failed: 0 +Optical/PCR duplicate: 0 +Non primary hits 0 +Unmapped reads: 3 +mapq < mapq_cut (non-unique): 1 + +mapq >= mapq_cut (unique): 196 +Read-1: 99 +Read-2: 97 +Reads map to '+': 98 +Reads map to '-': 98 +Non-splice reads: 196 +Splice reads: 0 +Reads mapped in proper pairs: 192 +Proper-paired reads map to different chrom:0 diff --git a/src/rseqc/rseqc_bamstat/test_data/ref_output_mapq.txt b/src/rseqc/rseqc_bamstat/test_data/ref_output_mapq.txt new file mode 100644 index 00000000..457c8863 --- /dev/null +++ b/src/rseqc/rseqc_bamstat/test_data/ref_output_mapq.txt @@ -0,0 +1,22 @@ + +#================================================== +#All numbers are READ count +#================================================== + +Total records: 200 + +QC failed: 0 +Optical/PCR duplicate: 0 +Non primary hits 0 +Unmapped reads: 3 +mapq < mapq_cut (non-unique): 20 + +mapq >= mapq_cut (unique): 177 +Read-1: 88 +Read-2: 89 +Reads map to '+': 96 +Reads map to '-': 81 +Non-splice reads: 177 +Splice reads: 0 +Reads mapped in proper pairs: 175 +Proper-paired reads map to different chrom:0 diff --git a/src/rseqc/rseqc_bamstat/test_data/test.paired_end.sorted.bam b/src/rseqc/rseqc_bamstat/test_data/test.paired_end.sorted.bam new file mode 100644 index 00000000..85cccf14 Binary files /dev/null and b/src/rseqc/rseqc_bamstat/test_data/test.paired_end.sorted.bam differ