From 5402ab5f8e391a643480cd5936c61d732583e3e8 Mon Sep 17 00:00:00 2001
From: nservant <nicolas.servant@curie.fr>
Date: Thu, 15 Apr 2021 12:17:41 +0200
Subject: [PATCH] update lint

---
 CHANGELOG.md         |  1 +
 main.nf              | 45 ++++++++++----------------------------------
 nextflow.config      |  2 +-
 nextflow_schema.json | 24 +++++++++++------------
 4 files changed, 24 insertions(+), 48 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd4557d..0f84a8a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## v1.3.0dev
 
+* Add `--hicpro_maps` options to generate the raw and normalized HiC-Pro maps. The default is now to use cooler
 * Add HiCExplorer distance decay quality control
 * Add HiCExplorer TADs calling
 * Add insulation score TADs calling
diff --git a/main.nf b/main.nf
index e45087a..177050a 100644
--- a/main.nf
+++ b/main.nf
@@ -730,7 +730,7 @@ process merge_stats {
    set val(prefix), file(fstat) from all_mapstat.groupTuple().concat(all_pairstat.groupTuple(), all_rsstat.groupTuple())
 
    output:
-   file("mstats/") into all_mstats
+   file("mstats/${sample}/*") into all_mstats
 
   script:
   sample = prefix.toString() - ~/(_R1|_R2|_val_1|_val_2|_1|_2)/
@@ -745,7 +745,7 @@ process merge_stats {
 
 /*
  * HiC-Pro build matrix processes
- * ONGOING VALIDATION - TO REPLACED BY COOLER ?
+ * kept for backward compatibility
  */
 
 
@@ -755,7 +755,7 @@ process build_contact_maps{
    publishDir "${params.outdir}/hicpro/matrix/raw", mode: params.publish_dir_mode
 
    when:
-   !params.skip_maps
+   !params.skip_maps && params.hicpro_maps
 
    input:
    set val(sample), file(vpairs), val(mres) from ch_vpairs.combine(map_res)
@@ -776,14 +776,14 @@ process run_ice{
    publishDir "${params.outdir}/hicpro/matrix/iced", mode: params.publish_dir_mode
 
    when:
-   !params.skip_maps && !params.skip_ice
+   !params.skip_maps && !params.skip_balancing && params.hicpro_maps
 
    input:
    set val(sample), val(res), file(rmaps), file(bed) from raw_maps
 
    output:
-   set val(sample), val(res), file("*iced.matrix"), file(bed) into iced_maps_4h5, iced_maps_4cool
-   file ("*.biases") into iced_bias
+   set val(sample), val(res), file("*iced.matrix"), file(bed) into hicpro_iced_maps
+   file ("*.biases") into hicpro_iced_bias
 
    script:
    prefix = rmaps.toString() - ~/(\.matrix)?$/
@@ -896,31 +896,6 @@ process cooler_zoomify {
 }
 
 
-/*
- * Create h5 file
-
-process convert_to_h5 {
-  tag "$sample"
-  label 'process_medium'
-  publishDir "${params.outdir}/contact_maps/norm/h5", mode: 'copy'
-
-  input:
-  set val(sample), val(res), file(maps)  from norm_cool_maps_h5
-
-  output:
-  set val(sample), val(res), file("*.h5") into h5maps_ddecay, h5maps_ccomp, h5maps_tads
-
-  script:
-  """
-  hicConvertFormat --matrices ${maps} \
-  		   --outFileName ${maps.baseName}.h5 \
-		   --resolution ${res} \
-		   --inputFormat cool \
-		   --outputFormat h5 \
-  """
-}
-*/
-
 /****************************************************
  * DOWNSTREAM ANALYSIS
  */
@@ -946,7 +921,7 @@ process dist_decay {
   !params.skip_dist_decay
 
   input:
-  set val(sample), val(res), file(h5mat), val(r) from chddecay
+  set val(sample), val(res), file(maps), val(r) from chddecay
   
   output:
   file("*_distcount.txt")
@@ -955,9 +930,9 @@ process dist_decay {
 
   script:
   """
-  hicPlotDistVsCounts --matrices ${h5mat} \
-                      --plotFile ${h5mat.baseName}_distcount.png \
-  		      --outFileData ${h5mat.baseName}_distcount.txt
+  hicPlotDistVsCounts --matrices ${maps} \
+                      --plotFile ${maps.baseName}_distcount.png \
+  		      --outFileData ${maps.baseName}_distcount.txt
   """
 }
 
diff --git a/nextflow.config b/nextflow.config
index c5b39ad..ecd633f 100644
--- a/nextflow.config
+++ b/nextflow.config
@@ -62,6 +62,7 @@ params {
   // Contact maps
   bin_size = '1000000'
   res_zoomify = '5000'
+  hicpro_maps = false
   ice_max_iter = 100
   ice_filter_low_count_perc = 0.02
   ice_filter_high_count_perc =  0
@@ -75,7 +76,6 @@ params {
 
   // Workflow
   skip_maps = false
-  skip_ice = false
   skip_balancing = false
   skip_mcool = false
   skip_dist_decay = false
diff --git a/nextflow_schema.json b/nextflow_schema.json
index 9274877..93591e7 100644
--- a/nextflow_schema.json
+++ b/nextflow_schema.json
@@ -162,12 +162,12 @@
                 "bwt2_opts_end2end": {
                     "type": "string",
                     "default": "'--very-sensitive -L 30 --score-min L,-0.6,-0.2 --end-to-end --reorder'",
-                    "description": "Option for end-to-end bowtie mapping"
+                    "description": "Option for HiC-Pro end-to-end bowtie mapping"
                 },
                 "bwt2_opts_trimmed": {
                     "type": "string",
                     "default": "'--very-sensitive -L 20 --score-min L,-0.6,-0.2 --end-to-end --reorder'",
-                    "description": "Option for trimmed reads mapping"
+                    "description": "Option for HiC-Pro trimmed reads mapping"
                 },
                 "save_aligned_intermediates": {
                     "type": "boolean",
@@ -212,7 +212,7 @@
                 }
             }
         },
-        "contact_maps_options": {
+        "contact_maps": {
             "title": "Contact maps",
             "type": "object",
             "description": "Options to build Hi-C contact maps",
@@ -224,24 +224,28 @@
                     "default": "'1000000,500000'",
                     "description": "Resolution to build the maps (comma separated)"
                 },
+                "hicpro_maps": {
+                    "type": "string",
+                    "description": "Generate raw and normalized contact maps with HiC-Pro"
+                },
                 "ice_filter_low_count_perc": {
                     "type": "number",
                     "default": 0.02,
-                    "description": "Filter low counts rows before normalization"
+                    "description": "Filter low counts rows before HiC-Pro normalization"
                 },
                 "ice_filter_high_count_perc": {
                     "type": "integer",
-                    "description": "Filter high counts rows before normalization"
+                    "description": "Filter high counts rows before HiC-Pro normalization"
                 },
                 "ice_eps": {
                     "type": "number",
                     "default": 0.1,
-                    "description": "Threshold for ICE convergence"
+                    "description": "Threshold for HiC-Pro ICE convergence"
                 },
                 "ice_max_iter": {
                     "type": "integer",
                     "default": 100,
-                    "description": "Maximum number of iteraction for ICE normalization"
+                    "description": "Maximum number of iteraction for HiC-Pro ICE normalization"
                 },
                 "res_zoomify": {
                     "type": "string",
@@ -289,10 +293,6 @@
                     "type": "boolean",
                     "description": "Do not build contact maps"
                 },
-                "skip_ice": {
-                    "type": "boolean",
-                    "description": "Do not run ICE normalization"
-                },
                 "skip_dist_decay": {
                     "type": "boolean",
                     "description": "Do not run distance/decay plot"
@@ -517,7 +517,7 @@
             "$ref": "#/definitions/valid_pairs_detection"
         },
         {
-            "$ref": "#/definitions/contact_maps_options"
+            "$ref": "#/definitions/contact_maps"
         },
         {
             "$ref": "#/definitions/downstream_analysis"
-- 
GitLab