diff --git a/src/find_interaction_cluster/community_finder.py b/src/find_interaction_cluster/community_finder.py index 82dfbf920cfc9def17a15487a71b9c61851c1a10..0ae68de0b05eaa90ae1af313e3068280492cbe41 100644 --- a/src/find_interaction_cluster/community_finder.py +++ b/src/find_interaction_cluster/community_finder.py @@ -11,7 +11,7 @@ import networkx as nx import numpy as np from networkx.algorithms import community import sqlite3 -from .config import ConfigGraph +from .config import ConfigGraph, get_communities from ..nt_composition.make_nt_correlation import get_project_colocalisation from ..logging_conf import logging_def import pandas as pd @@ -87,25 +87,6 @@ def write_cytoscape_graph(graph: nx.Graph, dic_community: Dict[str, str], f.write(res) -def get_communities(result: Path, threshold: int = 0) -> List[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 - :return: The list of communities find by the hipMCL program. - """ - communities = [] - with result.open('r') as f: - for line in f: - tmp = line.replace('\n', '').strip().split(' ') - if len(tmp) > threshold: - communities.append(tmp) - return communities - - def find_communities(graph: nx.Graph, project: str, outfile: Path, result_file: Path ) -> Tuple[pd.DataFrame, Dict]: @@ -122,7 +103,7 @@ def find_communities(graph: nx.Graph, project: str, logging.debug("Finding community ...") if not result_file.is_file(): cmd = f"mpirun -np 1 {ConfigGraph.get_hipmcl_prog()} -M {outfile} " \ - f"-I 1.2 -per-process-mem 50 -o {result_file}" + f"-I 1.5 -per-process-mem 50 -o {result_file}" sp.check_call(cmd, shell=True, stderr=sp.STDOUT) communities = get_communities(result_file) dic_community = {} diff --git a/src/find_interaction_cluster/config.py b/src/find_interaction_cluster/config.py index a35de0553d9e9dcbe82eb7596d369610d26f4b2d..0fbafd92cabeab92d572e3568371fb0c842e077c 100644 --- a/src/find_interaction_cluster/config.py +++ b/src/find_interaction_cluster/config.py @@ -9,6 +9,7 @@ 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 def get_weight_folder(weight: int, global_weight: int): @@ -78,6 +79,25 @@ def get_hipmcl_prog() -> Path: return get_hipmcl_folder() / "bin" / "hipmcl" +def get_communities(result: Path, threshold: int = 0) -> List[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 + :return: The list of communities find by the hipMCL program. + """ + communities = [] + with result.open('r') as f: + for line in f: + tmp = line.replace('\n', '').strip().split(' ') + if len(tmp) > threshold: + communities.append(tmp) + return communities + + class ConfigGraph: """ Class containing all the variables that will be used in this submodule