From 9cc3eb53d7ca43eed80aa2f13ca01ef6ede15368 Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Fri, 10 Jul 2020 10:12:20 +0200
Subject: [PATCH] src/find_interaction_cluster/config.py: chnage cpu value

---
 src/find_interaction_cluster/config.py | 33 +++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/find_interaction_cluster/config.py b/src/find_interaction_cluster/config.py
index 58ed8283..0cbd7d15 100644
--- a/src/find_interaction_cluster/config.py
+++ b/src/find_interaction_cluster/config.py
@@ -10,8 +10,31 @@ from ..db_utils.config import Config
 from pathlib import Path
 
 
+def get_weight_folder(weight: int, global_weight: int):
+    """
+    Get the weight folder.
+
+    :param weight: The weight of interaction to consider
+    :param global_weight: The global weight to consider. if \
+    the global weight is equal to 0 then then density figure are calculated \
+    by project, else all projet are merge together and the interaction \
+    seen in `global_weight` project are taken into account
+    :return: The folder that will contains the interaction with a weight \
+    greater or equal to `weigh` in ChIA-PET projects
+    """
+    if global_weight == 0:
+        weight_folder = ConfigGraph.community_folder / \
+                        f"project_weight-{weight}"
+    else:
+        weight_folder = ConfigGraph.community_folder / \
+                        f"weight-{weight}_" \
+                        f"global_weight-{global_weight}"
+    weight_folder.mkdir(parents=True, exist_ok=True)
+    return weight_folder
+
+
 def get_community_file(project: str, weight: int, global_weight: int,
-                       same_gene: bool, ext: str = ".txt"):
+                       same_gene: bool, ext: str = ".txt", stat: bool = False):
     """
     Get the output file of interest.
 
@@ -24,9 +47,13 @@ def get_community_file(project: str, weight: int, global_weight: int,
     :param same_gene: Say if we consider as co-localised exon within the \
     same gene
     :param ext: The file extension
+    :param stat: True to place the result in 'sf_community_enrichment' \
+     subfolder
     :return: The filename of interest
     """
-    folder = ConfigGraph.community_folder
+    folder = get_weight_folder(weight, global_weight)
+    if stat:
+        folder = folder / 'sf_community_enrichment'
     folder.mkdir(exist_ok=True, parents=True)
     if global_weight != 0:
         project = f"global-weight-{global_weight}"
@@ -55,7 +82,7 @@ class ConfigGraph:
     Class containing all the variables that will be used in this submodule
     """
     data = Config.data
-    cpu = 1 # Config.cpu
+    cpu = 7 # Config.cpu
     db_file = Config.db_file
     results = Config.results
     output_folder = results / 'community_of_co-localized-exons'
-- 
GitLab