diff --git a/src/nt_composition/config.py b/src/nt_composition/config.py index 97f29467185b1638c80bdeda17bf706b4027b83d..8dc88e86ae8954ff51d879f6f0bbc039e10c7f61 100644 --- a/src/nt_composition/config.py +++ b/src/nt_composition/config.py @@ -8,11 +8,13 @@ file that will be produced by this module. """ from ..db_utils.config import Config -from typing import List +from typing import List, Optional from ..figures_utils.config_figures import get_good_project +from ..find_interaction_cluster.config import ConfigGraph -def get_weight_folder(weight: int, global_weight: int, ft_type: str): +def get_weight_folder(weight: int, global_weight: int, ft_type: str, + community_size: Optional[int]): """ Get the weight folder. @@ -22,23 +24,29 @@ def get_weight_folder(weight: int, global_weight: int, ft_type: str): by project, else all projet are merge together and the interaction \ seen in `global_weight` project are taken into account :parma ft_type: The type fo featrue of interst + :param community_size: The minimum size of communities we want to consider :return: The folder that will contains the interaction with a weight \ greater or equal to `weigh` in ChIA-PET projects """ + if community_size is None: + c = '' + else: + c = f'_community_size_gte_{community_size}' if global_weight == 0: weight_folder = ConfigNt.density_folder / \ - f"{ft_type}_project_weight-{weight}" + f"{ft_type}_project_weight-{weight}{c}" else: weight_folder = ConfigNt.density_folder / \ f"{ft_type}_weight-{weight}_" \ - f"global_weight-{global_weight}" + f"global_weight-{global_weight}{c}" weight_folder.mkdir(parents=True, exist_ok=True) return weight_folder def get_density_file(weight: int, global_weight: int, project: str, ft_type: str, ft: str, fig: bool = False, - kind: str = 'density'): + kind: str = 'density', + community_size: Optional[int] = None): """ Get the filename that will contain the density data or figure. @@ -52,19 +60,22 @@ def get_density_file(weight: int, global_weight: int, project: str, :param ft: A feature :param fig: Say if the result file is a figure or not :param kind: The kind of the figure + :param community_size: The minimum size of communities we want to consider :return: The filename that will contain the density data or figure. """ if fig: ext = "pdf" else: ext = "txt" - res_folder = get_weight_folder(weight, global_weight, ft_type) / project + res_folder = get_weight_folder(weight, global_weight, ft_type, + community_size) / project res_folder.mkdir(exist_ok=True, parents=True) return res_folder / f"{project}_{ft_type}_{ft}_{kind}.{ext}" def get_density_recap(weight: int, global_weight: int, - ft_type: str, ft: str, fig: bool = False): + ft_type: str, ft: str, fig: bool = False, + community_size: Optional[int] = False): """ Get the density correlation recap file. @@ -76,13 +87,15 @@ def get_density_recap(weight: int, global_weight: int, :param ft_type: A feature type :param ft: A feature :param fig: Say if the result file is a figure or not + :param community_size: The minimum size of communities we want to consider :return: """ if fig: ext = "pdf" else: ext = "txt" - outfolder = get_weight_folder(weight, global_weight, ft_type) + outfolder = get_weight_folder(weight, global_weight, ft_type, + community_size) outfolder.mkdir(exist_ok=True, parents=True) return outfolder / f"{ft_type}_{ft}_density_recap.{ext}" @@ -151,3 +164,4 @@ class ConfigNt: get_density_file = get_density_file get_features = get_features good_projects = get_good_project() + get_community_file = ConfigGraph.get_community_file \ No newline at end of file