From d2eccc077dc2291e969ccffca2c7c522c4219398 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 17 Jun 2020 15:16:00 +0200 Subject: [PATCH] src/nt_composition/config.py: modifications of function to handle global_weight parameters --- src/nt_composition/config.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/nt_composition/config.py b/src/nt_composition/config.py index 14f0a395..504ca2ab 100644 --- a/src/nt_composition/config.py +++ b/src/nt_composition/config.py @@ -10,25 +10,37 @@ file that will be produced by this module. from ..db_utils.config import Config -def get_weight_folder(weight: int): +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 """ - weight_folder = ConfigNt.density_folder / f"weight:{weight}" + if global_weight == 0: + weight_folder = ConfigNt.density_folder / f"project_weight:{weight}" + else: + weight_folder = ConfigNt.density_folder / \ + f"weight:{weight}-global_weight:{global_weight}" weight_folder.mkdir(parents=True, exist_ok=True) return weight_folder -def get_density_file(weight: int, project: str, ft_type: str, ft: str, - fig: bool = False): +def get_density_file(weight: int, global_weight: int, project: str, + ft_type: str, ft: str, fig: bool = False): """ Get the filename that will contain the density data or figure. :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 :param project: A project name :param ft_type: A feature type :param ft: A feature @@ -39,16 +51,21 @@ def get_density_file(weight: int, project: str, ft_type: str, ft: str, ext = "pdf" else: ext = "txt" - res_folder = get_weight_folder(weight) / project + res_folder = get_weight_folder(weight, global_weight) / project res_folder.mkdir(exist_ok=True, parents=True) return res_folder / f"{project}_{ft_type}_{ft}_density.{ext}" -def get_density_recap(weight: int, ft_type: str, ft: str, fig: bool = False): +def get_density_recap(weight: int, global_weight: int, + ft_type: str, ft: str, fig: bool = False): """ Get the density correlation recap file. :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 :param ft_type: A feature type :param ft: A feature :return: @@ -57,7 +74,7 @@ def get_density_recap(weight: int, ft_type: str, ft: str, fig: bool = False): ext = "pdf" else: ext = "txt" - outfolder = get_weight_folder(weight) + outfolder = get_weight_folder(weight, global_weight) outfolder.mkdir(exist_ok=True, parents=True) return outfolder / f"{ft_type}_{ft}_density_recap.{ext}" -- GitLab