From 81032651fa07efe443091df474a71d3ec583e97d Mon Sep 17 00:00:00 2001 From: asp8200 Date: Wed, 21 Feb 2024 09:34:40 +0000 Subject: [PATCH 1/2] Fixing #22 --- modules/local/check_paired_end.nf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/local/check_paired_end.nf b/modules/local/check_paired_end.nf index 7d757ee8..52a31cef 100644 --- a/modules/local/check_paired_end.nf +++ b/modules/local/check_paired_end.nf @@ -24,7 +24,13 @@ process CHECK_IF_PAIRED_END { def prefix = task.ext.prefix ?: "${meta.id}" def reference = meta.filetype == "cram" ? "--reference ${fasta}" : "" """ - if [ \$({ samtools view -H $reference $input -@$task.cpus ; samtools view $reference $input -@$task.cpus | head -n1000; } | samtools view $reference -c -f 1 -@$task.cpus | awk '{print \$1/1000}') = "1" ]; then + if [ "\$( samtools view $reference $input -@$task.cpus | head -n1000 | wc -l)" -lt "1000" ]; then + LINES_TO_CHK=\$( samtools view $reference $input -@$task.cpus | wc -l) + else + LINES_TO_CHK=1000 + fi + + if [ \$({ samtools view -H $reference $input -@$task.cpus ; samtools view $reference $input -@$task.cpus | head -n\$LINES_TO_CHK; } | samtools view $reference -c -f 1 -@$task.cpus | awk -v lines=\$LINES_TO_CHK '{print \$1/lines}') = "1" ]; then echo 1 > ${prefix}.paired.txt else echo 1 > ${prefix}.single.txt From 767a274146ba6bb8b5ecc2a53d00dbdc27b749bf Mon Sep 17 00:00:00 2001 From: asp8200 Date: Mon, 11 Mar 2024 13:36:09 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10c4e5e4..971c9bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#73](https://github.com/nf-core/bamtofastq/pull/73) Sync TEMPLATE with tools 2.12 +### `Fixed` + +- [#77](https://github.com/nf-core/bamtofastq/pull/77) Fix detection of paired-end or single-end for input with less than 1000 reads. + ## v2.1.0 - Grace Hopper ### `Added`