Skip to content
Snippets Groups Projects
Commit 7f594d1f authored by nfontrod's avatar nfontrod
Browse files

src/nt_composition/config.py: Creation of get_interaction_file and...

src/nt_composition/config.py: Creation of get_interaction_file and get_weight_folder function + modification of get_density_file and get_density_recap function
parent 5d18da29
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment