From 3490e2f1b557c52ddf09a90262260938dd9debb9 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent@modolo.fr>
Date: Wed, 20 Jan 2021 17:17:31 +0100
Subject: [PATCH] nf_modules: add DSL2 for cutadapt

---
 src/nf_modules/bowtie2/main.nf  |  4 +-
 src/nf_modules/cutadapt/main.nf | 91 +++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 2 deletions(-)
 create mode 100644 src/nf_modules/cutadapt/main.nf

diff --git a/src/nf_modules/bowtie2/main.nf b/src/nf_modules/bowtie2/main.nf
index 46b30a76..d96b1214 100644
--- a/src/nf_modules/bowtie2/main.nf
+++ b/src/nf_modules/bowtie2/main.nf
@@ -1,5 +1,5 @@
-bowtie_version = "2.3.4.1"
-container_url = "lbmc/bowtie2:${bowtie_version}"
+version = "2.3.4.1"
+container_url = "lbmc/bowtie2:${version}"
 
 process index_fasta {
   container = "${container_url}"
diff --git a/src/nf_modules/cutadapt/main.nf b/src/nf_modules/cutadapt/main.nf
new file mode 100644
index 00000000..74c37be0
--- /dev/null
+++ b/src/nf_modules/cutadapt/main.nf
@@ -0,0 +1,91 @@
+version = "2.1"
+container_url = "lbmc/cutadapt:${version}"
+
+adapter_3_prim = "AGATCGGAAGAG"
+adapter_5_prim = "CTCTTCCGATCT"
+trim_quality = "20"
+
+
+process adaptor_removal_paired {
+  container = "${container_url}"
+  label "big_mem_mono_cpus"
+  tag "$pair_id"
+  publishDir "results/fastq/adaptor_removal/", mode: 'copy'
+
+  input:
+  tuple val(pair_id), path(reads)
+
+  output:
+  tuple val(pair_id), path("*_cut_R{1,2}.fastq.gz"), emit: fastq
+  path "*_report.txt", emit: report
+
+  script:
+  """
+  cutadapt -a ${adapter_3_prim} -g ${adapter_5_prim} -A ${adapter_3_prim} -G ${adapter_5_prim} \
+  -o ${pair_id}_cut_R1.fastq.gz -p ${pair_id}_cut_R2.fastq.gz \
+  ${reads[0]} ${reads[1]} > ${pair_id}_report.txt
+  """
+}
+
+process adaptor_removal_singleend {
+  container = "${container_url}"
+  label "big_mem_mono_cpus"
+  tag "$file_id"
+  publishDir "results/fastq/adaptor_removal/", mode: 'copy'
+
+  input:
+  tuple val(file_id), path(reads)
+
+  output:
+  tuple val(file_id), path("*_cut.fastq.gz"), emit: fastq
+  path "*_report.txt", emit: report
+
+  script:
+  """
+  cutadapt -a ${adapter_3_prim} -g ${adapter_5_prim} \
+  -o ${file_id}_cut.fastq.gz \
+  ${reads} > ${file_id}_report.txt
+  """
+}
+
+process trimming_pairedend {
+  container = "${container_url}"
+  label "big_mem_mono_cpus"
+  tag "$pair_id"
+  publishDir "results/fastq/trimming/", mode: 'copy'
+
+  input:
+  tuple val(pair_id), path(reads)
+
+  output:
+  tuple val(pair_id), path("*_trim_R{1,2}.fastq.gz"), emit:fastq
+  path "*_report.txt", emit: report
+
+  script:
+  """
+  cutadapt -q ${trim_quality},${trim_quality} \
+  -o ${pair_id}_trim_R1.fastq.gz -p ${pair_id}_trim_R2.fastq.gz \
+  ${reads[0]} ${reads[1]} > ${pair_id}_report.txt
+  """
+}
+
+process trimming_singleend {
+  container = "${container_url}"
+  label "big_mem_mono_cpus"
+  tag "$file_id"
+
+  input:
+  tuple val(file_id), path(reads)
+
+  output:
+  tuple val(file_id), path("*_trim.fastq.gz"), emit: fastq
+  path "*_report.txt", emit: report
+
+  script:
+  """
+  cutadapt -q ${trim_quality},${trim_quality} \
+  -o ${file_id}_trim.fastq.gz \
+  ${reads} > ${file_id}_report.txt
+  """
+}
+
-- 
GitLab