Skip to content
Snippets Groups Projects
Commit 55ea1762 authored by nfontrod's avatar nfontrod
Browse files

move get_community from src/find_interaction_cluster/community_finder.py to...

move get_community from src/find_interaction_cluster/community_finder.py to src/find_interaction_cluster/config.py
parent 72caf926
Branches
No related tags found
No related merge requests found
......@@ -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 = {}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment