From 6706a92d4de774716a99dae0acc5f599ad99e4ba Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent@modolo.fr>
Date: Wed, 20 Jan 2021 17:31:55 +0100
Subject: [PATCH] nf_modules: add kallisto to DSL2

---
 src/nf_modules/kallisto/main.nf | 71 +++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 src/nf_modules/kallisto/main.nf

diff --git a/src/nf_modules/kallisto/main.nf b/src/nf_modules/kallisto/main.nf
new file mode 100644
index 00000000..a2dc3d70
--- /dev/null
+++ b/src/nf_modules/kallisto/main.nf
@@ -0,0 +1,71 @@
+version = "0.44.0"
+container_url = "lbmc/kallisto:${version}"
+
+process index_fasta {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$fasta.baseName"
+  publishDir "results/mapping/index/", mode: 'copy'
+
+  input:
+    path fasta
+
+  output:
+    path "*.index*", emit: index
+    path "*_report.txt", emit: report
+
+  script:
+"""
+kallisto index -k 31 --make-unique -i ${fasta.baseName}.index ${fasta} \
+2> ${fasta.baseName}_kallisto_index_report.txt
+"""
+}
+
+
+process mapping_fastq_pairedend {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$pair_id"
+  publishDir "results/mapping/counts/", mode: 'copy'
+
+  input:
+  tuple val(pair_id), path(reads)
+  path index.collect()
+
+  output:
+  path "${pair_id}", emit: counts
+  path "*_report.txt", emit: report
+
+  script:
+"""
+mkdir ${pair_id}
+kallisto quant -i ${index} -t ${task.cpus} \
+--bias --bootstrap-samples 100 -o ${pair_id} \
+${reads[0]} ${reads[1]} &> ${pair_id}_kallisto_mapping_report.txt
+"""
+}
+
+
+process mapping_fastq_singleend {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$file_id"
+  publishDir "results/mapping/counts/", mode: 'copy'
+
+  input:
+  tuple val(file_id), path(reads)
+  path index.collect()
+
+  output:
+  path "${pair_id}", emit: counts
+  path "*_report.txt", emit: report
+
+  script:
+"""
+mkdir ${file_id}
+kallisto quant -i ${index} -t ${task.cpus} --single \
+--bias --bootstrap-samples 100 -o ${file_id} \
+-l ${params.mean} -s ${params.sd} \
+${reads} &> ${file_id}_kallisto_mapping_report.txt
+"""
+}
-- 
GitLab