From f19a3ec0c9b7c991ed8e935124140f4dec0c5da0 Mon Sep 17 00:00:00 2001
From: elabaron <emmanuel.labaronne@ens-lyon.fr>
Date: Tue, 24 Jul 2018 17:28:45 +0200
Subject: [PATCH] Add Ribowave and Fastq nf modules  Changes to be committed: 
 new file:   src/10_ribowave.nf 	modified:  
 src/docker_modules/FastQC/0.11.5/Dockerfile : Add perl instalation 	new
 file:   src/nf_modules/FastQC/fastqc.config 	new file:  
 src/nf_modules/FastQC/fastqc.nf 	renamed:   
 src/nf_modules/Ribowave/10_ribowave.nf ->
 src/nf_modules/Ribowave/pipeline_PSMN.nf 	new file:  
 src/nf_modules/Ribowave/pipeline_docker.nf 	modified:  
 src/nf_modules/Ribowave/test/P-site.nf 	new file:  
 src/ribowave.config

---
 src/10_ribowave.nf                            | 121 ++++++++++++++++++
 src/docker_modules/FastQC/0.11.5/Dockerfile   |   3 +-
 src/nf_modules/FastQC/fastqc.config           |  18 +++
 src/nf_modules/FastQC/fastqc.nf               |  33 +++++
 .../{10_ribowave.nf => pipeline_PSMN.nf}      |   0
 src/nf_modules/Ribowave/pipeline_docker.nf    | 121 ++++++++++++++++++
 src/nf_modules/Ribowave/test/P-site.nf        |  10 +-
 src/ribowave.config                           |  60 +++++++++
 8 files changed, 360 insertions(+), 6 deletions(-)
 create mode 100644 src/10_ribowave.nf
 create mode 100644 src/nf_modules/FastQC/fastqc.config
 create mode 100644 src/nf_modules/FastQC/fastqc.nf
 rename src/nf_modules/Ribowave/{10_ribowave.nf => pipeline_PSMN.nf} (100%)
 create mode 100644 src/nf_modules/Ribowave/pipeline_docker.nf
 create mode 100644 src/ribowave.config

diff --git a/src/10_ribowave.nf b/src/10_ribowave.nf
new file mode 100644
index 00000000..a9c41c33
--- /dev/null
+++ b/src/10_ribowave.nf
@@ -0,0 +1,121 @@
+/*
+* Ribowave :
+* Inputs : gtf genome files
+* Inputs : bam file
+* Inputs : genome size file
+*/
+
+/* 		PARAMETERS		 */
+
+params.gtf = ""
+params.genome = ""
+params.bam = ""
+params.genomesize = ""
+
+log.info "gtf file : ${params.gtf}"
+log.info "genome fasta file : ${params.genome}"
+log.info "bam file(s) : ${params.bam}"
+log.info "genomesize file : ${params.genomesize}"
+
+Channel
+  .fromPath( params.gtf )
+  .ifEmpty { error "Cannot find any fasta files matching: ${params.gtf}" }
+  .set { gtf_file }
+Channel
+  .fromPath( params.genome )
+  .ifEmpty { error "Cannot find any fasta files matching: ${params.genome}" }
+  .set { genome_file }
+Channel
+  .fromPath( params.bam )
+  .ifEmpty { error "Cannot find any fastq files matching: ${params.bam}" }
+  .set { bam_files }
+bam_files.into {bam_deter_P_site ; bam_track_P_site}
+Channel
+  .fromPath( params.genomesize )
+  .ifEmpty { error "Cannot find any index files matching: ${params.genomesize}" }
+  .set { genomesize_file }
+
+
+/*		CREATE ANNOTATION		*/
+
+process create_annot {
+  publishDir "results/ribowave/annotation", mode: 'copy'
+
+  input:
+    file gtf from gtf_file
+    file genome from genome_file
+
+  output:
+    file "*" into annot_file
+    file "start_codon.bed" into start_codon_channel
+    file "final.ORFs" into finalORF_channel
+    file "exons.gtf" into exon_gtf_channel
+
+  script:
+"""
+/Ribowave/scripts/create_annotation.sh -G ${gtf} -f ${genome}  -o ./  -s /Ribowave/scripts
+"""
+}
+
+
+/*		P-site determination		*/
+
+process determination_P_site {
+  tag "$bam.baseName"
+  publishDir "results/ribowave", mode: 'copy'
+
+  input:
+  file bam from bam_deter_P_site
+  file start from start_codon_channel
+
+  output:
+  file "*" into p_site_channel
+  file "*psite1nt.txt" into psite1nt_channel
+
+  script:
+"""
+/Ribowave/scripts/P-site_determination.sh -i ${bam} -S ${start} -o ./ -n ${bam.baseName} -s /Ribowave/scripts
+"""
+}
+
+/*		P-site track		*/
+
+process track_P_site {
+  tag "$bam.baseName"
+  publishDir "results/ribowave", mode: 'copy'
+
+  input:
+  file bam from bam_track_P_site
+  file exon from exon_gtf_channel
+  file genomesize from genomesize_file
+  file p_site from psite1nt_channel
+
+  output:
+  file "*" into track_p_site_channel
+  file "final.psite" into psite_channel
+  
+
+  script:
+"""
+/Ribowave/scripts/create_track_Ribo.sh -i ${bam} -G ${exon} -g ${genomesize} -P ${p_site} -o ./ -n ${bam.baseName} -s /Ribowave/scripts
+"""
+}
+
+/*		ribowave Identifying translated ORF		*/
+
+process ribowave_transORF {
+  publishDir "results/ribowave", mode: 'copy'
+
+  input:
+  file psite from psite_channel
+  file finalORF from finalORF_channel
+
+  output:
+  file "*" into ribowave_channel
+
+  script:
+"""
+/Ribowave/scripts/Ribowave -PD -a ${psite} -b ${finalORF} -o ./ -n ${bam.baseName} -s /Ribowave/scripts -p 2
+"""
+}
+
diff --git a/src/docker_modules/FastQC/0.11.5/Dockerfile b/src/docker_modules/FastQC/0.11.5/Dockerfile
index f7b999e4..d8956a15 100644
--- a/src/docker_modules/FastQC/0.11.5/Dockerfile
+++ b/src/docker_modules/FastQC/0.11.5/Dockerfile
@@ -2,7 +2,8 @@ FROM ubuntu:18.04
 MAINTAINER Laurent Modolo
 
 ENV FASTQC_VERSION=0.11.5
-ENV PACKAGES fastqc=${FASTQC_VERSION}*
+ENV PACKAGES fastqc=${FASTQC_VERSION}* \
+		perl
 
 RUN apt-get update && \
     apt-get install -y --no-install-recommends ${PACKAGES} && \
diff --git a/src/nf_modules/FastQC/fastqc.config b/src/nf_modules/FastQC/fastqc.config
new file mode 100644
index 00000000..e7b3280a
--- /dev/null
+++ b/src/nf_modules/FastQC/fastqc.config
@@ -0,0 +1,18 @@
+profiles {
+  docker {
+    docker.temp = 'auto'
+    docker.enabled = true
+    process {
+      $fastqc {
+        container = "fastqc:0.11.5"
+      }
+    }
+  }
+  sge {
+    process{
+      $fastqc {
+        beforeScript = "source /home/elabaron/.bashrc ; module load FastQC/0.11.5"
+      }
+    }
+  }
+}
diff --git a/src/nf_modules/FastQC/fastqc.nf b/src/nf_modules/FastQC/fastqc.nf
new file mode 100644
index 00000000..5725497d
--- /dev/null
+++ b/src/nf_modules/FastQC/fastqc.nf
@@ -0,0 +1,33 @@
+/*
+* fastqc :
+* Imputs : fastq files
+* Output : pdf files
+*/
+
+/*                      fastQC                                     */
+params.fastq = ""
+
+log.info "fastq files : ${params.fastq}"
+
+Channel
+  .fromPath( params.fastq )
+  .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" }
+  .set { fastq_files }
+
+process fastqc {
+  tag "$fastq.baseName"
+  publishDir "results/fasqc/${fastq.baseName}/", mode: 'copy'
+
+  input:
+    file fastq from fastq_files
+
+  output:
+    file "*" into fastqc_repport
+
+  script:
+"""
+fastqc -o ./ --noextract -f fastq ${fastq}
+"""
+}
+
+
diff --git a/src/nf_modules/Ribowave/10_ribowave.nf b/src/nf_modules/Ribowave/pipeline_PSMN.nf
similarity index 100%
rename from src/nf_modules/Ribowave/10_ribowave.nf
rename to src/nf_modules/Ribowave/pipeline_PSMN.nf
diff --git a/src/nf_modules/Ribowave/pipeline_docker.nf b/src/nf_modules/Ribowave/pipeline_docker.nf
new file mode 100644
index 00000000..9c9ff82a
--- /dev/null
+++ b/src/nf_modules/Ribowave/pipeline_docker.nf
@@ -0,0 +1,121 @@
+/*
+* Ribowave :
+* Inputs : gtf genome files
+* Inputs : bam file
+* Inputs : genome size file
+*/
+
+/* 		PARAMETERS		 */
+
+params.gtf = ""
+params.genome = ""
+params.bam = ""
+params.genomesize = ""
+
+log.info "gtf file : ${params.gtf}"
+log.info "genome fasta file : ${params.genome}"
+log.info "bam file(s) : ${params.bam}"
+log.info "genomesize file : ${params.genomesize}"
+
+Channel
+  .fromPath( params.gtf )
+  .ifEmpty { error "Cannot find any fasta files matching: ${params.gtf}" }
+  .set { gtf_file }
+Channel
+  .fromPath( params.genome )
+  .ifEmpty { error "Cannot find any fasta files matching: ${params.genome}" }
+  .set { genome_file }
+Channel
+  .fromPath( params.bam )
+  .ifEmpty { error "Cannot find any fastq files matching: ${params.bam}" }
+  .set { bam_files }
+bam_files.into {bam_deter_P_site ; bam_track_P_site ; bam_ribowave}
+Channel
+  .fromPath( params.genomesize )
+  .ifEmpty { error "Cannot find any index files matching: ${params.genomesize}" }
+  .set { genomesize_file }
+
+
+/*		CREATE ANNOTATION		*/
+
+process create_annot {
+  publishDir "results/ribowave/annotation", mode: 'copy'
+
+  input:
+    file gtf from gtf_file
+    file genome from genome_file
+
+  output:
+    file "*" into annot_file
+    file "start_codon.bed" into start_codon_channel
+    file "exons.gtf" into exon_gtf_channel
+    file "final.ORFs" into finalORF_channel
+
+  script:
+"""
+/Ribowave/scripts/create_annotation.sh -G ${gtf} -f ${genome}  -o ./  -s /Ribowave/scripts
+"""
+}
+
+
+/*		P-site determination		*/
+
+process determination_P_site {
+  tag "$bam.baseName"
+  publishDir "results/ribowave/", mode: 'copy'
+
+  input:
+  file bam from bam_deter_P_site
+  file start from start_codon_channel
+
+  output:
+  file "*" into p_site_channel
+  file "P-site/*1nt.txt" into psite1nt_channel
+
+  script:
+"""
+/Ribowave/scripts/P-site_determination.sh -i ${bam} -S ${start} -o ./ -n ${bam.baseName} -s /Ribowave/scripts
+"""
+}
+
+/*		P-site track		*/
+process track_P_site {
+  tag "$bam.baseName"
+  publishDir "results/ribowave", mode: 'copy'
+
+  input:
+  file bam from bam_track_P_site
+  file exon from exon_gtf_channel
+  file genomesize from genomesize_file
+  file p_site from psite1nt_channel
+
+  output:
+  file "*" into track_p_site_channel
+  file "bedgraph/${bam.baseName}/final.psite" into psite_channel 
+  
+
+  script:
+"""
+/Ribowave/scripts/create_track_Ribo.sh -i ${bam} -G ${exon} -g ${genomesize} -P ${p_site} -o ./ -n ${bam.baseName} -s /Ribowave/scripts
+"""
+}
+/*		ribowave Identifying translated ORF		*/
+
+process ribowave_transORF {
+  tag "$bam.baseName"
+  publishDir "results/ribowave", mode: 'copy'
+
+  input:
+  file psite from psite_channel
+  file bam from bam_ribowave
+  file finalORF from finalORF_channel
+
+  output:
+  file "*" into ribowave_channel
+
+  script:
+"""
+/Ribowave/scripts/Ribowave -PD -a ${psite} -b ${finalORF} -o ./ -n ${bam.baseName} -s /Ribowave/scripts -p 2
+"""
+}
+
diff --git a/src/nf_modules/Ribowave/test/P-site.nf b/src/nf_modules/Ribowave/test/P-site.nf
index 735a5a53..e1211223 100644
--- a/src/nf_modules/Ribowave/test/P-site.nf
+++ b/src/nf_modules/Ribowave/test/P-site.nf
@@ -1,10 +1,8 @@
 params.bam = ""
 params.start = ""
-params.jobname = ""
 
 log.info "bam file(s) : ${params.bam}"
 log.info "start_codon file : ${params.start}"
-log.info "job name : ${params.jobname}"
 
 Channel
   .fromPath( params.bam )
@@ -15,8 +13,9 @@ Channel
   .ifEmpty { error "Cannot find any index files matching: ${params.start}" }
   .set { start_file }
 
-process p_site {
-  publishDir "results/ribowave/P-site", mode: 'copy'
+process determination_P_site {
+  tag "$bam.baseName"
+  publishDir "results/ribowave", mode: 'copy'
 
   input:
   file bam from bam_files
@@ -24,9 +23,10 @@ process p_site {
 
   output:
   file "*" into p_site_channel
+  file "*psite1nt.txt" into psite1nt_channel
 
   script:
 """
-/Ribowave/scripts/P-site_determination.sh -i ${bam} -S ${start} -o ./ -n ${params.jobname} -s /Ribowave/scripts
+/Ribowave/scripts/P-site_determination.sh -i ${bam} -S ${start} -o ./ -n ${bam.baseName} -s /Ribowave/scripts
 """
 }
diff --git a/src/ribowave.config b/src/ribowave.config
new file mode 100644
index 00000000..59e6a55d
--- /dev/null
+++ b/src/ribowave.config
@@ -0,0 +1,60 @@
+profiles {
+  docker {
+    docker.temp = 'auto'
+    docker.enabled = true
+    process {
+      $create_annot {
+        container = "ribowave:1.0"
+      }
+      $determination_P_site {
+        container = "ribowave:1.0"
+      }
+      $track_P_site {
+        container = "ribowave:1.0"
+      }
+      $ribowave_transORF {
+        container = "ribowave:1.0"
+      }
+    }
+  }
+  sge {
+    process{
+      $create_annot {
+        beforeScript = "source /home/elabaron/.bashrc; module load BEDtools/2.25.0"
+        executor = "sge"
+        cpus = 8
+        memory = "5GB"
+        time = "6h"
+        queue = '*-E5-2667*'
+        penv = 'openmp8'
+      }
+      $determination_P_site {
+        beforeScript = "source /home/elabaron/.bashrc; module load BEDtools/2.25.0"
+        executor = "sge"
+        cpus = 8
+        memory = "5GB"
+        time = "6h"
+        queue = '*-E5-2667*'
+        penv = 'openmp8'
+      }
+      $track_P_site {
+        beforeScript = "source /home/elabaron/.bashrc; module load BEDtools/2.25.0"
+        executor = "sge"
+        cpus = 8
+        memory = "5GB"
+        time = "6h"
+        queue = '*-E5-2667*'
+        penv = 'openmp8'
+      }
+      $ribowave_transORF {
+        beforeScript = "source /home/elabaron/.bashrc; module load BEDtools/2.25.0"
+        executor = "sge"
+        cpus = 8
+        memory = "128GB"
+        time = "6h"
+        queue = '*-E5-2667*'
+        penv = 'openmp8'
+      }
+    }
+  }
+}
-- 
GitLab