From 490eca706c3d2ecc52395d977e5fe29145eba60c Mon Sep 17 00:00:00 2001 From: Piotr Faba Date: Fri, 6 Mar 2020 13:23:12 +0000 Subject: [PATCH] single and paired end supported --- tools/cutadapt/main.nf | 42 +++++++++++++------ tools/cutadapt/test/main.nf | 22 ---------- tools/cutadapt/test_paired/main.nf | 14 +++++++ tools/cutadapt/test_paired/nextflow.config | 9 ++++ tools/cutadapt/test_single/main.nf | 21 ++++++++++ .../{test => test_single}/nextflow.config | 1 + 6 files changed, 75 insertions(+), 34 deletions(-) delete mode 100644 tools/cutadapt/test/main.nf create mode 100644 tools/cutadapt/test_paired/main.nf create mode 100644 tools/cutadapt/test_paired/nextflow.config create mode 100644 tools/cutadapt/test_single/main.nf rename tools/cutadapt/{test => test_single}/nextflow.config (87%) diff --git a/tools/cutadapt/main.nf b/tools/cutadapt/main.nf index 432eccb4..bdd444af 100644 --- a/tools/cutadapt/main.nf +++ b/tools/cutadapt/main.nf @@ -4,24 +4,42 @@ process cutadapt { container 'quay.io/biocontainers/cutadapt:1.16--py27_1' input: - tuple sample_id, file(input_forward_fq), file(input_reverse_fq) + tuple val(sample_id), file(reads) output: - tuple sample_id, file(forward_fq), file(reverse_fq) + tuple sample_id, file("trimmed_*.fastq") script: - forward_fq = "trimmed_forward.fastq" - reverse_fq = "trimmed_reverse.fastq" + forward_fq = "trimmed_1.fastq" + reverse_fq = "trimmed_2.fastq" - """ - cutadapt \ - -j ${task.cpus} \ - -q $params.cutadapt_min_quality \ - --minimum-length $params.cutadapt_min_length \ - --pair-filter=any \ - --output ${forward_fq} \ - --paired-output ${reverse_fq} '${input_forward_fq}' '${input_reverse_fq}' + if (params.singleEnd) { + processing = """ + cutadapt \ + -j ${task.cpus} \ + -q $params.cutadapt_min_quality \ + --minimum-length $params.cutadapt_min_length \ + --output ${forward_fq} \ + ${reads} + """ + } else { + processing = """ + cutadapt \ + -j ${task.cpus} \ + -q $params.cutadapt_min_quality \ + --minimum-length $params.cutadapt_min_length \ + --pair-filter=any \ + --output ${forward_fq} \ + --paired-output ${reverse_fq} ${reads} + + + """ + } + + version = """ cutadapt --version &> v_cutadapt.txt """ + + return processing + version } diff --git a/tools/cutadapt/test/main.nf b/tools/cutadapt/test/main.nf deleted file mode 100644 index 69c1eef8..00000000 --- a/tools/cutadapt/test/main.nf +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env nextflow -nextflow.preview.dsl = 2 -include '../../../nf-core/module_testing/check_process_outputs.nf' params(params) -include '../main.nf' params(params) - -// Define input channels -readPaths = [ - [ sample: 'SRR4238351', - R1: '../../../test-datasets/tools/cutadapt/input/SRR396636.sra_1.fastq', - R2: '../../../test-datasets/tools/cutadapt/input/SRR396636.sra_2.fastq' - ] -] -Channel - .from(readPaths) - .map { row -> tuple( row.sample_name, file(row.R1.trim()), file(row.R2.trim()) ) } - .set { ch_read_files } - -// Run the workflow -workflow { - cutadapt(ch_read_files) - // .check_output() -} diff --git a/tools/cutadapt/test_paired/main.nf b/tools/cutadapt/test_paired/main.nf new file mode 100644 index 00000000..46d0fdc6 --- /dev/null +++ b/tools/cutadapt/test_paired/main.nf @@ -0,0 +1,14 @@ +#!/usr/bin/env nextflow +nextflow.preview.dsl = 2 +include '../main.nf' params(params) + +// Define input channels + +Channel + .fromFilePairs('../../../test-datasets/tools/cutadapt/input/*_{1,2}.fastq' ) + .set { ch_read_files } + +// Run the workflow +workflow { + cutadapt(ch_read_files) +} diff --git a/tools/cutadapt/test_paired/nextflow.config b/tools/cutadapt/test_paired/nextflow.config new file mode 100644 index 00000000..08e52203 --- /dev/null +++ b/tools/cutadapt/test_paired/nextflow.config @@ -0,0 +1,9 @@ +docker.enabled = true +params.outdir = './results' + +params{ + //preprocessing options + cutadapt_min_length = 40 + cutadapt_min_quality = 25 + singleEnd = false +} diff --git a/tools/cutadapt/test_single/main.nf b/tools/cutadapt/test_single/main.nf new file mode 100644 index 00000000..96947ad0 --- /dev/null +++ b/tools/cutadapt/test_single/main.nf @@ -0,0 +1,21 @@ +#!/usr/bin/env nextflow +nextflow.preview.dsl = 2 +include '../main.nf' params(params) + +// Define input channels + +readPaths = [ + ['SRR4238351', '../../../test-datasets/tools/fastqc/input/SRR4238351_subsamp.fastq.gz'], + ['SRR4238355', '../../../test-datasets/tools/fastqc/input/SRR4238355_subsamp.fastq.gz'], + ['SRR4238359', '../../../test-datasets/tools/fastqc/input/SRR4238359_subsamp.fastq.gz'], + ['SRR4238379', '../../../test-datasets/tools/fastqc/input/SRR4238379_subsamp.fastq.gz'] +] +Channel + .from(readPaths) + .map { row -> [ row[0], [ file(row[1]) ] ] } + .set { ch_read_files } + +// Run the workflow +workflow { + cutadapt(ch_read_files) +} diff --git a/tools/cutadapt/test/nextflow.config b/tools/cutadapt/test_single/nextflow.config similarity index 87% rename from tools/cutadapt/test/nextflow.config rename to tools/cutadapt/test_single/nextflow.config index b1c505a7..4b805ff3 100644 --- a/tools/cutadapt/test/nextflow.config +++ b/tools/cutadapt/test_single/nextflow.config @@ -5,4 +5,5 @@ params{ //preprocessing options cutadapt_min_length = 40 cutadapt_min_quality = 25 + singleEnd = true }