From 55ea1762b493f4248c23c33e4d7af4e76fe73825 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 15 Jul 2020 15:53:58 +0200 Subject: [PATCH] move get_community from src/find_interaction_cluster/community_finder.py to src/find_interaction_cluster/config.py --- .../community_finder.py | 23 ++----------------- src/find_interaction_cluster/config.py | 20 ++++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/find_interaction_cluster/community_finder.py b/src/find_interaction_cluster/community_finder.py index 82dfbf92..0ae68de0 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 a35de055..0fbafd92 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 -- GitLab