Skip to content
Snippets Groups Projects
Commit 4e3f9b0f authored by nfontrod's avatar nfontrod
Browse files

src/nt_composition/config.py: add the parameter community_size in...

src/nt_composition/config.py: add the parameter community_size in get_weight_folder, get_density_file and get_density_recap functions. This parameter corresponds to the minimum size of community for which we want to concider the exons it contains. None if we don't want this filter
parent 4d0e8aef
No related branches found
No related tags found
No related merge requests found
...@@ -8,11 +8,13 @@ file that will be produced by this module. ...@@ -8,11 +8,13 @@ file that will be produced by this module.
""" """
from ..db_utils.config import Config 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 ..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. Get the weight folder.
...@@ -22,23 +24,29 @@ def get_weight_folder(weight: int, global_weight: int, ft_type: str): ...@@ -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 \ by project, else all projet are merge together and the interaction \
seen in `global_weight` project are taken into account seen in `global_weight` project are taken into account
:parma ft_type: The type fo featrue of interst :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 \ :return: The folder that will contains the interaction with a weight \
greater or equal to `weigh` in ChIA-PET projects 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: if global_weight == 0:
weight_folder = ConfigNt.density_folder / \ weight_folder = ConfigNt.density_folder / \
f"{ft_type}_project_weight-{weight}" f"{ft_type}_project_weight-{weight}{c}"
else: else:
weight_folder = ConfigNt.density_folder / \ weight_folder = ConfigNt.density_folder / \
f"{ft_type}_weight-{weight}_" \ f"{ft_type}_weight-{weight}_" \
f"global_weight-{global_weight}" f"global_weight-{global_weight}{c}"
weight_folder.mkdir(parents=True, exist_ok=True) weight_folder.mkdir(parents=True, exist_ok=True)
return weight_folder return weight_folder
def get_density_file(weight: int, global_weight: int, project: str, def get_density_file(weight: int, global_weight: int, project: str,
ft_type: str, ft: str, fig: bool = False, 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. 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, ...@@ -52,19 +60,22 @@ def get_density_file(weight: int, global_weight: int, project: str,
:param ft: A feature :param ft: A feature
:param fig: Say if the result file is a figure or not :param fig: Say if the result file is a figure or not
:param kind: The kind of the figure :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. :return: The filename that will contain the density data or figure.
""" """
if fig: if fig:
ext = "pdf" ext = "pdf"
else: else:
ext = "txt" 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) res_folder.mkdir(exist_ok=True, parents=True)
return res_folder / f"{project}_{ft_type}_{ft}_{kind}.{ext}" return res_folder / f"{project}_{ft_type}_{ft}_{kind}.{ext}"
def get_density_recap(weight: int, global_weight: int, 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. Get the density correlation recap file.
...@@ -76,13 +87,15 @@ def get_density_recap(weight: int, global_weight: int, ...@@ -76,13 +87,15 @@ def get_density_recap(weight: int, global_weight: int,
:param ft_type: A feature type :param ft_type: A feature type
:param ft: A feature :param ft: A feature
:param fig: Say if the result file is a figure or not :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: :return:
""" """
if fig: if fig:
ext = "pdf" ext = "pdf"
else: else:
ext = "txt" 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) outfolder.mkdir(exist_ok=True, parents=True)
return outfolder / f"{ft_type}_{ft}_density_recap.{ext}" return outfolder / f"{ft_type}_{ft}_density_recap.{ext}"
...@@ -151,3 +164,4 @@ class ConfigNt: ...@@ -151,3 +164,4 @@ class ConfigNt:
get_density_file = get_density_file get_density_file = get_density_file
get_features = get_features get_features = get_features
good_projects = get_good_project() good_projects = get_good_project()
get_community_file = ConfigGraph.get_community_file
\ No newline at end of file
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