From c3fd3dfafb6f0e4eff4c81a4c5a064c0175ecbae Mon Sep 17 00:00:00 2001
From: Mia Croiset <mia.croiset@ens-lyon.fr>
Date: Wed, 10 May 2023 15:55:09 +0200
Subject: [PATCH] hicstuff fragment & filter plot option correction

---
 bin/hicstuff_filter.py                    | 13 ++++++++++---
 bin/hicstuff_fragments.py                 |  8 ++++++++
 conf/hicstuff.config                      | 10 +++++-----
 modules/local/hicstuff/filter_event.nf    |  1 +
 modules/local/hicstuff/fragment_enzyme.nf |  1 +
 5 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/bin/hicstuff_filter.py b/bin/hicstuff_filter.py
index a06f9e6..23b7424 100755
--- a/bin/hicstuff_filter.py
+++ b/bin/hicstuff_filter.py
@@ -538,13 +538,20 @@ if __name__ == "__main__":
     prefix = args.prefix
     pairs_out = prefix+"_"+pairs_out
     plot = args.plot
-    plot.title()
-    if plot == "False":
+    if plot.lower() == "false":
         plot = False
-    elif plot == "True":
+    elif plot.lower() == "true":
         plot = True
     dist_plot = args.dist_plot
+    if dist_plot == "None":
+        dist_plot = None
+    else:
+        dist_plot = prefix+"_"+dist_plot
     pie_plot = args.pie_plot
+    if pie_plot == "None":
+        pie_plot = None
+    else:
+        pie_plot = prefix+"_"+pie_plot
 
     uncut_thr, loop_thr = get_thresholds(
         pairs_idx, plot_events=plot, fig_path=dist_plot, prefix=prefix
diff --git a/bin/hicstuff_fragments.py b/bin/hicstuff_fragments.py
index 489945d..5594097 100755
--- a/bin/hicstuff_fragments.py
+++ b/bin/hicstuff_fragments.py
@@ -19,9 +19,17 @@ if __name__ == "__main__":
     index = args.index
     min_size = args.min_size
     circular = args.circular
+    if circular.lower() == "false":
+        circular = False
+    elif circular.lower() == "true":
+        circular = True
     output_contigs = args.output_contigs
     output_frags = args.output_frags
     plot = args.plot
+    if plot.lower() == "false":
+        plot = False
+    elif plot.lower() == "true":
+        plot = True
     fig_path = args.fig_path
 
 
diff --git a/conf/hicstuff.config b/conf/hicstuff.config
index a4e4be8..44f2782 100644
--- a/conf/hicstuff.config
+++ b/conf/hicstuff.config
@@ -121,10 +121,10 @@ params {
     // Hicstuff
     hicstuff_bwt2_align_opts = '--very-sensitive-local'
     hicstuff_min_size = 0
-    hicstuff_circular = 'False'
+    hicstuff_circular = 'frue'
     hicstuff_output_contigs = 'info_contigs.txt'
     hicstuff_output_frags = 'fragments_list.txt'
-    hicstuff_frags_plot = 'False'
+    hicstuff_frags_plot = 'false'
     hicstuff_frags_plot_path = 'frags_hist.pdf'
     hicstuff_valid_pairs = 'valid.pairs'
     hicstuff_valid_idx = 'valid_idx.pairs'
@@ -132,9 +132,9 @@ params {
     hicstuff_matrix = 'abs_fragments_contacts_weighted.txt'
     hicstuff_bin = 10000
     hicstuff_valid_idx_filtered = 'valid_idx_filtered.pairs'
-    hicstuff_plot_events = 'False'
-    hicstuff_pie_plot = 'None'
-    hicstuff_dist_plot = 'None'
+    hicstuff_plot_events = 'false'
+    hicstuff_pie_plot = 'distrib'
+    hicstuff_dist_plot = 'dist'
 
     //Hicstuff optional modules
     filter_event = true
diff --git a/modules/local/hicstuff/filter_event.nf b/modules/local/hicstuff/filter_event.nf
index bc45e87..2fa7051 100644
--- a/modules/local/hicstuff/filter_event.nf
+++ b/modules/local/hicstuff/filter_event.nf
@@ -10,6 +10,7 @@ process FILTER_EVENT {
 
     output:
     tuple val(meta1), path("*_valid_idx_filtered.pairs"), emit: idx_pairs_filtered
+    path("*.png"), optional: true
 
     script:
 
diff --git a/modules/local/hicstuff/fragment_enzyme.nf b/modules/local/hicstuff/fragment_enzyme.nf
index d17fdfe..b770ee4 100644
--- a/modules/local/hicstuff/fragment_enzyme.nf
+++ b/modules/local/hicstuff/fragment_enzyme.nf
@@ -12,6 +12,7 @@ process FRAGMENT_ENZYME {
     output:
     tuple val(meta), path(params.hicstuff_output_contigs) , emit: info_contigs
     tuple val(meta), path(params.hicstuff_output_frags), emit: fragments_list
+    path("*.pdf"), optional: true
 
     script:
 
-- 
GitLab