Skip to content
Snippets Groups Projects
Commit 92b7dca7 authored by nfontrod's avatar nfontrod
Browse files

src/find_interaction_cluster/config.py: get_community ->...

src/find_interaction_cluster/config.py: get_community -> get_communities_basefile and creation of a new get_community function
parent 3919c987
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,8 @@ Description: Configuration folder
from ..db_utils.config import Config
from pathlib import Path
from ..figures_utils.config_figures import get_good_project
from typing import List
from typing import List, Dict
import pandas as pd
def get_weight_folder(weight: int, global_weight: int):
......@@ -81,7 +82,8 @@ def get_hipmcl_prog() -> Path:
return get_hipmcl_folder() / "bin" / "hipmcl"
def get_communities(result: Path, threshold: int = 0) -> List[List[str]]:
def get_communities_basefile(result: Path, threshold: int = 0
) -> List[List[str]]:
"""
Get the communities inside the file `result`
......@@ -100,6 +102,31 @@ def get_communities(result: Path, threshold: int = 0) -> List[List[str]]:
return communities
def get_communities(result: Path, feature: str, threshold: int = 0,
) -> Dict[str, List[str]]:
"""
Get the communities inside the file `result`
:param result: A file containing the communities found by the hipMCL \
program.
:param threshold: The number of exon the community must contains at least \
to be recovered
:param feature: The kind of feature analysed
:return: The list of communities find by the hipMCL program.
>>> get_communities(Config.tests_files / "test_community_file.txt", "gene",
... 0)
{'C1': ['415', '416', '421', '422', '423', '433', '441', '475', \
'481', '502', '511'], 'C2': ['10123', '10209', '8812', '9140', '9166']}
"""
df = pd.read_csv(result, sep="\t")[["community", "nodes", f"{feature}s"]]
df = df[df["nodes"] >= threshold].copy()
df.index = df["community"]
df.drop(["nodes", "community"], axis=1, inplace=True)
dic = df.to_dict()[f"{feature}s"]
return {k: dic[k].split(", ") for k in dic}
class ConfigGraph:
"""
Class containing all the variables that will be used in this submodule
......@@ -116,4 +143,3 @@ class ConfigGraph:
get_hipmcl_prog = get_hipmcl_prog
good_projects = get_good_project()
ppi_threshold = 700
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