#!/usr/bin/env python3

# -*- coding: UTF-8 -*-

"""
Description: Configuration folder
"""

from ..db_utils.config import Config


def get_community_file(project: str, weight: int, global_weight: int,
                       same_gene: bool, is_fig: bool = False):
    """
    Get the output file of interest.

    :param project: Name of the project of interest
    :param weight: The minimum 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 same_gene: Say if we consider as co-localised exon within the \
    same gene
    :return: The filename of interest
    """
    folder = ConfigGraph.community_folder
    folder.mkdir(exist_ok=True, parents=True)
    if is_fig:
        ext = '.html'
    else:
        ext = '.txt'
    if global_weight != 0:
        project = f"global-weight-{global_weight}"
    return folder / f"{project}_weight-{weight}_same_gene-{same_gene}{ext}"


class ConfigGraph:
    """
    Class containing all the variables that will be used in this submodule
    """
    data = Config.data
    cpu = Config.cpu
    db_file = Config.db_file
    results = Config.results
    output_folder = results / 'community_of_co-localized-exons'
    community_folder = output_folder / 'communities'
    get_community_file = get_community_file