From 9ef97beaef840b84c178ecfdb153b5c44274ad50 Mon Sep 17 00:00:00 2001
From: aliarifki <aliarifki@outlook.fr>
Date: Tue, 20 Jun 2023 11:11:18 +0200
Subject: [PATCH] =?UTF-8?q?Contr=C3=B4le=20qualit=C3=A9=20et=20basecalling?=
 =?UTF-8?q?=20en=20mode=20gpu?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/bolero.nf                    |  8 +++--
 src/nextflow.config              | 61 +++++++++++++++++---------------
 src/nf_modules/ont-guppy/main.nf |  4 ++-
 src/nf_modules/pycoqc/main.nf    | 21 +++++++++++
 4 files changed, 63 insertions(+), 31 deletions(-)
 create mode 100644 src/nf_modules/pycoqc/main.nf

diff --git a/src/bolero.nf b/src/bolero.nf
index 0e7e3fa..5c37e4d 100755
--- a/src/bolero.nf
+++ b/src/bolero.nf
@@ -92,6 +92,7 @@ params.num_callers = 16
 params.chunks_per_runner = 512
 params.chunk_size = 1900
 
+
 /* Params out */
 
 params.basecalling_out = "01_Basecalling/"
@@ -171,6 +172,7 @@ if(!params.skipBC) {
   }
 }
 
+include { pycoqc } from "./nf_modules/pycoqc/main.nf"
 include { concatenate } from "./nf_modules/seqkit/main.nf"
 include { cut_5pRACE } from "./nf_modules/cutadapt/main.nf"
 include { hbv_genome } from "./nf_modules/minimap2/main.nf"
@@ -192,9 +194,9 @@ include { rna_count } from "./nf_modules/rna_count/main.nf"
 */
 
 workflow {
-
   //######################## BASECALLING ########################
 
+
   if(params.skipBC) { // we take fastq files as input and skip basecalling
     concatenate(barcodes)
   }
@@ -204,10 +206,12 @@ workflow {
     if(params.gpu_mode) {
       basecall_fast5_gpu(input)
       concatenate(basecall_fast5_gpu.out.pass)
+      pycoqc(basecall_fast5_gpu.sequencing_summary)
     }
     else {
       basecall_fast5_cpu(input)
       concatenate(basecall_fast5_cpu.out.pass)
+      pycoqc(basecall_fast5_cpu.sequencing_summary)
     }
   }
 
@@ -241,5 +245,5 @@ workflow {
   //#################### VARIANTS D'EPISSAGE ####################
 
   rna_count(junctions_nanosplicer.out.identified_SPvariants, start_position_individuals.out.classification_of_reads)
-
+*/
 }
diff --git a/src/nextflow.config b/src/nextflow.config
index e544f2f..b1b3d86 100755
--- a/src/nextflow.config
+++ b/src/nextflow.config
@@ -72,37 +72,42 @@ profiles {
       }
     }
   }
+  
   pollux {
-    singularity.enabled = true
-    singularity.cacheDir = "./bin/"
-    singularity.runOptions = "--bind /data,/home"
-    process {
-      errorStrategy = 'finish'
-      memory = '32GB'
-      withLabel: big_mem_mono_cpus {
-        cpus = 1
-      }
-      withLabel: big_mem_multi_cpus {
-        cpus = 16
-      }
-      withLabel: small_mem_mono_cpus {
-        cpus = 1
-        memory = '2GB'
-      }
-      withLabel: small_mem_multi_cpus {
-        cpus = 8
-        memory = '2GB'
-      }
-      withLabel: mid_mem_mono_cpus {
-        cpus = 1
-        memory = '8GB'
-      }
-      withLabel: mid_mem_multi_cpus {
-        cpus = 8
-        memory = '8GB'
+      singularity.enabled = true
+      singularity.cacheDir = "./bin/"
+      singularity.runOptions = "--bind /data,/home"
+      process {
+        errorStrategy = 'finish'
+        memory = '256GB'
+        withLabel: big_mem_mono_cpus {
+          cpus = 1
+        }
+        withLabel: big_mem_multi_cpus {
+          cpus = 16
+        }
+        withLabel: small_mem_mono_cpus {
+          cpus = 1
+          memory = '2GB'
+        }
+        withLabel: small_mem_multi_cpus {
+          cpus = 8
+          memory = '2GB'
+        }
+        withLabel: mid_mem_mono_cpus {
+          cpus = 1
+          memory = '8GB'
+        }
+        withLabel: mid_mem_multi_cpus {
+          cpus = 8
+          memory = '8GB'
+        }
+        withLabel: gpus {
+          maxForks = 1
+          containerOptions = '--nv'
+        }
       }
     }
-  }
 
   singularity {
     singularity.enabled = true
diff --git a/src/nf_modules/ont-guppy/main.nf b/src/nf_modules/ont-guppy/main.nf
index 7169b7a..d806d33 100644
--- a/src/nf_modules/ont-guppy/main.nf
+++ b/src/nf_modules/ont-guppy/main.nf
@@ -1,6 +1,7 @@
 version = "6.4.6"
 container_url = "xgrand/ont-guppy:${version}"
 
+params.config_file = ""
 params.basecalling_out = ""
 params.flowcell = "FLO-MIN106"
 params.kit = "SQK-PBK004"
@@ -51,7 +52,8 @@ guppy_basecaller --compress_fastq \
    --min_qscore ${params.min_qscore} \
    --gpu_runners_per_device ${params.gpu_runners_per_device} \
    --num_callers ${params.num_callers} \
-   --chunks_per_runner ${params.chunks_per_runner}
+   --chunks_per_runner ${params.chunks_per_runner} \
+   ${params.config_file}
 """
 }
 
diff --git a/src/nf_modules/pycoqc/main.nf b/src/nf_modules/pycoqc/main.nf
new file mode 100644
index 0000000..1951dbf
--- /dev/null
+++ b/src/nf_modules/pycoqc/main.nf
@@ -0,0 +1,21 @@
+version = "2.5.2"
+container_url = "xgrand/pycoqc:${version}"
+
+process pycoqc {
+  container = "${container_url}"
+  label "small_mem_mono_cpus"
+  
+  if (params.basecalling_out != "") {
+    publishDir "results/${params.basecalling_out}", mode: 'copy'
+  }
+
+  input:
+  path(txt)
+
+  output:
+  path("*.html")
+
+  """
+  pycoQC -f ${txt} -o quality_control.html)
+  """
+}
\ No newline at end of file
-- 
GitLab