From 4b0a2fe37b332786a8ca96727cf130cf02300c96 Mon Sep 17 00:00:00 2001
From: nservant <nicolas.servant@curie.fr>
Date: Mon, 19 Dec 2022 17:36:51 +0100
Subject: [PATCH] [MODIF] update local modules

---
 bin/check_samplesheet.py                   |  2 +-
 conf/modules.config                        |  8 +++++++-
 modules/local/hicpro/bowtie2_merge.nf      |  2 +-
 modules/local/hicpro/build_contact_maps.nf | 13 +++++++------
 modules/local/hicpro/combine_mates.nf      |  2 +-
 modules/local/hicpro/merge_stats.nf        |  1 +
 modules/local/hicpro/run_ice.nf            |  2 +-
 modules/local/multiqc.nf                   |  8 ++++----
 modules/local/split_cooler_dump.nf         |  9 +++++++--
 subworkflows/local/hicpro.nf               |  1 +
 subworkflows/local/input_check.nf          |  1 -
 workflows/hic.nf                           |  1 +
 12 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/bin/check_samplesheet.py b/bin/check_samplesheet.py
index 59af511..c498ef4 100755
--- a/bin/check_samplesheet.py
+++ b/bin/check_samplesheet.py
@@ -126,7 +126,7 @@ class RowChecker:
         for row in self.modified:
             sample = row[self._sample_col]
             seen[sample] += 1
-            row[self._sample_col] = f"{sample}_T{seen[sample]}"
+            ##row[self._sample_col] = f"{sample}_T{seen[sample]}"
 
 
 def read_head(handle, num_lines=10):
diff --git a/conf/modules.config b/conf/modules.config
index 6a5ccd5..031e7c6 100644
--- a/conf/modules.config
+++ b/conf/modules.config
@@ -163,6 +163,7 @@ process {
             mode: 'copy',
             enabled: params.hicpro_maps
         ]
+	ext.prefix = { "${meta.id}.${resolution}" }
     }
 
     withName: 'ICE_NORMALIZATION' {
@@ -193,6 +194,7 @@ process {
             saveAs: { filename -> filename.equals('versions.yml') ? null : filename },
             mode: 'copy'
         ]
+	ext.prefix={ "cooler_bins_${cool_bin}" }
     }
 
     withName: 'COOLER_CLOAD' {
@@ -202,6 +204,7 @@ process {
             mode: 'copy',
             enabled : params.save_raw_maps
         ]
+	ext.prefix = { "${meta.id}.${cool_bin}" }
         ext.args = "pairs -c1 2 -p1 3 -c2 4 -p2 5"
     }
 
@@ -212,7 +215,7 @@ process {
             mode: 'copy'
         ]
         ext.args = '--force'
-	ext.prefix = { "${meta.id}_balanced" }
+	ext.prefix = { "${cool.baseName}_balanced" }
     }
 
     withName: 'COOLER_DUMP' {
@@ -258,6 +261,7 @@ process {
             mode: 'copy'
         ]
         ext.args = '--bigwig'
+	ext.prefix = { "${meta.id}.${resolution}" }
     }
 
     //********************************
@@ -270,6 +274,7 @@ process {
             mode: 'copy'
         ]
         ext.args = '15 25 50 --window-pixels'
+	ext.prefix = { "${meta.id}.${resolution}" }
     }
 
     withName: 'HIC_FIND_TADS' {
@@ -279,5 +284,6 @@ process {
             mode: 'copy'
         ]
         ext.args = '--correctForMultipleTesting fdr'
+	ext.prefix = { "${meta.id}.${resolution}" }
     }
 }
diff --git a/modules/local/hicpro/bowtie2_merge.nf b/modules/local/hicpro/bowtie2_merge.nf
index ed200d6..ed6817c 100644
--- a/modules/local/hicpro/bowtie2_merge.nf
+++ b/modules/local/hicpro/bowtie2_merge.nf
@@ -1,5 +1,5 @@
 process MERGE_BOWTIE2{
-    tag "$prefix"
+    tag "${meta.id}"
     label 'process_medium'
 
     conda (params.enable_conda ? "bioconda::samtools=1.15.1" : null)
diff --git a/modules/local/hicpro/build_contact_maps.nf b/modules/local/hicpro/build_contact_maps.nf
index 097ff59..18ed243 100644
--- a/modules/local/hicpro/build_contact_maps.nf
+++ b/modules/local/hicpro/build_contact_maps.nf
@@ -1,5 +1,5 @@
 process BUILD_CONTACT_MAPS{
-  tag "$meta.id - $res"
+  tag "${meta.id}"
   label 'process_high_memory'
 
   conda (params.enable_conda ? "conda-forge::sed=4.7" : null)
@@ -8,19 +8,20 @@ process BUILD_CONTACT_MAPS{
       'ubuntu:20.04' }"
 
   input:
-  tuple val(meta), path(vpairs), val(res) 
-  path chrsize 
+  tuple val(meta), path(vpairs), val(resolution) 
+  tuple val(meta2), path(chrsize) 
 
   output:
-  tuple val(meta), val(res), path("*.matrix"), path("*.bed"), emit: maps
+  tuple val(meta), val(resolution), path("*.matrix"), path("*.bed"), emit: maps
    
   script:
+  def prefix = task.ext.prefix ?: "${meta.id}"
   """
   build_matrix \\
     --matrix-format upper  \\
-    --binsize ${res} \\
+    --binsize ${resolution} \\
     --chrsizes ${chrsize} \\
     --ifile ${vpairs} \\
-    --oprefix ${meta.id}_${res}
+    --oprefix ${prefix}
   """
 }
diff --git a/modules/local/hicpro/combine_mates.nf b/modules/local/hicpro/combine_mates.nf
index 83b18dc..c0a8063 100644
--- a/modules/local/hicpro/combine_mates.nf
+++ b/modules/local/hicpro/combine_mates.nf
@@ -1,5 +1,5 @@
 process COMBINE_MATES {
-    tag "$prefix"
+    tag "${meta.id}"
     label 'process_low'
 
     conda (params.enable_conda ? "conda-forge::python=3.9  bioconda::pysam=0.19.0" : null)
diff --git a/modules/local/hicpro/merge_stats.nf b/modules/local/hicpro/merge_stats.nf
index 743f374..757ec23 100644
--- a/modules/local/hicpro/merge_stats.nf
+++ b/modules/local/hicpro/merge_stats.nf
@@ -1,4 +1,5 @@
 process MERGE_STATS {
+    tag "${meta.id}"
     label 'process_low'
 
     conda (params.enable_conda ? "conda-forge::python=3.9" : null)
diff --git a/modules/local/hicpro/run_ice.nf b/modules/local/hicpro/run_ice.nf
index 996baf1..bf9bf6e 100644
--- a/modules/local/hicpro/run_ice.nf
+++ b/modules/local/hicpro/run_ice.nf
@@ -1,5 +1,5 @@
 process ICE_NORMALIZATION{
-    tag "$rmaps"
+    tag "${meta.id}"
     label 'process_high_memory'
 
     conda (params.enable_conda ? "conda-forge::python=3.9  bioconda::iced=0.5.10 conda-forge::numpy=1.22.3" : null)
diff --git a/modules/local/multiqc.nf b/modules/local/multiqc.nf
index 8fa76a1..8af7656 100644
--- a/modules/local/multiqc.nf
+++ b/modules/local/multiqc.nf
@@ -1,10 +1,10 @@
 process MULTIQC {
     label 'process_medium'
 
-    conda (params.enable_conda ? 'bioconda::multiqc=1.12' : null)
-    container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
-        'https://depot.galaxyproject.org/singularity/multiqc:1.12--pyhdfd78af_0' :
-        'quay.io/biocontainers/multiqc:1.12--pyhdfd78af_0' }"
+    conda (params.enable_conda ? 'bioconda::multiqc=1.13' : null)
+     container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
+        'https://depot.galaxyproject.org/singularity/multiqc:1.13--pyhdfd78af_0' :
+        'quay.io/biocontainers/multiqc:1.13--pyhdfd78af_0' }"
 
     input:
     path multiqc_config
diff --git a/modules/local/split_cooler_dump.nf b/modules/local/split_cooler_dump.nf
index 38e7357..b7272e8 100644
--- a/modules/local/split_cooler_dump.nf
+++ b/modules/local/split_cooler_dump.nf
@@ -2,12 +2,17 @@ process SPLIT_COOLER_DUMP {
     tag "$meta.id"
     label 'process_low'
 
+    conda (params.enable_conda ? "conda-forge::gawk=5.1.0" : null)
+    container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
+      'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
+      'ubuntu:20.04' }"
+   
     input:
     tuple val(meta), path(bedpe)
 
     output:
-    path "*.txt", emit: matrix
-    path "versions.yml", emit: versions
+    tuple val(meta), path("*.txt"), emit: matrix
+    path ("versions.yml"), emit: versions
 
     script:
     def args = task.ext.args ?: ''
diff --git a/subworkflows/local/hicpro.nf b/subworkflows/local/hicpro.nf
index 8b106a0..60f99e0 100644
--- a/subworkflows/local/hicpro.nf
+++ b/subworkflows/local/hicpro.nf
@@ -72,6 +72,7 @@ workflow HICPRO {
   
   //if (params.split_fastq){
   ch_valid_pairs = ch_valid_pairs.map{ it -> removeChunks(it)}.groupTuple()
+  ch_valid_pairs.view()
   ch_hicpro_stats = HICPRO_MAPPING.out.mapstats.map{it->removeChunks(it)}.groupTuple()
                       .concat(HICPRO_MAPPING.out.pairstats.map{it->removeChunks(it)}.groupTuple(),
 		        ch_valid_stats.map{it->removeChunks(it)}.groupTuple())
diff --git a/subworkflows/local/input_check.nf b/subworkflows/local/input_check.nf
index 9735a49..3f21f1f 100644
--- a/subworkflows/local/input_check.nf
+++ b/subworkflows/local/input_check.nf
@@ -9,7 +9,6 @@ workflow INPUT_CHECK {
     samplesheet // file: /path/to/samplesheet.csv
 
     main:
-
     if (params.split_fastq){
 
       SAMPLESHEET_CHECK ( samplesheet )
diff --git a/workflows/hic.nf b/workflows/hic.nf
index d5ba119..0f39687 100644
--- a/workflows/hic.nf
+++ b/workflows/hic.nf
@@ -184,6 +184,7 @@ workflow HIC {
   //
   // SUB-WORFLOW: HiC-Pro
   //
+  INPUT_CHECK.out.reads.view()
   HICPRO (
     INPUT_CHECK.out.reads,
     PREPARE_GENOME.out.index,
-- 
GitLab