From 487c5d26d48de9596651aa039688b7499c0ad35f Mon Sep 17 00:00:00 2001 From: Sai Nirmayi Yasa <92786623+sainirmayi@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:53:39 +0100 Subject: [PATCH] Fix featurecounts (#20) * check if junction counts file exists * add test without junctions --- src/featurecounts/script.sh | 4 +++- src/featurecounts/test.sh | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/featurecounts/script.sh b/src/featurecounts/script.sh index b8da615f..7fbafa39 100644 --- a/src/featurecounts/script.sh +++ b/src/featurecounts/script.sh @@ -82,4 +82,6 @@ featureCounts \ [[ ! -z "$par_counts" ]] && mv "$tmp_dir/output.txt" "$par_counts" [[ ! -z "$par_summary" ]] && mv "$tmp_dir/output.txt.summary" "$par_summary" -[[ ! -z "$par_junctions" ]] && mv "$tmp_dir/output.txt.jcounts" "$par_junctions" +if [[ ! -z "$par_junctions" ]] && [[ -e "$tmp_dir/output.txt.jcounts" ]]; then + mv "$tmp_dir/output.txt.jcounts" "$par_junctions" +fi diff --git a/src/featurecounts/test.sh b/src/featurecounts/test.sh index 26494f98..3349d016 100644 --- a/src/featurecounts/test.sh +++ b/src/featurecounts/test.sh @@ -4,7 +4,7 @@ set -e dir_in="$meta_resources_dir/test_data" -echo "> Run featureCounts" +echo "> Run featureCounts (with junctions)" "$meta_executable" \ --input "$dir_in/a.bam" \ --annotation "$dir_in/annotation.gtf" \ @@ -32,4 +32,28 @@ echo ">> Check if output is empty" [ ! -s "junction_counts.txt" ] && echo "Output file junction_counts.txt is empty" && exit 1 [ ! -s "detailed_results/a.bam.featureCounts.sam" ] && echo "Output file detailed_results/a.bam.featureCounts.sam is empty" && exit 1 +echo "> Run featureCounts (without junctions)" +"$meta_executable" \ + --input "$dir_in/a.bam" \ + --annotation "$dir_in/annotation.gtf" \ + --counts "features.tsv" \ + --summary "summary.tsv" \ + --overlapping \ + --frac_overlap 0.2 \ + --paired \ + --strand 0 \ + --detailed_results detailed_results \ + --detailed_results_format SAM + +echo ">> Checking output" +[ ! -f "features.tsv" ] && echo "Output file features.tsv does not exist" && exit 1 +[ ! -f "summary.tsv" ] && echo "Output file summary.tsv does not exist" && exit 1 +[ ! -d "detailed_results" ] && echo "Output directory detailed_results does not exist" && exit 1 +[ ! -f "detailed_results/a.bam.featureCounts.sam" ] && echo "Output file detailed_results/a.bam.featureCounts.sam does not exist" && exit 1 + +echo ">> Check if output is empty" +[ ! -s "features.tsv" ] && echo "Output file features.tsv is empty" && exit 1 +[ ! -s "summary.tsv" ] && echo "Output file summary.tsv is empty" && exit 1 +[ ! -s "detailed_results/a.bam.featureCounts.sam" ] && echo "Output file detailed_results/a.bam.featureCounts.sam is empty" && exit 1 + echo "> Test successful" \ No newline at end of file