From 622494cadc960d4e4a206447b34030bc4050bf91 Mon Sep 17 00:00:00 2001
From: aliarifki <aliarifki@outlook.fr>
Date: Wed, 21 Jun 2023 10:24:46 +0200
Subject: [PATCH] Ajout du process barcoding

---
 src/bolero.nf                    | 12 +++++++--
 src/nf_modules/ont-guppy/main.nf | 42 +++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/src/bolero.nf b/src/bolero.nf
index 5c37e4d..cd2387a 100755
--- a/src/bolero.nf
+++ b/src/bolero.nf
@@ -91,7 +91,7 @@ params.gpu_runners_per_device = 32
 params.num_callers = 16
 params.chunks_per_runner = 512
 params.chunk_size = 1900
-
+params.config_file = ""
 
 /* Params out */
 
@@ -156,6 +156,11 @@ Channel
     .map(it -> [it.baseName, it])
     .set{barcodes}
 
+// Test pour barcoding process
+Channel
+    .fromPath(params.pass)
+    .set{pass}
+
 /*
  ****************************************************************
                           Imports
@@ -164,6 +169,7 @@ Channel
 
 if(!params.skipBC) {
   /* Hardware configuration, if Nvidia CUDA compatible graphic card is installed, use guppy-gpu, else guppy-cpu (much slower)*/
+  include { barcoding } from "./nf_modules/ont-guppy/main.nf"
   if(params.gpu_mode) {
     include { basecall_fast5_gpu } from "./nf_modules/ont-guppy/main.nf"
   }
@@ -194,9 +200,11 @@ include { rna_count } from "./nf_modules/rna_count/main.nf"
 */
 
 workflow {
+  pass.view()
+  barcoding(pass)
   //######################## BASECALLING ########################
 
-
+/*
   if(params.skipBC) { // we take fastq files as input and skip basecalling
     concatenate(barcodes)
   }
diff --git a/src/nf_modules/ont-guppy/main.nf b/src/nf_modules/ont-guppy/main.nf
index 5c615eb..c4f8278 100644
--- a/src/nf_modules/ont-guppy/main.nf
+++ b/src/nf_modules/ont-guppy/main.nf
@@ -9,6 +9,7 @@ params.min_qscore = 7.0
 params.gpu_runners_per_device = 1
 params.num_callers = 1
 params.chunks_per_runner = 1
+options = ""
 process basecall_fast5_gpu {
   container = "${container_url}"
   label "gpu"
@@ -27,6 +28,14 @@ process basecall_fast5_gpu {
       errorKit.view()
   }
 
+  if (params.config_file != "") {
+    options = "-c /opt/ont/guppy/data/${params.config_file}"
+  }
+  else {
+    options = "--flowcell ${params.flowcell} \
+--kit ${params.kit} "
+  }
+
   input:
     path(fast5_folder)
 
@@ -46,14 +55,12 @@ guppy_basecaller --compress_fastq \
    -i / \
    --input_file_list fichier.txt \
    -s . \
-   --flowcell ${params.flowcell} \
-   --kit ${params.kit} \
    -x "cuda:all" \
    --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} \
-   -c ${params.config_file}
+   ${options}
 """
 }
 
@@ -97,4 +104,33 @@ guppy_basecaller --compress_fastq \
    --flowcell ${params.flowcell} \
    --kit ${params.kit}
 """
+}
+
+process barcoding {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$fast5_folder"
+  if (params.barcoding_out != "") {
+    publishDir "results/${params.barcoding_out}", mode: 'copy'
+  }
+
+  input:
+    path(pass_path)
+  
+  output:
+    path("barcode")
+  
+  script:
+"""
+guppy_barcoder \
+  --input_path ${pass_path} \
+  --save_path barcode/ \
+  -c /opt/ont/guppy/data/${params.config_file} \
+  --barcode_kits ${params.kit} \
+  --progress_stats_frequency 60 \
+  -x "cuda:all" \
+  --enable_trim_barcodes \
+  --trim_adapters \
+  --compress_fastq
+"""
 }
\ No newline at end of file
-- 
GitLab