From f07cbf2d2da0aa1d70459e87dc773e50b3da5f2e Mon Sep 17 00:00:00 2001
From: elabaron <emmanuel.labaronne@ens-lyon.fr>
Date: Wed, 6 Jun 2018 14:59:49 +0000
Subject: [PATCH] RNAseq.ng: add kallisto index and mapping blocks

---
 src/RNAseq.nf | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/src/RNAseq.nf b/src/RNAseq.nf
index a6792735..dd31c13f 100644
--- a/src/RNAseq.nf
+++ b/src/RNAseq.nf
@@ -76,3 +76,60 @@ bedtools getfasta -name \
 """
 }
 
+params.fasta = "$baseDir/data/bam/*.fasta"
+
+log.info "fasta files : ${params.fasta}"
+
+Channel
+  .fromPath( params.fasta )
+  .ifEmpty { error "Cannot find any fasta files matching: ${params.fasta}" }
+  .set { fasta_file }
+
+process index_fasta {
+  tag "$fasta.baseName"
+  publishDir "results/mapping/index/", mode: 'copy'
+
+  input:
+    file fasta from fasta_file
+
+  output:
+    file "*.index*" into index_files
+
+  script:
+"""
+kallisto index -k 31 --make-unique -i ${fasta.baseName}.index ${fasta} \
+> ${fasta.baseName}_kallisto_report.txt
+"""
+}
+
+params.index = "$baseDir/data/index/*.index.*"
+
+log.info "index files : ${params.index}"
+
+Channel
+  .fromPath( params.index )
+  .ifEmpty { error "Cannot find any index files matching: ${params.index}" }
+  .set { index_files }
+
+process mapping_fastq {
+  tag "$reads"
+  cpus 4
+  publishDir "results/mapping/quantification/", mode: 'copy'
+
+  input:
+  file reads from fastq_files
+  file index from index_files.toList()
+
+  output:
+  file "*" into counts_files
+
+  script:
+"""
+mkdir ${reads[0].baseName}
+kallisto quant -i ${index} -t ${task.cpus} \
+--bias --bootstrap-samples 100 -o ${reads[0].baseName} \
+${reads[0]} ${reads[1]} &> ${reads[0].baseName}_kallisto_report.txt
+"""
+}
+
+
-- 
GitLab