diff --git a/src/nt_composition/config.py b/src/nt_composition/config.py index ace3744b14cff356a8a0ca6742bcfb1b90f710cc..14f0a395501be622c4175fc7c9c0a990fbd78ba0 100644 --- a/src/nt_composition/config.py +++ b/src/nt_composition/config.py @@ -10,11 +10,25 @@ file that will be produced by this module. from ..db_utils.config import Config -def get_density_file(project: str, ft_type: str, ft: str, +def get_weight_folder(weight: int): + """ + Get the weight folder. + + :param weight: The weight of interaction to consider + :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}" + 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): """ Get the filename that will contain the density data or figure. + :param weight: The weight of interaction to consider :param project: A project name :param ft_type: A feature type :param ft: A feature @@ -25,15 +39,16 @@ def get_density_file(project: str, ft_type: str, ft: str, ext = "pdf" else: ext = "txt" - res_folder = ConfigNt.density_folder / project + res_folder = get_weight_folder(weight) / project res_folder.mkdir(exist_ok=True, parents=True) return res_folder / f"{project}_{ft_type}_{ft}_density.{ext}" -def get_density_recap(ft_type: str, ft: str, fig: bool = False): +def get_density_recap(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 ft_type: A feature type :param ft: A feature :return: @@ -42,8 +57,21 @@ def get_density_recap(ft_type: str, ft: str, fig: bool = False): ext = "pdf" else: ext = "txt" - ConfigNt.density_folder.mkdir(exist_ok=True, parents=True) - return ConfigNt.density_folder / f"{ft_type}_{ft}_density_recap.{ext}" + outfolder = get_weight_folder(weight) + outfolder.mkdir(exist_ok=True, parents=True) + return outfolder / f"{ft_type}_{ft}_density_recap.{ext}" + + +def get_interaction_file(weight: int): + """ + Return the interaction file : coresponding to the file containing \ + iteraction with a weight greater or eaqual to `weight` + + :param weight: minimum weight of interaction to \ + concider + :return: The interaction filename + """ + return ConfigNt.interaction / f"interaction_number_weight>={weight}_by_project.txt" class ConfigNt: @@ -56,7 +84,7 @@ class ConfigNt: db_file = Config.db_file output_folder = result / "nt_composition" interaction = output_folder / 'interaction_number' - interaction_file = interaction / "interaction_number_by_project.txt" + get_interaction_file = get_interaction_file density_folder = output_folder / 'density_fig' get_density_recap = get_density_recap selected_project = interaction / "selected_sample.txt"