diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f720035..3fc134fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * `rsem/rsem_calculate_expression`: Calculate expression levels (PR #93). * `rseqc`: + - `rseqc/rseqc_inferexperiment`: Infer strandedness from sequencing reads (PR #158). - `rseqc/bam_stat`: Generate statistics from a bam file (PR #155). * `nanoplot`: Plotting tool for long read sequencing data and alignments (PR #95). @@ -27,7 +28,6 @@ * `cutadapt`: Fix the the non-functional `action` parameter (PR #161). - ## MINOR CHANGES * `agat_convert_bed2gff`: change type of argument `inflate_off` from `boolean_false` to `boolean_true` (PR #160). diff --git a/src/rseqc/rseqc_inferexperiment/config.vsh.yaml b/src/rseqc/rseqc_inferexperiment/config.vsh.yaml new file mode 100644 index 00000000..184f2c10 --- /dev/null +++ b/src/rseqc/rseqc_inferexperiment/config.vsh.yaml @@ -0,0 +1,76 @@ +name: "rseqc_inferexperiment" +namespace: "rseqc" +description: | + Infer strandedness from sequencing reads +links: + homepage: https://rseqc.sourceforge.net/ + documentation: https://rseqc.sourceforge.net/#infer-experiment-py + issue_tracker: https://github.com/MonashBioinformaticsPlatform/RSeQC/issues + repository: https://github.com/MonashBioinformaticsPlatform/RSeQC +references: + doi: 10.1093/bioinformatics/bts356 +license: GPL-3.0 +authors: + - __merge__: /src/_authors/emma_rousseau.yaml + roles: [ author, maintainer ] + +argument_groups: +- name: "Input" + arguments: + - name: "--input_file" + alternatives: ["-i"] + type: file + required: true + description: input alignment file in BAM or SAM format + - name: "--refgene" + alternatives: ["-r"] + type: file + required: true + description: Reference gene model in bed format + +- name: "Output" + arguments: + - name: "--output" + type: file + direction: output + required: true + description: Output file (txt) of strandness report. + example: $id.strandedness.txt + +- name: "Options" + arguments: + - name: "--sample_size" + alternatives: ["-s"] + type: integer + description: | + Number of reads sampled from SAM/BAM file. Default: 200000 + example: 200000 + - name: "--mapq" + alternatives: ["-q"] + type: integer + description: | + Minimum mapping quality (phred scaled) to determine uniquely mapped reads. Default: 30 + example: 30 + +resources: + - type: bash_script + path: script.sh + +test_resources: + - type: bash_script + path: test.sh + - path: test_data + +engines: +- type: docker + image: python:3.10 + setup: + - type: python + packages: [ RSeQC ] + - type: docker + run: | + echo "RSeQC - infer_experiment.py: $(infer_experiment.py --version | cut -d' ' -f2)" > /var/software_versions.txt + +runners: +- type: executable +- type: nextflow diff --git a/src/rseqc/rseqc_inferexperiment/help.txt b/src/rseqc/rseqc_inferexperiment/help.txt new file mode 100644 index 00000000..f19aa318 --- /dev/null +++ b/src/rseqc/rseqc_inferexperiment/help.txt @@ -0,0 +1,21 @@ +``` +infer_eperiment.py --help +``` + +Usage: infer_experiment.py [options] + + +Options: + --version show program's version number and exit + -h, --help show this help message and exit + -i INPUT_FILE, --input-file=INPUT_FILE + Input alignment file in SAM or BAM format + -r REFGENE_BED, --refgene=REFGENE_BED + Reference gene model in bed fomat. + -s SAMPLE_SIZE, --sample-size=SAMPLE_SIZE + Number of reads sampled from SAM/BAM file. + default=200000 + -q MAP_QUAL, --mapq=MAP_QUAL + Minimum mapping quality (phred scaled) for an + alignment to be considered as "uniquely mapped". + default=30 \ No newline at end of file diff --git a/src/rseqc/rseqc_inferexperiment/script.sh b/src/rseqc/rseqc_inferexperiment/script.sh new file mode 100644 index 00000000..c425b6f3 --- /dev/null +++ b/src/rseqc/rseqc_inferexperiment/script.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eo pipefail + +infer_experiment.py \ + -i $par_input_file \ + -r $par_refgene \ + ${par_sample_size:+-s "${par_sample_size}"} \ + ${par_mapq:+-q "${par_mapq}"} \ +> $par_output diff --git a/src/rseqc/rseqc_inferexperiment/test.sh b/src/rseqc/rseqc_inferexperiment/test.sh new file mode 100644 index 00000000..ff2e870c --- /dev/null +++ b/src/rseqc/rseqc_inferexperiment/test.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# define input and output for script +input_bam="$meta_resources_dir/test_data/sample.bam" +input_bed="$meta_resources_dir/test_data/test.bed12" +output="strandedness.txt" + +echo ">>> Prepare test output data" + +cat > "$meta_resources_dir/test_data/strandedness.txt" < "$meta_resources_dir/test_data/strandedness2.txt" <>> Test 1: Test with default parameters" + +"$meta_executable" \ + --input_file "$input_bam" \ + --refgene "$input_bed" \ + --output "$output" + +exit_code=$? +[[ $exit_code != 0 ]] && echo "Non zero exit code: $exit_code" && exit 1 + +echo ">> Checking whether output can be found and has content" + +[ ! -f "$output" ] && echo "$output is missing" && exit 1 +[ ! -s "$output" ] && echo "$output is empty" && exit 1 + + +echo ">> Checking whether output is correct" +diff "$output" "$meta_resources_dir/test_data/strandedness.txt" || { echo "Output is not correct"; exit 1; } + +rm "$output" + +################################################################################ + +echo ">>> Test 2: Test with non-default sample size and map quality" + +"$meta_executable" \ + --input_file "$input_bam" \ + --refgene "$input_bed" \ + --output "$output" \ + --sample_size 150000 \ + --mapq 90 + +exit_code=$? +[[ $exit_code != 0 ]] && echo "Non zero exit code: $exit_code" && exit 1 + +echo ">> Checking whether output can be found and has content" + +[ ! -f "$output" ] && echo "$output is missing" && exit 1 +[ ! -s "$output" ] && echo "$output is empty" && exit 1 + +echo ">> Checking whether output is correct" +diff "$output" "$meta_resources_dir/test_data/strandedness2.txt" || { echo "Output is not correct"; exit 1; } + + +echo "All tests passed" + +exit 0 \ No newline at end of file diff --git a/src/rseqc/rseqc_inferexperiment/test_data/sample.bam b/src/rseqc/rseqc_inferexperiment/test_data/sample.bam new file mode 100644 index 00000000..9b8d417c Binary files /dev/null and b/src/rseqc/rseqc_inferexperiment/test_data/sample.bam differ diff --git a/src/rseqc/rseqc_inferexperiment/test_data/test.bed12 b/src/rseqc/rseqc_inferexperiment/test_data/test.bed12 new file mode 100644 index 00000000..33a46951 --- /dev/null +++ b/src/rseqc/rseqc_inferexperiment/test_data/test.bed12 @@ -0,0 +1,4 @@ +MT192765.1 1242 1264 nCoV-2019_5_LEFT 1 + 1242 1264 0 2 10,12, 0,10, +MT192765.1 1573 1595 nCoV-2019_6_LEFT 2 + 1573 1595 0 2 7,15, 0,7, +MT192765.1 1623 1651 nCoV-2019_5_RIGHT 1 - 1623 1651 0 2 14,14, 0,14, +MT192765.1 1942 1964 nCoV-2019_6_RIGHT 2 - 1942 1964 0 2 11,11 0,11, diff --git a/src/rseqc/rseqc_inferexperiment/test_data/test.paired_end.sorted.bam b/src/rseqc/rseqc_inferexperiment/test_data/test.paired_end.sorted.bam new file mode 100644 index 00000000..85cccf14 Binary files /dev/null and b/src/rseqc/rseqc_inferexperiment/test_data/test.paired_end.sorted.bam differ